Tagged: Sensing Motors Start Switch Code
February 6, 2016 at 10:04 am #3254DaveParticipant
Just a tiny change to the robotic vehicle. I’ve added a sparkle to give an ‘indicator’ function for left, right and reverse. I’ve also used cheap M3 nuts and bolts as terminal posts. Croc clips got too close to each other for comfort.
The program is just to make the buggy go forwards until it meets a bright(er) surface. Then it reverses and turns while indicating, then goes forwards in the opposite direction until it meets another brighter surface. The turns are in the opposite direction so that when connected to USB it doesn’t tangle up.
You’ll notice I’ve put some little 100nF capacitors across the motor terminals as somebody told me that makes them less ‘noisy’? Is that necessary?
The code first sets A low and waits for me to touch it HIGH. I didn’t want the wheels turning before I’ve taken the buggy to a starting grid!
Then ‘y’ takes the ambient light level.
If that level is exceeded by a value I found by trial and error, the buggy stops and does a turn routine.
If its not exceeded, the buggy trundles along happily.
I’d love to have ‘interrupts’ or ‘break’ available inside the loops. One day I’ll get round to sticking a load more ‘do until A is high’ in an altered loop structure so that the program can effectively stop the buggy moving at any point. Currently, there are dirty great 460ms waits in the turn and indicate sequences.
Any suggestions for this greatly appreciated!
- This topic was modified 4 years, 11 months ago by Dave.
Attachments:You must be logged in to view attached files.
- You must be logged in to reply to this topic.