I am currently at Codebits, were we tried to implement a physics game with Processing and Open CV. Here is the result:
Those were three funny days here! Code is available at github.
I am currently at Codebits, were we tried to implement a physics game with Processing and Open CV. Here is the result:
Those were three funny days here! Code is available at github.
I am currently at Codebits, were we tried to implement a physics game with Processing and Open CV. Here is the result:
Those were three funny days here! Code is available at github.
I always thought about connecting an Arduino controller board to my N900, to have external sensor data available on the phone. My first attempt was quite successful now, I managed to send data of an Accelerometer via a serial bluetooth connection and just print the raw data in the N900 terminal. Everything is based on my first experiments with Arduino, which I built after a sample setup on heise.de. All I did now was add a Bluesmirf Modem to RX/TX pins of the Arduino board, change the power supply from USB to 4 attached AA batteries, et voilá: I just open a serial bluetooth connection on my N900 with Python and receive the data.
This is more or less a proof of concept for now, as only raw data is printed to the N900's terminal. And, of course, the N900 also has its own accelerometer.. Anyway, here is a sketch of the board:
The controller script is very basic and should be uploaded to the Arduino board through the Processing environment:
/*
* Siehe auch:
* http://www.arduino.cc/en/Tutorial/ADXL3xx
*/
// Definition der Pins des Beschleunigungssensors ADXL330
int xPin = 2; // X-Achse
int yPin = 1; // Y-Achse
int zPin = 0; // Z-Achse
int buttonPin = 2; // Schalter
void setup() { // Initialisierung
Serial.begin(115200); // Serielle Verb., 9600 baud
pinMode(buttonPin, INPUT); // Schalter-Pin als Eingang
}
void loop() {
Serial.print(analogRead(xPin)); // X-Achse lesen, seriell ausg.
Serial.print(" ");
Serial.print(analogRead(yPin)); // Y-Achse
Serial.print(" ");
Serial.print(analogRead(zPin)); // Z-Achse
Serial.print(" ");
Serial.print(digitalRead(buttonPin)); // Schalter
Serial.println(); // Zeilenvorschub
delay(50); // 50 ms warten
}
import sys, os
import dbus
import glob
import termios, fcntl
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")
adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
"org.bluez.Adapter")
address = "00:06:66:02:CC:89"
service = "spp"
path = adapter.FindDevice(address)
serial = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Serial")
node = serial.Connect(service)
print "Connected %s to %s" % (node, address)
print "Press CTRL-C to disconnect"
a = open("/dev/rfcomm0","r")
fd = sys.stdin.fileno()
oldterm = termios.tcgetattr(fd)
newattr = termios.tcgetattr(fd)
newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, newattr)
oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
try:
while 1:
w = a.readline()
print w
try:
c = sys.stdin.read(1)
if c == 'q':
break
except IOError: pass
finally:
termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
serial.Disconnect(node)

I always thought about connecting an Arduino controller board to my N900, to have external sensor data available on the phone. My first attempt was quite successful now, I managed to send data of an Accelerometer via a serial bluetooth connection and just print the raw data in the N900 terminal. Everything is based on my first experiments with Arduino, which I built after a sample setup on heise.de. All I did now was add a Bluesmirf Modem to RX/TX pins of the Arduino board, change the power supply from USB to 4 attached AA batteries, et voilá: I just open a serial bluetooth connection on my N900 with Python and receive the data.
This is more or less a proof of concept for now, as only raw data is printed to the N900's terminal. And, of course, the N900 also has its own accelerometer.. Anyway, here is a sketch of the board:
The controller script is very basic and should be uploaded to the Arduino board through the Processing environment:
/*
* Siehe auch:
* http://www.arduino.cc/en/Tutorial/ADXL3xx
*/
// Definition der Pins des Beschleunigungssensors ADXL330
int xPin = 2; // X-Achse
int yPin = 1; // Y-Achse
int zPin = 0; // Z-Achse
int buttonPin = 2; // Schalter
void setup() { // Initialisierung
Serial.begin(115200); // Serielle Verb., 9600 baud
pinMode(buttonPin, INPUT); // Schalter-Pin als Eingang
}
void loop() {
Serial.print(analogRead(xPin)); // X-Achse lesen, seriell ausg.
Serial.print(" ");
Serial.print(analogRead(yPin)); // Y-Achse
Serial.print(" ");
Serial.print(analogRead(zPin)); // Z-Achse
Serial.print(" ");
Serial.print(digitalRead(buttonPin)); // Schalter
Serial.println(); // Zeilenvorschub
delay(50); // 50 ms warten
}
import sys, os
import dbus
import glob
import termios, fcntl
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")
adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
"org.bluez.Adapter")
address = "00:06:66:02:CC:89"
service = "spp"
path = adapter.FindDevice(address)
serial = dbus.Interface(bus.get_object("org.bluez", path),
"org.bluez.Serial")
node = serial.Connect(service)
print "Connected %s to %s" % (node, address)
print "Press CTRL-C to disconnect"
a = open("/dev/rfcomm0","r")
fd = sys.stdin.fileno()
oldterm = termios.tcgetattr(fd)
newattr = termios.tcgetattr(fd)
newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, newattr)
oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
try:
while 1:
w = a.readline()
print w
try:
c = sys.stdin.read(1)
if c == 'q':
break
except IOError: pass
finally:
termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
serial.Disconnect(node)

HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"
KTHXBYE
HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"
KTHXBYE