So I tested a circuit to use 5 buttons to trigger 5 different tones to be outputed by a piezo. worked great!
Soldered it up to make a home-made shield and I made a mistake. One pole of the switch was supposed to be wired to an Arduino pin and have a 10k resistor pulling down to ground. I swapped that wire on ALL the switches so instead I ran 5v to the same side of the switch that had the pull down resistor. Essentially shorting the circuit with only a 10k resistor slowing it down (x5 switches). Of course I had it plugged in several times while I tried to debug it thinking I had a solder short circuit.
After I found the problem I took my homemade shield off and set up a blinking led circuit to test each of the pin that could have been affected. They all worked fine. Any other simple sketch is working fine.
So now I am working on learning about "millis()" to try and make a Morse interpretation program. This is what I have so far. I know its not quality, yet.
int keyPin = 8;
int ledPin = 10;
int startTime = 0;
void setup()
{
Serial.begin(9600);
pinMode(keyPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
if (digitalRead(keyPin) == HIGH )
{
startTime = millis();
delay (10);
if ((millis() - startTime > 500))
{
Serial.println("dash");
digitalWrite(ledPin, HIGH);
}
}
else if (digitalRead(keyPin) == LOW)
{
Serial.println("waiting");
digitalWrite(ledPin, LOW);
delay(500);
}
}
The sketch works, but only after about 1 minute of waiting. I fire it up and it is slow as hell and I wait and then, WHAM! it starts working fine, after what I feel is a too long of a wait.
Is my Sketch flawed and causing the delay or did I mess something up on the board with the short?
Is there a diagnostic program I can run?