how can i use input_pullup

I want to setup 2 switches and 3 leds. When switch 1 is pressed an led(red) comes on and when switch 2 is pressed another led(green) comes on. Then when switch 1 and switch 2 are both pressed all the leds come on(white).

Show us what you have done.

Show us a good schematic of your circuit.
Show us a good image of your wiring.

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

Here are basics, see if you can work it out:

pinMode (pin2, INPUT_PULLUP); pinMode (pin3, INPUT_PULLUP);

pin2state = digitalRead (pin2); pin3state = digitalRead(pin3);

if (pin2state == LOW && pin3state == LOW){ // do one thing }

if (pin2state == HIGH && pin3state == LOW){ // do one thing }

if (pin2state == LOW && pin3state == HIGH){ // do one thing }

if (pin2state == HIGH && pin3state == HIGH){ // do one thing }

larryd:
Show us what you have done.

Show us a good schematic of your circuit.
Show us a good image of your wiring.

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

larryd:
Show us what you have done.

Show us a good schematic of your circuit.
Show us a good image of your wiring.

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

here is my circuit Imgur: The magic of the Internet

|375x500

Show us your current sketch also.

If you push switch #1 then let go, does the red LED follow the switch?

Do red and green come on if both switches are pushed?

What is this to be used for?

CrossRoads: Here are basics, see if you can work it out:

pinMode (pin2, INPUT_PULLUP); pinMode (pin3, INPUT_PULLUP);

pin2state = digitalRead (pin2); pin3state = digitalRead(pin3);

if (pin2state == LOW && pin3state == LOW){ // do one thing }

if (pin2state == HIGH && pin3state == LOW){ // do one thing }

if (pin2state == LOW && pin3state == HIGH){ // do one thing }

if (pin2state == HIGH && pin3state == HIGH){ // do one thing }

thanks for that but i'm not getting a light I used digitalWrite

thanks for that but i’m not getting a light I used digitalWrite

Always show us your ‘current’ compete sketch.
Use CTRL T to format the sketch. Please use code tags.
Use the </> icon in the posting menu.
[code] Paste sketch here. [/code]

thanks for that but i’m not getting a light I used digitalWrite

You did replace the lines

// do one thing

With a line of code that actually did something like turn your light on?

You need to write a LOW to turn on your light.