Go Down

Topic: problem in accessing values from python correctly (Read 259 times) previous topic - next topic

batooLa_ibrahim

hello ,
my goal is to take a specific value as an input from the user (using python) and by using serial communication , i want this value to be read by the arduino uno and be applied on a motor as its speed .
but i am facing a problem in reading this value by the arduino , i guess it is not reading it as i want from the python.
so what is happening? and what i should do to take this value as it is from the python?
Thanks.
Code: [Select]

void loop()
{
 if (Serial.available()>0)
  speed = Serial.read()
  delay(1000);
  if (speed >= 0 && speed <= 255)
    {
      analogWrite(MA,speed);
      analogWrite(MB,speed);
 
    }
}
   

Robin2

These links should help get you started
Python - Arduino demo
Serial Input Basics - simple reliable ways to receive data.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up