Code: Select all
# Left state
if state == 1:
ser.write('L095')
# Change state?
if ((int(x) > w/3) & (int(x) < (w/3)*2)): state = 2 # Change to 'middle' state
if ((int(x) > (w/3)*2) & (int(x) < w)): state = 3 # Change to 'Right' state
The code below is what i have come up with to send over serial but i can't seem to join the first character L with the value obtained from the speed calculation. Not sure if i'm explaining this very well but the end goal would be for example:
speed = 1.11 * (80-10) = 78 therefore the value i need to send is 'L078' meaning 'L' Left @ '078' 78%
I somehow need to get 'L078' into ser.write('????')
Code: Select all
# Left state
if state == 1:
int(speed) = 1.11 * (radius - 10) # Speed calculation
if speed > 100: speed = 100 # Clip speed at max 100%
if speed < 0: speed = 0 # Clip speed at min 0%
ser.write('????') # Write value over serial ie. 'L078' Left at 78% speed
# Change state?
if ((int(x) > w/3) & (int(x) < (w/3)*2)): state = 2 # Change to 'middle' state
if ((int(x) > (w/3)*2) & (int(x) < w)): state = 3 # Change to 'Right' state