Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
project:arduino-kickstarter-105 [14.01.2013 15:56] – Externe Bearbeitung 127.0.0.1project:arduino-kickstarter-105 [20.11.2013 21:27] (aktuell) paalsteek
Zeile 17: Zeile 17:
   const int buttonPin = 2;     // the number of the pushbutton pin   const int buttonPin = 2;     // the number of the pushbutton pin
   const int ledPin =  13;      // the number of the LED pin   const int ledPin =  13;      // the number of the LED pin
 +  
   // Variables will change:   // Variables will change:
   int ledState = HIGH;         // the current state of the output pin   int ledState = HIGH;         // the current state of the output pin
   int buttonState;             // the current reading from the input pin   int buttonState;             // the current reading from the input pin
   int lastButtonState = LOW;   // the previous reading from the input pin   int lastButtonState = LOW;   // the previous reading from the input pin
 +  
   // the following variables are long's because the time, measured in miliseconds,   // the following variables are long's because the time, measured in miliseconds,
   // will quickly become a bigger number than can be stored in an int.   // will quickly become a bigger number than can be stored in an int.
   long lastDebounceTime = 0;  // the last time the output pin was toggled   long lastDebounceTime = 0;  // the last time the output pin was toggled
   long debounceDelay = 50;    // the debounce time; increase if the output flickers   long debounceDelay = 50;    // the debounce time; increase if the output flickers
 +  
   void setup() {   void setup() {
     pinMode(buttonPin, INPUT);     pinMode(buttonPin, INPUT);
     pinMode(ledPin, OUTPUT);     pinMode(ledPin, OUTPUT);
   }   }
 +  
   void loop() {   void loop() {
     // read the state of the switch into a local variable:     // read the state of the switch into a local variable:
     int reading = digitalRead(buttonPin);     int reading = digitalRead(buttonPin);
 +  
     // check to see if you just pressed the button     // check to see if you just pressed the button
     // (i.e. the input went from LOW to HIGH),  and you've waited     // (i.e. the input went from LOW to HIGH),  and you've waited
     // long enough since the last press to ignore any noise:       // long enough since the last press to ignore any noise:  
 +  
     // If the switch changed, due to noise or pressing:     // If the switch changed, due to noise or pressing:
     if (reading != lastButtonState) {     if (reading != lastButtonState) {
Zeile 55: Zeile 55:
     // set the LED using the state of the button:     // set the LED using the state of the button:
     digitalWrite(ledPin, buttonState);     digitalWrite(ledPin, buttonState);
 +  
     // save the reading.  Next time through the loop,     // save the reading.  Next time through the loop,
     // it'll be the lastButtonState:     // it'll be the lastButtonState:
project/arduino-kickstarter-105.1358178997.txt.gz · Zuletzt geändert: 20.11.2013 21:27 (Externe Bearbeitung)
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Driven by DokuWiki