User Tools

Site Tools


arduino:basic_interaction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
arduino:basic_interaction [2012/09/14 00:43] mithatarduino:basic_interaction [2012/09/14 00:55] mithat
Line 17: Line 17:
  
 <code c> <code c>
-digitalWrite(pushButtonPin, HIGH);       // turn on pullup resistors+digitalWrite(pushButtonPin, HIGH);  // turn on pullup resistors
 </code> </code>
  
Line 43: Line 43:
  
   // set LED state accordingly   // set LED state accordingly
-  if (buttonState == HIGH)        // if the button is pushed +  if (buttonState == LOW)        // if the button is pushed 
-    digitalWrite(ledPin, HIGH);   // turn the LED on +    digitalWrite(ledPin, HIGH);  // turn the LED on 
-  else                            // otherwise +  else                           // otherwise 
-    digitalWrite(ledPin, LOW);    // turn the LED off+    digitalWrite(ledPin, LOW);   // turn the LED off
          
   //delay(1);        // delay in between reads for stability (?)   //delay(1);        // delay in between reads for stability (?)
Line 72: Line 72:
 void loop() { void loop() {
   int buttonState = digitalRead(pushButtonPin);  // read the input pin   int buttonState = digitalRead(pushButtonPin);  // read the input pin
-  digitalWrite(ledPin, buttonState);          // turn the LED on or off+  digitalWrite(ledPin, !buttonState);          // turn the LED on or off
   //delay(1);        // delay in between reads for stability (?)   //delay(1);        // delay in between reads for stability (?)
 } }
Line 94: Line 94:
  
 void loop() { void loop() {
-  digitalWrite(ledPin, digitalRead(pushButtonPin));  // read the input pin and turn the LED on or off+  digitalWrite(ledPin, !digitalRead(pushButtonPin));  // read the input pin and turn the LED on or off
   //delay(1);        // delay in between reads for stability (?)   //delay(1);        // delay in between reads for stability (?)
 } }
 </file> </file>
arduino/basic_interaction.txt · Last modified: 2012/09/14 01:19 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki