Bonjour, je n'arrive pas à utiliser la fonction return. Pourriez-vous m'expliquer ce que je fais de mal ? Merci.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | int buttonPin = 2; int buttonValue = 0; int previousButtonValue = 0; int ledPin = 8; int ledPin2 = 7; int ledPin3 = 6; int ledPin4 = 5; int ledPin5 = 4; int counter = 0; void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT); pinMode(ledPin5, OUTPUT); } void loop() { buttonValue = digitalRead(buttonPin); if(previousButtonValue != buttonValue) { if(buttonValue == HIGH) { counter++; } } previousButtonValue = buttonValue; if(counter == 0) { digitalWrite(ledPin, LOW); delay(10); } else if(counter == 1) { digitalWrite(ledPin, HIGH); delay(10); } else if(counter == 2) { digitalWrite(ledPin2, HIGH); delay(10); } else if(counter == 3) { digitalWrite(ledPin3, HIGH); delay(10); } else if(counter == 4) { digitalWrite(ledPin4, HIGH); delay(10); } else if(counter == 5) { digitalWrite(ledPin5, HIGH); delay(10); } else { digitalWrite(ledPin, LOW); delay(10); digitalWrite(ledPin2, LOW); delay(10); digitalWrite(ledPin3, LOW); delay(10); digitalWrite(ledPin4, LOW); delay(10); digitalWrite(ledPin5, LOW); delay(10); } return void(); } |
+0
-0