m using arduino to interact the accelerometer MMA7361L with blender2.49.using python 2.62. my arduino code is :
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(analogRead(0)/4, BYTE); //x-axis
Serial.print(analogRead(1)/4, BYTE); //y-axis
Serial.print(analogRead(2)/4, BYTE); //z-axis
delay(40);
}
my python code is:
import Blender
import GameLogic
import serial
serialport = serial.Serial('COM4', 9600)
ob = Blender.Object.Get ('Cube')
cont=GameLogic.getCurrentController()
own = cont.owner
rotxx = move.dRot[0]
rotyy = move.dRot[1]
rotzz = move.dRot[2]
move = cont.actuators["move"]
Blender.Window.WaitCursor(1)
x=[0,0,0]
for i in range(1, 100):
x1[0] = serialport.read(size=1)
x1[1] = serialport.read(size=1)
x1[2] = serialport.read(size=1)
x2=[(((m - n)*1.65)/180) for m,n in zip(x,x1)]
rotxx = rotxx + x2[0]
rotyy = rotyy + x2[1]
rotzz = rotzz + x2[2]
move.dRot=(rotxx,rotyy,rotzz)
cont.activate(move)
x1=x
else:
serialport.close()
Blender.Window.WaitCursor(0)
have made the sensor actuator connection.. no errors shown in implementation but blender cube shows no movement.