Shop OBEX P1 Docs P2 Docs Learn Events
New (Old) Programmer — Parallax Forums

New (Old) Programmer

IroneIrone Posts: 116
edited 2009-09-30 09:44 in BASIC Stamp
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.

Comments

  • skylightskylight Posts: 1,915
    edited 2009-09-29 10:43
    I'm not much younger than yourself but can help a little,


    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
  • dev/nulldev/null Posts: 381
    edited 2009-09-29 14:36
    Try this:

    mypin VAR Nib
    
    Main:
        FOR mypin = 15 TO 10
           HIGH mypin : PAUSE 300
           LOW mypin : PAUSE 300
       NEXT
    
       FOR mypin = 11 TO 14
          HIGH mypin : PAUSE 300
          LOW mypin : PAUSE 300
       NEXT
    
    GOTO Main
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-09-29 15:26
    Hi,
    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.
  • IroneIrone Posts: 116
    edited 2009-09-30 09:44
    Thanks everybody!!! So far I have only copied dev/nul program and put it on my microcontroller. It looks more like Kitt if you only use one for the LOW mypin. ( I tried nothing and got a stern reminder I made a mistake ) Believe it or not my garden tractor has this in a Radio Shack box on the front with 10mm LED lights using a 4017 chip and a few diodes. Lately I have been thinking that with age my patience has improved because very few things cause me to get excited. I have recently found out that mostly I do not give a (expletive) anymore. My life, I'll do it my way. Also I will look up the shift operator and the x+1 and the x-1 to see what happens. Thanks again, Irone
Sign In or Register to comment.