• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

sequence selector????

Status
Not open for further replies.

Lighty

New Member
Hi All

I wanting to write a program that will flash 2 LEDs on to seperate output pins, that I can manage. But now what I'm wanting to achieve is, writing several different patterns and using a input pin as a switch to change between the patterns, and if possible, for it to remember which pattern it was on when power disconnected (unit turned off) so when its powered up again it will automatically go back to that pattern.

I'm using SciTE4gcBasic to write the program and then compile it to a .ASM and .HEX files.

what I need to figure out:

- Does each pattern needs to be writen into its own "SUB PatternX"?
- How do I make it run repeatedly on that Sub until input activated high?
- Require an "interupt" on the input pin to count through the patterns???
- How to store which pattern it was running into memory when power removed?

Code:
#chip 16f628, 4
#config INTRC_OSC

#define LED1 PortB.0
#define LED2 PortB.1
#define SW1 PortB.2
dir LED1 out
dir LED2 out
dir SW1 in

Main:



~~~make start up on last used pattern?
~~~interupt from SW1



goto Main


sub Pattern1
                    [COLOR="Red"]Pattern code[/COLOR]
end sub

sub pattern2
                    [COLOR="Red"]Pattern code[/COLOR]
End sub

sub pattern3
                   [COLOR="Red"]Pattern code[/COLOR]
End sub

sub pattern4
                   [COLOR="Red"]Pattern code[/COLOR]
End sub




goto Main
Thanks in advace!
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top