I have a simple python script to test the communications between the Raspberry and the Arduino Uno.
In the Raspberry:
Code: Select all
#!/usr/bin/env python
import serial
arduino = serial.Serial('/dev/ttyACM0', 9600)
arduino.open()
arduino.write('D')
arduino.close()
Code: Select all
int dia = 9;
int dPWD;
void setup(){
Serial.begin(9600);
pinMode(dia,OUTPUT);
}
void loop (){
if (Serial.available()){
char c = Serial.read();
if (c=='D'){
//dPWD=Serial.parseInt();
analogWrite(dia,255);
Serial.flush();
} else if (c=='E'){
analogWrite(dia,0);
Serial.flush();
}
}
}I instaled the Arduino program in the Raspberry and I test the code in Arduino with the serial monitor and it go fine. I think that it is not comunication problem.
Could somebody help me?. I tried it solve a week...