Hi guys, am doing a very simple program to produce the C major scale, however when creating an interger variable "A4" to store the frequency 2272Hz, i get "conflicting declaration 'int A4'. I can fix the problem by just putting it in lower case.
However, am interested in the reason why that is happening
The code is bellow
int C4 = 3830;
int D4 = 3400;
int E4 = 3038;
int F4 = 2864;
int G4 = 2550;
int A4 = 2272;
int B4 = 2028;
int C5 = 1912;
int duration = 500;
int pinTone = 7;
void setup() {
pinMode (pinTone, OUTPUT);
}
void tone(int period, int length) {
long M = millis() + length;
while(millis() < M) {
digitalWrite(pinTone, HIGH);
delayMicroseconds(period/2);
digitalWrite(pinTone, LOW);
delayMicroseconds(period/2);
}
}
void loop() {
tone(C4, duration);
tone(D4, duration);
tone(E4, duration);
tone(F4, duration);
tone(G4, duration);
tone(A4, duration);
tone(B4, duration);
tone(C5, duration);
}
Thanks a lot!
Carlos