Step 8Programming the Arduino
The other, more complex file, is the brains of the operation. I've annotated it quite thoroughly throughout the code, but feel free to ask me any questions. I'll offer a few thoughts on the code here for those who are interested.
The following variables are worth playing around with, depending how you wish to use the device:
- resolution will set the sampling interval of the sensors in milliseconds. If you increase this time, the resolution of the recording will decrease, but yo will be able to record for longer without running out of memory.
- routeSamples is the maximum number of points of data you can record. You can increase this if you have the memory capacity on your device. A better way to record longer routes would be to decrease the sampling time, resolution.
- overtakePause is the minimum time one climber must spend ahead of the other before it registers as an overtaking event. This is currently set at two seconds to prevent a rapid flurry of conflicting beeps when two climbers are neck and neck. Decrease this time for increased confusion and excitement. Notice that although it will take two seconds for a noise to play, the yellow LED will immediately respond to an overtaking event by lighting up or turning off accordingly. This can be used by judges in a clinch.
If you build this, you will need to map your sensors to your servomotors. This isn't hard at all, it just involves a little bit of playing around. Search for the word "map" in the code to see where this is relevant.
Also notice that the modes I have referred to earlier in this Instructable are numbered slightly differently in the code. Mode 1 is divided into Modes 10 and 11, Mode 2 into 20 and 21, with Mode 3 divided into Modes 30, 31 and 32.
| « Previous Step | Download PDFView All Steps | Next Step » |

















































sometimes it shows error .But Idea is brilliant
There is a lot of learning for a Jr ( wanna be coder ) like me in what you have written. Commenting is great as well.
Many thanks !
Build_it_Bob