mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
[ES] Blatt 1 und 2 hinzugefügt
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
34
es/blatt1/uebung1-15a/uebung1-15a.ino
Normal file
34
es/blatt1/uebung1-15a/uebung1-15a.ino
Normal file
@ -0,0 +1,34 @@
|
||||
int ledPin = 7;
|
||||
int buttonPlusPin = 5;
|
||||
int buttonMinusPin = 3;
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(buttonPlusPin, INPUT);
|
||||
pinMode(buttonMinusPin, INPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
if (digitalRead(buttonPlusPin) == LOW) {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
if (digitalRead(buttonMinusPin) == LOW) {
|
||||
counter -= 1;
|
||||
}
|
||||
|
||||
if (counter > 255) {
|
||||
counter = 255;
|
||||
}
|
||||
if (counter < 0) {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
analogWrite(ledPin, counter);
|
||||
Serial.print("LED: ");
|
||||
Serial.println(counter);
|
||||
delay(50);
|
||||
}
|
||||
Reference in New Issue
Block a user