const int switchPin = 2;
const int ledPin = 13;
int state;
int lastState;
int ledState;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
Serial.begin(9600);
}
void loop()
{
state = digitalRead(switchPin);
if (state != lastState)
{
if (state == HIGH)
{
if (ledState == HIGH)
{
ledState = LOW;
Serial.println("LED AUS");
}
else
{
ledState = HIGH;
Serial.println("LED EIN");
}
}
lastState = state;
}
digitalWrite(ledPin, ledState);
delay(20);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.