I am using the 14m2 with 3 ultrasonic sensors and I get this message while trying to run the code:
symbol pingDistance1, pingDistance2, pingDistance3
^
Syntax error on line 7 at/before position 21
Error: syntax error
Here is my code that I am using:
symbol PING_1 = PIN0
symbol PING_2 = PIN1
symbol PING_3 = PIN2
symbol MOTOR_A = PIN6
symbol MOTOR_B = PIN7
symbol pingDistance1, pingDistance2, pingDistance3
symbol DISTANCE_THRESHOLD = 2
symbol ALL_SENSORS_PICKING_UP_OBJECT = 1;
; Main loop
Do: Loop
' Read the ultrasonic sensors
;pingDistance1 = ping(PING_1)
;pingDistance2 = ping(PING_2)
;pingDistance3 = ping(PING_3)
' Check if all sensors are picking up a signal with a distance of >2cm
if pingDistance1 > DISTANCE_THRESHOLD && pingDistance2 > DISTANCE_THRESHOLD && pingDistance3 > DISTANCE_THRESHOLD then
' Set the flag
;ALL_SENSORS_PICKING_UP_OBJECT = 1;
else
' Clear the flag
;ALL_SENSORS_PICKING_UP_OBJECT = 0;
endif
' If all sensors are picking up a signal with a distance of >2cm, run the motors forward
if ;ALL_SENSORS_PICKING_UP_OBJECT then
' Set the motor pins
output MOTOR_A = 1
output MOTOR_B = 1
' Wait for the time to run the motors forward
pause 10000
' Stop the motors
output MOTOR_A = 0
output MOTOR_B = 0
else
' If at least 1 sensor stops picking up a signal with a distance of >2cm, run the motors back
' Set the motor pins
output MOTOR_A = 0
output MOTOR_B = 1
' Wait for the time to run the motors back
pause 10000
' Stop the motors
output MOTOR_A = 0
output MOTOR_B = 0
' Exit the loop
Exit Loop
endif
End Do
If anyone could help me with this it would be very appreciated!
symbol pingDistance1, pingDistance2, pingDistance3
^
Syntax error on line 7 at/before position 21
Error: syntax error
Here is my code that I am using:
symbol PING_1 = PIN0
symbol PING_2 = PIN1
symbol PING_3 = PIN2
symbol MOTOR_A = PIN6
symbol MOTOR_B = PIN7
symbol pingDistance1, pingDistance2, pingDistance3
symbol DISTANCE_THRESHOLD = 2
symbol ALL_SENSORS_PICKING_UP_OBJECT = 1;
; Main loop
Do: Loop
' Read the ultrasonic sensors
;pingDistance1 = ping(PING_1)
;pingDistance2 = ping(PING_2)
;pingDistance3 = ping(PING_3)
' Check if all sensors are picking up a signal with a distance of >2cm
if pingDistance1 > DISTANCE_THRESHOLD && pingDistance2 > DISTANCE_THRESHOLD && pingDistance3 > DISTANCE_THRESHOLD then
' Set the flag
;ALL_SENSORS_PICKING_UP_OBJECT = 1;
else
' Clear the flag
;ALL_SENSORS_PICKING_UP_OBJECT = 0;
endif
' If all sensors are picking up a signal with a distance of >2cm, run the motors forward
if ;ALL_SENSORS_PICKING_UP_OBJECT then
' Set the motor pins
output MOTOR_A = 1
output MOTOR_B = 1
' Wait for the time to run the motors forward
pause 10000
' Stop the motors
output MOTOR_A = 0
output MOTOR_B = 0
else
' If at least 1 sensor stops picking up a signal with a distance of >2cm, run the motors back
' Set the motor pins
output MOTOR_A = 0
output MOTOR_B = 1
' Wait for the time to run the motors back
pause 10000
' Stop the motors
output MOTOR_A = 0
output MOTOR_B = 0
' Exit the loop
Exit Loop
endif
End Do
If anyone could help me with this it would be very appreciated!