I am trying to make a code to upload to arduino. I've just strarted to experiment with it.
I am getting :
In function 'void loop()':
error: a function-definition is not allowed here before '{' token
I've got the problem at the very last line of code.
Here's the code:
int timer = 100;
int ledPins[] = {
2, 7, 4, 6, 5, 3 };
int pinCount = 6;
const int analogPin = 0;
const int threshold = 400;
const int ledPin = 13;
void setup() {
int thisPin;
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
pinMode(ledPin, OUTPUT);
}
}
void loop() {
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
digitalWrite(ledPin, HIGH);
}
else {
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
// loop from the highest pin to the lowest:
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}
Thanks