Hello, I would like to know how to send a variable valor from python to arduino,
my program on python looks like this
import serial
ser = serial.Serial(
port='COM3',
baudrate=9600,
)
ser.write(1)
my program on arduino looks like this
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int val = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
val = Serial.read();
Serial.print(val);
lcd.begin(16, 2);
if (val == 1){
lcd.print("Ok");}
else if (val > 1){
lcd.print("positive");}
else if (val == -1){
lcd.print("negative");
}
lcd.setCursor(0, 1);
}
despite I put a big valor in the ser.write, the "val" valor in python is the same : -1
do someone have the solution of my problem ?
sorry for my english i'm french ![]()