Shop OBEX P1 Docs P2 Docs Learn Events
help me in coding — Parallax Forums

help me in coding

KARIM102KARIM102 Posts: 75
edited 2010-02-21 10:47 in Learn with BlocklyProp
Hi everybody!!!! is anyone know how i can make code in BS2 microcontroller!!! i would like to use three Tact·sw all has differenlt LED color output!!!!! when i press sw 1 then sw 2 then sw 3 then the·4 LED will illuminate!!!!!!!!! and if i don't do it in the right order the 4 LED won't·illuminate!!!!

best wishes
thx

·

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-02-14 14:32
    ·Work with this first
    ' INPUT_OUTPUT.BS2
    ' This program demonstrates how the input/output direction of a pin is
    ' determined by the corresponding bit of DIRS. It also shows that the
    ' state of the pin itself (as reflected by the corresponding bit of PINS)
    ' is determined by the outside world when the pin is an input, and by the
    ' corresponding bit of PINS when it's an output. To set up the demo,
    ' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
    ' to +5V puts a high (1) on the pin when it's an input. The BASIC Stamp
    ' can override this state by writing a low (0) to bit 7 of OUTS and
    ' changing the pin to output.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Main:
      INPUT 7                               ' Make P7 an input
      DEBUG "State of P7: ",
            BIN1 IN7, CR
      OUT7 = 0                              ' Write 0 to output latch
      DEBUG "After 0 written to OUT7: ",
            BIN1 IN7, CR
      OUTPUT 7                              ' Make P7 an output
      DEBUG "After P7 changed to output: ",
            BIN1 IN7
      END
    



    Then work with this

    ·
    ' HIGH_LOW.BS2
    ' This simple program sets I/O pin 0 high for 1/2 second and low for
    ' 1/2 second in an endless loop.  Connect an LED to P0 for a simple
    ' blinker.
    ' {$STAMP BS2}
    
    Main:
      HIGH 0
      PAUSE 500
      LOW 0
      PAUSE 500
      GOTO Main
      END
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-14 15:35
    Start with "What's a Microcontroller?" and the "BASIC Stamp Syntax and Reference Manual" here:

    www.parallax.com/tabid/535/Default.aspx
    www.parallax.com/tabid/440/Default.aspx
  • KARIM102KARIM102 Posts: 75
    edited 2010-02-14 16:11
    thx a lot for ur helping but could u be more clear!!!!! i need three input from microcontroller that can controller one output from it!!!!! if it is inorder otherwise it won't work!!!!!!!!!!!!!! i wish u get what i wanna

    thx again
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-14 17:08
    I get what you want. You want someone to give you a program to light your LEDs when the switches are closed in order. You won't get that here. What you will get is advice, suggestions, and references to use to learn how to write such a program for yourself. Start with the texts I suggested. There are chapters in "What's a Microcontroller?" on sensing switch settings, on lighting LEDs, on decision making in a program, all the things you need to learn to be able to write the program you need. Read the tutorial and work through the exercises, then come back and ask for clarification on anything you don't understand or help in getting your own program to work the way you want. The tutorials are quite good and most people can figure out what they need to do once they're gone through the exercises.
  • KARIM102KARIM102 Posts: 75
    edited 2010-02-15 20:05
    I appreciate what u have said!!!! thx a lot i will do hard and get my own program thx again
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-02-21 10:47
    here is program for u have fun i think that what u are asking for. i had not tried this program but i think it will work fine.

    switch pin 4
    switch1 pin 5
    switch2 pin 6
    switch3 pin 7

    Main:

    High 0 this will make ur pin 0·LED high which would be on pin 0
    High 1 this will make ur pin·1·LED high which would be on pin 1
    High 2 this will make ur pin·2·LED high which would be on pin 2
    High 3 this will make ur pin·3·LED high which would be on pin 3

    If switch=1 then
    If switch1=1 then
    If switch2= 1 then
    If switch3= 1 then
    low 0
    low 1
    low 2
    low 3
    pause 1000
    endif
    endif
    endif
    endif
    END
    ·
Sign In or Register to comment.