3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Laser-guided Ghost Climber

Step 8Programming the Arduino

Programming the Arduino
I have uploaded the two files needed to run the Ghost Climber program on an Arduino. One of these files, "pitches.h", is borrowed under a Creative Commons agreement from a tutorial on the Arduino website and is just a list of musical tones that the Arduino can play through its buzzer.

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.
I have programmed in a simple linear smoothing process to the servomotors' motion. This means that even if you sample from the sensor turret at a very low resolution, the servo turret will still play the motion back smoothly.

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 StepDownload PDFView All StepsNext Step »
4 comments
May 18, 2011. 10:07 AMJeevesh says:
NO Hard feelings but i just wanted to ask will the codes actually work.
sometimes it shows error .But Idea is brilliant
May 30, 2011. 9:52 AMJeevesh says:
I just wanted to know can these files be directly burned into the chip or they need some type of work to be done(conversion to some other format)
Apr 21, 2011. 6:35 PMBuild_it_Bob says:
Amazing code ! I will spend some time trying to understand it . VERY nice work!
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

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
201
Followers
24
Author:PenfoldPlant(Penfold Labs)
I'm a UK-grown tinkerer with a background in medicine and engineering, currently working (well, playing) as an Artist in Residence at the Instructables Lab in San Francisco. Please feel free to visit...
more »