New (Old) Programmer
Irone
Posts: 116
I am an old Fart. I may be too old or drank too much beer but I am still trying. I got a BS2 and a programming board and read thru most of the abundant information Parrallex offered free. I made a program that mimics the Kit lights. It is very simple but remember I am just a newbie. For the past 62 years I have never been afraid to ask for help and are not afraid to have some young snot show me where I went wrong. If it can be made easier or using less data help an old man out and tell me a better way to do it.
Below is my program:
' {$STAMP BS2}
' {$PBASIC 2.5}
' Kit Lights
DEBUG "Program Running"
DO
· HIGH 15
· PAUSE 300
· LOW 15
· HIGH 14
· PAUSE 300
· LOW 14
· HIGH 13
· PAUSE 300
· LOW 13
· HIGH 12
· PAUSE 300
· LOW 12
· HIGH 11
· PAUSE 300
· LOW 11
· HIGH 10
· PAUSE 300
· LOW 10
· HIGH 11
· PAUSE 300
· LOW 11
· HIGH 12
· PAUSE 300
· LOW 12
· HIGH 13
· PAUSE 300
· LOW 13
· HIGH 14
· PAUSE 300
· LOW 14
LOOP
I wired up 6 LEDs on pins 15 thru 10 and ran them thru a 470 ohm resistor to ground.
Below is my program:
' {$STAMP BS2}
' {$PBASIC 2.5}
' Kit Lights
DEBUG "Program Running"
DO
· HIGH 15
· PAUSE 300
· LOW 15
· HIGH 14
· PAUSE 300
· LOW 14
· HIGH 13
· PAUSE 300
· LOW 13
· HIGH 12
· PAUSE 300
· LOW 12
· HIGH 11
· PAUSE 300
· LOW 11
· HIGH 10
· PAUSE 300
· LOW 10
· HIGH 11
· PAUSE 300
· LOW 11
· HIGH 12
· PAUSE 300
· LOW 12
· HIGH 13
· PAUSE 300
· LOW 13
· HIGH 14
· PAUSE 300
· LOW 14
LOOP
I wired up 6 LEDs on pins 15 thru 10 and ran them thru a 470 ohm resistor to ground.
Comments
to simplify you could put a variable say x in place of the pin numbers and use for x=x+1 loop until x=? then perhaps x=x-1 until x=? to go in the other direction
this would then leave only one HIGH x and one LOW x instruction in your loop instead of all the ones you have now.
you will probably have to nest this do loop until inside your main do loop
Post Edited (skylight) : 9/29/2009 10:53:28 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
As one old fart to another – welcome.
Your code reminded me of my first coding attempt in 1973.
I assume you do want to learn so I won’t write it for you.
Just look at what you did and you will see the pattern.
You are “walking” thru the outputs starting from most significant bit (MSB) to the right.
Each step “shifts” the pattern one bit – so use shift operator in you subroutine until you reach the end and then reverse the process using similar subroutine. Also use PAUSE in subroutine and you can vary the pause value easily.
Have a great time coding.