A következő kapcsolás lényege, hogy a LED egy gomb lenyomásakor elkezd villogni, ha a reset pin-t közben rákötjük az egyik GND pinre leáll a folyamat.
int ledPin = 12; // choose the pin for the LED
int ledPin2 = 11;
int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int inPin6 = 6;
int val2 = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
pinMode(ledPin2, OUTPUT);
pinMode(inPin6, INPUT);
}
void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for a second
digitalWrite(ledPin, LOW);
delay(50);
} else {
digitalWrite(ledPin, LOW);
delay(0);
}
}
Utolsó kommentek