I just started experimenting with Arduino Lilypad(mega328). I attempted to download a very simple program that ran sucessfully on a regular Arduino (Duemilanove mega328) board. The Arduino client software reported that the download was successful, but the Lilypad doesn’t do what my program instructs it to do (basically toggle digital I/O line pin 3 at a random interval (between 8 and 13 seconds). Instead, Lilypad toggles pin 13, and not at the random rate. Here is my code:
int second = 1000;
int output_pin = 3;
void setup() {
pinMode(output_pin, OUTPUT);
}
void loop() {
int beep_time = 2;
beep(beep_time);
delay(second * random(8, 13));
}
void beep(int beep_time) {
for (int x = 0; x < beep_time; x++) {
// use pulse width for brighter signal
analogWrite(output_pin, 10);
delay(2);
digitalWrite(output_pin, LOW);
delay(2);
}
}
Any thoughts would be appreciated.
GK