Go Down

Topic: a function-definition is not allowed here before '{' token (Read 37 times) previous topic - next topic

hotarduinosex

Yeah, it should be working but isn't any fixes? or i have forgot to do something which breaks everything


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
int skanPin = 12;
int daudzums = 26;
char notis[] = "eeeeeeegcde fffffeeeddedg ";
int notsgarums[] = {2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 5, 1, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 4, 9};
int temps = 200;

void speletToni(int tonis, int ilgums) {
for (long i=0; i < ilgums * 1000L; i += tonis * 2) {
digitalWrite(skanPin, HIGH);
delayMicroseconds(tonis);
digitalWrite(skanPin, LOW);
delayMicroseconds(tonis);
}
}

void speletNoti(char nots, int ilgums) {
char vardi[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int toni[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

for (int i = 0; i < 8; i++) {
if (vardi == nots) {
speletToni(toni, ilgums);
}
}

}

void setup() {
pinMode(skanPin, OUTPUT);
}

void loop() {
for (int i = 0; i < daudzums; i++) {
if (notis == ' ') {
delay(notsgarums * temps);
} else {
speletNoti(notis, notsgarums * temps);
}

delay(temps / 2);
}
}
}

AWOL

You appear to have a function definition embedded in your first (oops) loop function.

You have two setup functions.

You have no code tags.

Ianuno

Under display microseconds you need another }, you never closed one of the statements

Take it back.. thought it was isn't though

Go Up