Hello,
I am working on a class project involving Arduino Gemmas and an older set of class computers which are not capable of installing the new Arduino 1.6.5 - we are stuck with v1.0.5 - Gemma. We are utilizing all three ports on the Gemmas: D1 as a digital output for an LED (with 200-ohm resistor in series), D0 as a digital output for a Piezo speaker, and A1/D2 as an analog input with a photoresistor (with pullup resistor circuit).
When I was testing my program on my own laptop (using Arduino 1.6.5) I configured the ports as follows:
int speaker = 0; // speaker on pin D0
int LED = 1; // LED on pin D1
int sensor = A1; // sensor on pin A1 (D2)
int threshold = 700; // defines threshold for light sensor (between 0 and 1023)
// the setup routine runs once when you press reset:
void setup() {
pinMode(speaker, OUTPUT); // makes speaker pin an output
pinMode(LED, OUTPUT); // makes LED pin an output
pinMode(sensor, INPUT); // makes sensor pin an input
}
and everything worked as it should. When we tried loading the program onto students' Gemmas (on the museum computers, using Arduino 1.0.5 - Gemma), we received the following compile error: "'A1' was not declared in this scope". To remedy the problem, we tried changing "A1" to "2" (thinking we could reference port D2, even though we're using it as an analog input), and the program didn't respond to input from the photoresistor. We also tried changing "A1" to "1", but then we found that the program worked as written, but now the LED on port D1 was barely lit when given the "digitalWrite(1, HIGH);" command.
I'm assuming the problem lies with me not knowing how to setup A1/D2 as an analog input, but I can't think of other ideas. Does anyone have any ideas to try? (Keep in mind, we're limited to the older version of Arduino - v1.0.5.)
Thanks,
Matthew