my first circuit

As anyone who has seen any of my earlier posts may have noticed, I am very problem-prone. I am, however certain that all my problems branch from my inexperience, could anyone with a bit of spare time look over the circuit and code I have below and spot the obvious mistake that must be there (missing capacitor, resistor, etc.)

this circuit is loaded with (note that there is a buton in-between the 5v and pin6)
this should make the light be on when I press the buton if I am to believe the simulation, intead it is always on.

if pin6 = 1
then onn
goto offf

high 7
goto main

low 7
goto main




I checked your code in my linaxepad editor. It complains about
if pin6 = 1 then onn
It must ll be on the same line. Syntax is OK otherwise.

I think your code is always looping through the subroutine “offf”. Is this what you intended to do? The result would be that the output pin always ends up low at the end of every loop. I suggest you insert a few pause commands here and there and see what happens Maybe use a voltmeter instead of your LED.

Or start coding all over. Did you know you can take an input and directl throw its value onto an output? Read some more pages in the manual.


If your code indeed makes pin 7 low all the time, or most of the time. Maybe you reversed the polarity of the LED and also connected it to V+ instead of GND? Just a wild guess.

Connect button to GND

You are using pull-up resistor so your button must be connected to GND (0V) not to Vcc (5v). Like this:


Think pull-up (or pull-down) as a default value of an input. If you pull input pin up its value is 1 by default. To change the default value you have to place your switch so that it "pulls the default value to the opposite".

Note: If Pin 6 was configurable IO pin (in 20M it is not) you must be careful not to connect output pin directly (without any resistors) to Vcc (5V) or GND (0V). Doing so will fry your microcontroller! (Again: in 20M pin 6 in always input so no worries)


You Are My God

Thank you sooo much Nuumio, this has completely solved all the problem I was having, you have saved me much time and money in the agony of swearing at my picaxe chips and buying new ones, if there are other ways of connecting a switch, do you think you could post diagrams for other noobs reference? I can’t be the only one to ever have done this.

This is the way to connect a button

This is the way to connect a button. (Well, the other way is to have pull-down.) So at this point I have to say: “Read the fine manual”. You can find schematics for button connections in Picaxe manuals if you read them (at least manuals 1 and 3 have examples for switches). And you should read them.


Nice catch

This only goes to show, your question is as good as your schematic is! I missed the swithc problem because the text assumed it was connected and I never bothered to “fill in” the switch into my mental picture of the circuit.

I agree

Good and complete schematic is a must have if you are asking for a solution to circuit problems (and want a good answer too).

This is getting a bit off topic but should we have a “Start here electronics” or “Basic circuits/connections” page when this kind of problems (connecting a switch) would have an answer already? Maybe a sticky thread on Electronics forum. Or should we just rely on people reading those fine manuals :slight_smile: