I coded the highlighted box to make the car stop when within 3cm of ultrasonic sensor, given the input "1", however the motors keep spinning regardless. Sensor definitely works as it prints "OBSTACLE" successfully when within 3cm of sensor. How do i fix?
Your topic was MOVED to its current forum category as it is more suitable than the original
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
You have not shown all your code or any information on how things are wired up. Why are you using a different trigger to stop the motor from the state variable that you use to print obstacle? If these are both the same trigger ie the obstacle is <3cm why not if state is true stop motor
You can't say that.
What is feeding these sensors into the serial port?
Have you got the baud rate correct?
bluetooth module, if I input 1, motors spin and if 0 motors stop. Yes, baud rate 9600. Have no clue why it still doesnt work
Do a serial print of the data you receive just after the serial read to see what it is. This will give you a big clue.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.