Thursday, 13 June 2013

31 - Button + Buzzer + LED count

int button1State = 0;
int count = 0;

int lastIncrementState = 0;
const int button1Pin = 2;
const int buzzerPin = 9;
const int led1 = 3;

void setup()
{
  // Here we'll configure the Arduino pins we're using
  // LEDs are to be outputs, and buttons are inputs:

  pinMode(button1Pin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(led1, OUTPUT);
}

void displayCount()
{
    delay(10000);
    serial.println(count);
}
void loop()
{
    displayCount();
    if (button1State != lastIncrementState)
        {
              if (button1State == LOW)
             {
                  buzzerPin(tone);
                  digitalWrite(led1, HIGH);
                  count += 1;
             }

        lastIncrementState = button2State;

       }
       
}

No comments:

Post a Comment