Couple of questions

allgone

New Member
Hi guys back again to pick your brains.

Basically Im want my 18X to activate a seperate alarm (9v) which is switched on via push button connecting the alarm terminals across pin X and 0V. obviosuly im not going to put the terminals straight into the pic, so can it be done by simply putting a resistor in line or will i need some sort of relay?

Second is using a 14m Im trying to make a simple key code using 5 buttons where one code is inputted and then it produces pin 0 hight and then if another is pressed pin 2 will go high. Not sure where I have done wrong but every time Pin 4 is pressed pin 0 just goes high no matter what order the are pressed and pin 2 never goes high!:confused:


main:
label_1: if pin1=1 then label_2
pause 1000
goto label_1

label_2: pause 1000
if pin2=1 then label_3
goto label_1

label_3: pause 1000
if pin3=1 then label_4
goto label_1

label_4: pause 1000
if pin4=1 then label_5
goto label_1

label_5: pause 1000
if pin0=1 then label_6
high 0
pause 1000
low 0
goto label_1

label_6: high 2
pause 1000
low 2
pause 1000
goto label_1


I know this is fairly straight forward stuff for you guys but I'm still learning :)
Thanksssssssssssssssssssss
 

westaust55

Moderator
You can use a transistor as the switching device.

Have a look at PICAXE Manual 3 on page 9 where there are circuits to drive lamps and buzzers.
The +6Vdc to the top side of the circuit could be 9Vdc - but do not conenct this 9V to the PICAXE (use only 4.5 or 5V there).
 
Last edited:

MartinM57

Moderator
Looks a bit tricky for the user to use your key lock - they have to make sure they've got the right button pressed at exactly the time that you run the if... statements.

With all those 1 second pauses, and no feedback to the user, and the code jumping back to label_1 all the time, it might be pretty hard (aka impossible?) to get it right.

Have another think about how a keypad works...(it's actually not that trivial)...
 
Top