I need help from communicating serial data from blender game engine to arduino.
I'm making keyboard input from blender and trying to communicate to arduino, but it's not working.
This is blender code
import serial
ser = serial.Serial("COM6", 9600)
x=ser.write(1)
print(x)
ser.close()
Logic
Key "a" --> Python script
and this is the arduino code i trying to communicate from blender.
int led = 2;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
if ( Serial.available())
{
char ch = Serial.read();
if(ch >= '0' && ch <= '9')
{
digitalWrite(led, HIGH);
}
}
}
Actually, when Blender Game Engine (BGE) running, and I press Key 'a' blender communicate with arduino and LED turn on.
Am I doing wrong?
Can anybody help me to solve this?