Saturday, March 20, 2010

Pushing a button

Next up is pushing a button to turn on a light. I'm going to modify it to a push on - push off setup when I'm done.

#define LED 13
#define BUTTON 7

int val = 0;

void setup {
   pinMode(LED, OUTPUT)
   pinMode(BUTTON, INPUT)

void loop {
  val = digitalRead(BUTTON);
  if (val == HIGH) {
     digitalWrite(LED, HIGH);
     digitalWrite(LED, LOW);

No comments:

Post a Comment