Let's Make Robots!

coding for 4x3 keypad coding

i have connect keypad to my picaxe 28 pin project board and i would like to test whether which pin should connect to input or output

but after i program it into my PIC it cant function.

this is my simple coding



readadc 5,b1

if b1 = 1then high 6;


low 6


end if


is my coding hv any problem???

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Do away with the DO and LOOP. Instead of END use GOTO MAIN.

READADC is an analog function and will return a value 0-255 based on the voltage it sees. You really just need a "is it high, yes, high 6, etc..." If you want to use the READADC you'll have to make it "if b1 > 0 then high 6" and it would help to have a pulldown resistor to keep it at zero when not activated.

Mmm, I didn't see birdmun's reply. Repetition unintended.

The do loop is correct. The loop might(?) need to be moved one line down. But, main/goto main is considered spaghetti programming. :P

Yes, the LOOP is out of sequence. I believe it needs more parameters as well. LOOP... DO UNTIL/WHILE I think is the syntax. That's why I suggested a GOTO command. I could be wrong, as always.

Spaghetti programming? I like spaghetti. Have you seen my breadboards??? :)

readadc 5,b1

will treat pin 5 as an analog input. So, in your if/then statement asking if b1 = 1 will almost never be true, because analog goes from 0 to 255.

You need instead to get rid of the readadc line and just use an if/then statement on the pin. Like:

if 5 = 1 then high 6;

That should work. Don't quote me on the exact syntax.