Why, oh why do I get this error even if incomingPin is declared before void setup????: serial_tester_thingy_2:17: error: 'incomingPin' was not declared in this scope
(moderator - need to use the # sign above - results in [ code ] paste_your_code [ / code ] (without the spaces) )
int pinCount = 12;
int digiPins[] = {
2,3,4,5,6,7,8,9,10,11,12,13};
int thisPin;
//int incomimgPin; << oops - incoming mis-spelled
void setup() {
Serial.begin(9600);
for (int thisPin = 0; thisPin < pinCount; thisPin++){
pinMode(digiPins[thisPin], OUTPUT);
}
}
void loop() {
if (Serial.available() > 0){
// read the byte, convert from ASCII character '5' for example to 0x05, check ASCIItable.com for the characters
int incomimgPin = Serial.read(); << mis-spelled incoming here too
Serial.println(incomingPin);
// test for range 2-9
thisPin = incomingPin - 48;
Serial.println(thisPin);
if (thisPin >= 0 && thisPin <= 9)
{
digitalWrite (digiPins[thisPin], HIGH); // set the pin high
delay (1000); // hold it high for one second
digitalWrite (digiPins[thisPin], LOW); // and back low.
}
// test for range A-F
thisPin = incomingPin - 65 + 10;
Serial.println(thisPin);
if (thisPin >= 10 && thisPin <= 15)
{
digitalWrite (digiPins[thisPin], HIGH); // set the pin high
delay (1000); // hold it high for one second
digitalWrite (digiPins[thisPin], LOW); // and back low.
}
delay(1);
}