in my project I am sending int from python to arduino, which is the number of steps the stepper motor should take. Python code:
while(1):
userInput = input('Get data point?')
ser.write("s{}".format(int(131.0268562*userInput)).encode())
if userInput == 'c':
break;
Arduino Code:
if (Serial.available() > 0){
int receivedValue = Serial.parseInt();
digitalWrite(4,HIGH);
if (receivedValue>=0){
for(Index = 0; Index < receivedValue; Index++)
{
digitalWrite(5,HIGH);
delayMicroseconds(s);
digitalWrite(5,LOW);
delayMicroseconds(s);
}
}
}
But when the value is bigger than 30000, the code doesn't work. When I print the value on arduino side, it is either negative, or some small positive number
Why is it happening and how do I solve it?
Edit: I have solved it thanks to the helps of "quamrana" and "Serge Ballesta"
If anyone stumbles on a similar problem. Just use:
long receivedValue = Serial.Stream::parseInt();