Finally got my PICAXE microcontroller and other components in the mail this past weekend. While I didn’t have a set plan on what I was going to build exactly, I knew that I needed to know how to connect each component and know the intricacies of each one separately before I start combining them into something useful. Understandably, my wife just doesn’t quite understand how someone can just sit with electronics and play with an LED light for an hour or so. My son, on the other hand, loves the idea and has an imagination that goes crazy with phrases like, “What if it could do this, ‘{insert crazy idea here}’ “. His ideas are mostly farfetched, but some of them are totally worth taking note of. He’s got an inventors mindset and I hope I can help him made some of his ideas into reality some day.
The first night I sat down with the components, my goal was simple; get an LED to light up in a breadboard without blowing it. I used battery pack, resistor and an LED and it worked just great. One of the next things I tried were several LEDs lighting up at once. I quickly learned the fact that i knew but hadn’t tried yet, that LEDs use up energy and if you didn’t have a large enough power source, only a few of the LEDs would light up. — DAH!
Working with LEDs can get boring after a while, so I then started trying to build the PICAXE-08M start kit on a breadboard. While you’re supposed to use the circuit board that comes with the kit and solder on the pieces in the marked spots, I figured that using the breadboard would allow me to disassemble it easy and do other things with it – WRONG! I failed at setting it up on the breadboard… The computer just wouldn’t connect to it. I resorted to soldering the components onto the circuit board and it worked great. Obviously my first program was a ‘hello world’-type of program that blinked an LED on and off; but it still feels good to accomplish putting something together. — The Lego builder in me hasn’t left; it just grew up!
The next night after I sorts knew what I was doing, I explained things to my 7 year old son and showed him how to make a simple circuit with LEDs. Result: A simple circuit with two LEDs and two switches…
That night, I moved on to trying to program the Piezo to make noise. I was successfully able to integrate the Piezo with the PICAXE-08M and the following sound code produced a nice little tune:
symbol dur = 10
sound 1,(127,dur,126,dur,125,dur,124,dur,123,dur,122,dur.121,dur)
I then tried to integrate a switch into the PICAXE and program it so that when the switch was pressed, it would run the sound code. I ended up not succeeding (at least so far), at the simply-seeming task. The following is what I had hooked up:
The Piezo was hooked into pin1, and i know that pin outputs just fine because it worked for my previous tests. The switch part is where things didn’t work. I had the switch hooked up into pin2 and then grounded. I also tried the switch to pin2 and also to the positive terminal; as i wasn’t sure which was supposed to work. My code seemed simple enough:
main:
if pin2 = 1 then
sound 1,(127,dur,126,dur,125,dur,124,dur,123,dur,122,dur.121,dur)
end if
goto main
The problem is that the sound would play whenever the button wasn’t pressed! I changed the programming to “if pin2 = 0″, but that just made the sound play regardless of whether the button was pressed or not. It just made no sense to me why I couldn’t get it to work. This is definitely the next step in my learning… Using a digital switch with the PICAXE-08M microcontroller!



