Switches

Thread Starter

XxAxisxX

Joined Mar 11, 2010
6
Hi I really have no clue what I am doing. Basically I want to have 3 switches attached to a microprocessor. Each switch when pressed will do something different like SW1 will trigger immediately while SW2 will go after 4 seconds and SW3 will go after like 10 seconds. Then from the processor it will be transmitted to a receiver and then the receiving processor will apply current to the correct pins. I was using MicroCode studio to do this but I am not really sure what I am doing. This is what I had so far. Any help would be greatly appreciated. Thank you!

Rich (BB code):
Check:
IF Pin0 = 0 THEN SW1 ' If button connected to Pin0 is pushed (0), jump to label SW1
    Endif
IF Pin1 = 0 THEN SW2 ' If button connected to Pin1 is pushed (0), jump to label SW2
    Endif
IF Pin2 = 0 THEN SW3 ' If button connected to Pin2 is pushed (0), jump to label SW3
    Endif
Goto Check
SW1:LOW 1        ' Turn off connected to PORTB.0
        Pause 100       ' Delay for .1 seconds

        High 1           ' Turn on LED connected to PORTB.0  
        Pause 500       ' Delay for .5 seconds             
        Goto Check   ' Go back to loop and blink LED forever

SW2: LOW 1        ' Turn off connected to PORTB.0
        Pause 10000       ' Delay for 10 seconds

        High 1           ' Turn on connected to PORTB.0
        Pause 500       ' Delay for .5 seconds

        Goto Check   ' Go back to loop and blink LED forever
        End

SW3: LOW 1        ' Turn off connected to PORTB.0
        Pause 60000       ' Delay for 10 seconds

        High 1           ' Turn on connected to PORTB.0
        Pause 500       ' Delay for .5 seconds

        Goto Check   ' Go back to loop and blink LED forever
        End
If I am doing things completely wrong could you point me in the right direction. Like a good coding tut for microprocessors. Thx!
 

retched

Joined Dec 5, 2009
5,207
Gooligum is a great tutorial resource for beginners. He holds your hand through C or ASM programming, where to get the free compilers and how to wire the circuits. From the simple pic 'hello world' of lighting a single led, to switches, polling and more.

This is invaluable for beginners.

http://www.gooligum.com.au/tutorials.html
 
Top