been a while since I toyed around with the IDE so upgraded to 1.6.5 from 1.0.*
I have a sketch which I'm 99.9% sure was working fine in the old IDE but now I am getting "not declared in this scope" errors for a number of variables. Has something changed in the way variables are declared in the updated IDE's?
code below for reference and the compiler complains about ledPin and Serial variables "not declared in this scope":
int lightReading = 0;
int numBlink[4] = {0, 1, 1, 2};
int ambientLight;
int darkThreshhold = 575;
int highCount = 0;
int lowCount = 0;
void setup(){
int ledPins[3] = {6, 6, 6};
Serial.begin(9600);
pinMode(ledPins, OUTPUT);
}
void monitorLight(){
highCount = 0;
lowCount = 0;
for(int i=0; i < 10; i++){
lightReading = analogRead(A0);
if (lightReading < darkThreshhold){
highCount++;
}else{
lowCount++;
}
//Serial.println(highCount);
//Serial.println(lowCount);
//Serial.println(lightReading);
delay(500);
}
}
void selectPin(){
//setup random 3 PWM pin selection function
ledPin = random(0,4);
ledPin = ledPins[ledPin];
}
void lightFly(){
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(10);
}
}
void dimFly(){
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(10);
}
}
void loop(){
Serial.println(analogRead(lightReading));
analogWrite(ledPin[0], analogRead(lightReading)/4);
delay(10);
}