As my first project I am working on a bike turn signal. While coding i decided to test it out, but alas, I was too lazy to get a 10k resistor for the pushbutton circuit. When I tried it out the "on" led started to flicker and the pin13 led that i was testing was blinking too fast. I tried resetting the board but then when i picked the arduino up to remove the wires in the 5v, grnd, and pin 10 it started to blink on it's own accord. I tried uploading the simple blink sketch to make sure it would work properly but then i got an error. avrdude stk500_getsync()\ . I unplugged the arduino and after plugging it back in it was working just fine. But now when ever i upload my sketch that I'm working on to the arduino it will start the "blinking led" part of the code when my finger simply bridges the connection between the pins on the bottom of the arduino. Did I short it? Here's the code, and if you need anything else I'll reply fast.
/* This is going to be my first arduino sketch, a bike turn
signal type thing. The way it's going to work is when a button
is pressed, be it left or right, the correct signal will
start to blink. Then after the turn you simply press the button
again and the signal will stop. Later I will add a brake light
by making it so when you pull on the bike brake (front or back)
a bar of red leds light up.
*/
//constants
const int rightswitch = 10; //right switch
const int leftswitch = 11; //left switch
const int rightsignal = 13; //right turn signal
const int leftsignal = 12; //left turn signal
//variables
int rightval = 0; //value will be used to store state of input pin
int oldrightval = 0; //previous value of "rightval"
int rightstate = 0; //0=led off 1=led on
int leftpushcnt = 0; //left button status
void setup()
{
pinMode(leftswitch, INPUT);
pinMode(rightswitch, INPUT);
pinMode(rightsignal, OUTPUT);
pinMode(leftsignal, OUTPUT);
}
void loop(){
rightval = digitalRead(rightswitch);
if ((rightval == HIGH) && (oldrightval == LOW)){
rightstate = 1 - rightstate;
delay(10);
}
oldrightval = rightval;
if (rightstate == 1) {
digitalWrite(rightsignal, HIGH);
delay(350);//I've found 350ms is a good speed for the signal
digitalWrite(rightsignal, LOW);
delay(350);
} else {
digitalWrite(rightsignal, LOW);
}
}