LED-Test mit blink() vereinfacht

Moderator: paulluis

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable
André
Posts: 2
Joined: Sat Nov 05, 2016 9:31 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

LED-Test mit blink() vereinfacht

Postby André » Sat Dec 03, 2016 11:36 am

const int pinHR = 12;
const int pinHL = 11;
const int pinVR = 10;
const int pinVL = 9;
const int led = 13;

int valueHR = 0;
int valueHL = 0;
int valueVR = 0;
int valueVL = 0;





void setup() {
pinMode(pinHR, INPUT);
pinMode(pinHL, INPUT);
pinMode(pinVR, INPUT);
pinMode(pinVL, INPUT);

pinMode(led, OUTPUT); // Mode festgelegt

digitalWrite(pinHR, HIGH);
digitalWrite(pinHL, HIGH);
digitalWrite(pinVR, HIGH);
digitalWrite(pinVL, HIGH);

digitalWrite(led, LOW); // Startzustand festgelegt

}

void loop() {
valueHR = digitalRead(pinHR);
valueHL = digitalRead(pinHL);
valueVR = digitalRead(pinVR);
valueVL = digitalRead(pinVL); // values festgelegt --> Eingabe lesen


// wenn Taster nicht gedrückt
if (valueHR == HIGH && valueHL == HIGH && valueVR == HIGH && valueVL == HIGH) {
digitalWrite(led, LOW);
}

// wenn HR gedrückt
if (valueHR == LOW) {
blink(2); // blink mit Variable 2 angesprochen
}


if ( valueHL == LOW) {
blink(3); // blink mit Variable 3 angesprochen
}

if ( valueVL == LOW) { // usw
blink(4);
}

if (valueVR == LOW) {
blink(1); // usw
}


delay(100);


}
// blink Parameter input = Anzahl der Signale
void blink(int input) {
for (int i = 0; i < input; i++) {
// i++ entspricht i = i + 1
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
}
}

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1236: count(): Parameter must be an array or an object that implements Countable

Return to “Taster”

Who is online

Users browsing this forum: No registered users and 1 guest