at getting buttons to work...
int pins[] = {10, 11}; // led
int num_pins = 4;
int inPin[] = {6, 7}; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
int i;
for (i = 0; i < num_pins; i++)
pinMode(pins[i], OUTPUT); // declare LED as output
pinMode(inPin[i], INPUT); // declare pushbutton as input
}
void loop(){
int i;
val = digitalRead(inPin[i]); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(pins[i], LOW); // turn LED OFF
} else {
digitalWrite(pins[i], HIGH); // turn LED ON
}
}
17.3.09
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment