code to make a push button work, need assit.

my first self written code for the arduino no error warnings but it dont work either.

help from those who know is much appreciated thank you.

my goals are:

1 to get led pin 13 to lite up and shut off when a push button is being pressed or not pressed.

2 after i get that working to write that on/off value to make the lite toggle every time i press the button.

this is my attempt to under stand how to code for sensors to achieve a programmed response. i would like to use ir receivers this is a 1ST step to that goal.

here my code:

int analogPin = 0;
int val = 0;
int ledPin = 13;

void setup()
{ pinMode(ledPin, OUTPUT);
pinMode(analogPin, INPUT);
}
void loop()
{
val = analogRead(analogPin);
switch (val){
case 1:
val == 0;
digitalWrite(ledPin,LOW);
case 2:
val == 1;
digitalWrite(ledPin,HIGH);
}
} :-?

vila22! I found this tutorial very useful. It has some of the code that your looking for! :slight_smile: Goatboy

http://www.ladyada.net/learn/arduino/

Can't believe I forgot to post the link! ::slight_smile:
http://www.ladyada.net/learn/arduino/lesson5.html

It what way does your program not work?