Serial Communication Between Arduino And Python, Issue Of Using Hexidecimal Values
I am attempting to start a motor from the computer by code in Python 3.4, using pySerial to communicate to an Arduino Uno. I have packed the value I am sending to hexidecimal, so I
Solution 1:
its not hard here is a simple example, its usually a good idea to start simple and then increase the functionality to what you want.
test_serial.py
import serial
ser = serial.Serial("COM4",timeout=5) # everything else is default
ser.write("\x45")
print"RECIEVED BACK:",repr(ser.read(5000))
test_serial.ino
int incomingByte = 0; // for incoming serial datavoidsetup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
voidloop() {
// send data only when you receive data:if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
Post a Comment for "Serial Communication Between Arduino And Python, Issue Of Using Hexidecimal Values"