Ultrasonic sensor - save value


#1

I want to buil a robot who “looks” in two directions with the ultrasonic sensor. The program must look like this:


turn head right
read value ultrasonic sensor (save value 1)
turn head left
read value ultrasonic sensor (save value 2)
compare value 1 with value 2
if value 1 > value 2 :
turn right
if value 1 < value 2 :
turn left

Now my questions are: how can i save the values, the ultrasonic sensor reads? And compare? Thanks for help.


#2

I think you could save the value in python, just in a local variable. Does that make sense? or are you trying to save it to file?