Forum: Mikrocontroller und Digitale Elektronik Arduino VU Meter Problem Fehler Programm


von Boss4538 (Gast)


Lesenswert?

Hallo liebe Mikrocontroller Gemeinde,

bin gerade neu hier auf der Seite gelandet durch eine Empfehlung von 
einem Freund. Habe auf YouTube ein Video Tutorial entdeckt wie man sich 
mit einem Arduino ein VU-Meter bauen kann 
(https://www.youtube.com/watch?v=GBX_6ucEZ1E). Vorab ich bin erst 
Einsteiger was Programmieren betrifft und das hier ist mein Erstes 
Projekt mit einem Arduino.
Beim Hochladen des bereits vorgefertigten Programmcodes auf den Arduino 
wird eine Fehlermeldung angezeigt. Kann damit nicht viel anfangen wäre 
nett wenn jemand mir verraten könnte was ich tun muss um es zum laufen 
zu bekommen.



Hier der Programmcode:

int led[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // Assign the pins for 
the leds
int leftChannel = 0;  // left channel input
int left, i;

void setup()
{
for (i = 0; i < 10; i++)  // Tell the arduino that the leds are digital 
outputs
  pinMode(led, OUTPUT);
//  Serial.begin(9600); // Uncomment to enable troubleshooting over 
serial.
}

void loop()
{
left = analogRead(leftChannel);  // read the left channel
// Serial.println(left);  // uncomment to check the raw input.
left = left / 50;    // adjusts the sensitivity
//  Serial.println(left);  // uncomment to check the modified input.
// left = 1500;  // uncomment to test all leds light.
// left = 0;    // uncomment to check the leds are not lit when the 
input is 0.

  if (left == 0)  // if the volume is 0 then turn off all leds
   {
   for(i = 0; i < 10; i++)
     {
     digitalWrite(led, LOW);
     }
  }

  else
  {
   for (i = 0; i < left; i++) // turn on the leds up to the volume level
    {
     digitalWrite(led, HIGH);
    }

    for(i = i; i < 10; i++)  // turn off the leds above the voltage 
level
     {
      digitalWrite(led, LOW);
     }
  }
}




Fehlermeldung:
Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, 
ATmega2560 (Mega 2560)"

D:\Eigene Dateien\User\Desktop\sketch_sep04a\sketch_sep04a.ino: In 
function 'void setup()':

sketch_sep04a:8: error: invalid conversion from 'int*' to 'uint8_t {aka 
unsigned char}' [-fpermissive]

   pinMode(led, OUTPUT);

                      ^

In file included from sketch\sketch_sep04a.ino.cpp:1:0:

C:\Program Files 
(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:125:6: error: 
initializing argument 1 of 'void pinMode(uint8_t, uint8_t)' 
[-fpermissive]

 void pinMode(uint8_t, uint8_t);

      ^

D:\Eigene Dateien\User\Desktop\sketch_sep04a\sketch_sep04a.ino: In 
function 'void loop()':

sketch_sep04a:25: error: invalid conversion from 'int*' to 'uint8_t {aka 
unsigned char}' [-fpermissive]

      digitalWrite(led, LOW);

                           ^

In file included from sketch\sketch_sep04a.ino.cpp:1:0:

C:\Program Files 
(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:126:6: error: 
initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)' 
[-fpermissive]

 void digitalWrite(uint8_t, uint8_t);

      ^

sketch_sep04a:33: error: invalid conversion from 'int*' to 'uint8_t {aka 
unsigned char}' [-fpermissive]

      digitalWrite(led, HIGH);

                            ^

In file included from sketch\sketch_sep04a.ino.cpp:1:0:

C:\Program Files 
(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:126:6: error: 
initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)' 
[-fpermissive]

 void digitalWrite(uint8_t, uint8_t);

      ^

sketch_sep04a:38: error: invalid conversion from 'int*' to 'uint8_t {aka 
unsigned char}' [-fpermissive]

       digitalWrite(led, LOW);

                            ^

In file included from sketch\sketch_sep04a.ino.cpp:1:0:

C:\Program Files 
(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:126:6: error: 
initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)' 
[-fpermissive]

 void digitalWrite(uint8_t, uint8_t);

      ^

exit status 1
invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' 
[-fpermissive]

Ungültige Bibliothek D:\Eigene 
Dateien\User\Documents\Arduino\libraries\keypad_lcd in D:\Eigene 
Dateien\User\Documents\Arduino\libraries\keypad_lcd gefunden
Ungültige Bibliothek D:\Eigene 
Dateien\User\Documents\Arduino\libraries\LCD1602for_023 in D:\Eigene 
Dateien\User\Documents\Arduino\libraries\LCD1602for_023 gefunden
Ungültige Bibliothek D:\Eigene 
Dateien\User\Documents\Arduino\libraries\keypad_lcd in D:\Eigene 
Dateien\User\Documents\Arduino\libraries\keypad_lcd gefunden
Ungültige Bibliothek D:\Eigene 
Dateien\User\Documents\Arduino\libraries\LCD1602for_023 in D:\Eigene 
Dateien\User\Documents\Arduino\libraries\LCD1602for_023 gefunden

  Dieser Report hätte mehr Informationen mit
  "Ausführliche Ausgabe während der Kompilierung"
  aktiviert in Datei > Einstellungen.

von Boss4538 (Gast)


Lesenswert?

1
int led[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // Assign the pins for the leds
2
int leftChannel = 0;  // left channel input
3
int left, i;
4
5
void setup()
6
{
7
for (i = 0; i < 10; i++)  // Tell the arduino that the leds are digital outputs
8
  pinMode(led, OUTPUT);
9
//  Serial.begin(9600); // Uncomment to enable troubleshooting over serial.
10
}
11
12
void loop()
13
{
14
left = analogRead(leftChannel);  // read the left channel
15
// Serial.println(left);  // uncomment to check the raw input.
16
left = left / 50;    // adjusts the sensitivity  
17
//  Serial.println(left);  // uncomment to check the modified input.
18
// left = 1500;  // uncomment to test all leds light.
19
// left = 0;    // uncomment to check the leds are not lit when the input is 0.
20
21
  if (left == 0)  // if the volume is 0 then turn off all leds
22
   {
23
   for(i = 0; i < 10; i++)
24
     {
25
     digitalWrite(led, LOW);
26
     }
27
  }
28
  
29
  else
30
  {
31
   for (i = 0; i < left; i++) // turn on the leds up to the volume level
32
    {
33
     digitalWrite(led, HIGH);
34
    }
35
    
36
    for(i = i; i < 10; i++)  // turn off the leds above the voltage level
37
     {
38
      digitalWrite(led, LOW);
39
     }
40
  }
41
}

von Draco (Gast)


Lesenswert?

1
for (i = 0; i < 10; i++)  
2
  pinMode(led[i], OUTPUT);
3
              ^

Wobei das die schlimmste Portzuweisung ist, die ich je gesehen habe :-D 
Arduino halt, kannst du nix für.

AAAAber:

hier gibt es Formatierungen im Forum, das man Code auch in Code packen 
kann. Bzw. längere Geschichten als .c Datei anhängen. Sonst ist das ein 
Graus das zu lesen.

btw.: Willkommen.

von Draco (Gast)


Lesenswert?

Ich sehe gerade, das du bei jedem "led" die Arrayposition vergessen 
hast. Da muss überall das [n] dahinter.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.