Hallo, ich versuche ein Lauflicht mit 10 LED über eine Schleife (LOOP) zu erstellen, aber hier ist einiges fehlerhaft, was ist da fehlerhaft?
LEDPin=(0,1,2,3,4,5,6,7,8,9,10);
void setup() {
for (int i=0: i<=10; i++) {
// put your setup code here, to run once:
pinmode(LEDPins [i], output);
}}
// put your main code here, to run repeatedly:
void loop()
for (int i=0; i<=10; i++) {
digitalWrite (LEDPins[i]HIGH);
delay(250);
digitalwrite(LEDPins[i]LOW);
(delay0);
}
for (int i=0; i<=10; 1--) {
digitalwrite(LEDPins[1]HIGH);
delay(250);
digitalwrite (LEDPins[1]Low);
delay(0);
}}
for (int i=0; i<=10; i++) {
^
C:\Users\HP\Documents\Arduino\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530.ino:16:2: error: expected unqualified-id before 'for'
for (int i=0; i<=10; 1--) {
^~~
C:\Users\HP\Documents\Arduino\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530.ino:16:16: error: 'i' does not name a type
for (int i=0; i<=10; 1--) {
^
C:\Users\HP\Documents\Arduino\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530.ino:16:23: error: expected unqualified-id before numeric constant
for (int i=0; i<=10; 1--) {
^
C:\Users\HP\Documents\Arduino\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530\sketch_feb19a_copy_20260219150310_copy_2026_copy_20260228080530.ino:21:5: error: expected declaration before '}' token
}}
^
exit status 1
Compilation error: 'LEDPin' does not name a type`Verwende dieses Symbol um Code zu posten`
Kommentar:
Falls Du als Hardware einen Arduino UNO R3 benutzt:
Die Pins 0 und 1 sollten, wenn möglich frei bleiben da dort beim Arduino UNO R3 die serielle Schnittstelle liegt.
Hallo, jetzt scheint es zu funktionieren (Danke)Verwende dieses Symbol um Code zu posten:
int LEDPins[10]={1,2,3,4,5,6,7,8,9,10};
void setup() {
for (int i=0; i<10; i++) {
// put your setup code here, to run once:
pinMode(LEDPins[i],OUTPUT);
}
}
// put your main code here, to run repeatedly:
void loop() {
for (int i=0; i<10; i++) {
digitalWrite(LEDPins[i],HIGH);
delay(250);
digitalWrite(LEDPins[i],LOW);
delay(0);
}
for (int i=9; i>0; i--) {
digitalWrite(LEDPins[1],HIGH);
delay(250);
digitalWrite(LEDPins[1],LOW);
delay(0);
}
}
Pin-Nummern brauchen keinen int, ein byte (ist dasselbe wie uint8_t) reicht und sie ändern sich nicht.
Mit Verwendung von Pin 1 hast Du Dir den seriellen Monitor kaputt gemacht.
Schau Dir nochmal den Code von @combie an, da ist fast alles schon drin - bis auf das rückwärts laufende Licht. Du willst wohl einen K.I.T.T. nachbauen