Paste: 1
Author: | 1 |
Mode: | factor |
Date: | Fri, 28 Dec 2012 09:19:07 |
Plain Text |
const int buttongPin = 3;
const int buttonyPin = 2;
const int ledgPin = 13;
const int ledyPin = 12;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
pinMode(ledgPin, OUTPUT);
pinMode(ledyPin, OUTPUT);
pinMode(buttongPin, INPUT);
pinMode(buttonyPin, INPUT);
}
void loop()
{
buttonyState = digitalRead(buttonyPin);
if (buttonyState == HIGH) {
// turn LED on:
digitalWrite(ledyPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledyPin, LOW);
buttongState = digitalRead(buttongPin);
if (buttongState == HIGH) {
// turn LED on:
digitalWrite(ledgPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledgPin, LOW);
}
}
New Annotation