Hey guys
I have been working on controlling the tail lights in my car with arduino. The original tail lights had 4 bulbs (brake running lights, braking, turn signal, and reverse), but I replaced it with two LED rings connected in parallel, essentially one bulb. This has created the need for an arduino and relays to control the LED ring to flash in correspondence to the car's brake, turn, running signals.
The program for tail lights is very simple, all it does is read if there is power at XX pin, and if there is, set another pin to HIGH or LOW to control a 8 relay module I purchased off ebay. The relays dictate when the LED tail lights get power.
Before setting the arduino up in the car, I decided to try it on the bench. I have 3 arduinos, 2 Unos and one pro mini 5v. I have encountered the same issue with all of them
The relay board's VCC and ground are connected to the arduino's VCC and ground, and the a IN pin on the relay board is connected to digital pin 11 on the arduino. Meanwhile, i have a loose wire inserted into digital pin 5 on the arduino, and the other end is stripped so that I can touch it to VCC on the arduino and make pin 5 HIGH.
Here is the example code I am running
/* Basic Digital Read
-
- turns on and off a light emitting diode(LED) connected to digital
- pin 13, when pressing a pushbutton attached to pin 7. It illustrates the
- concept of Active-Low, which consists in connecting buttons using a
- 1K to 10K pull-up resistor.
- Created 1 December 2005
- copyleft 2005 DojoDave http://www.0j0.org
- http://arduino.berlios.de
*/
int ledPin = 11; // choose the pin for the LED
int inPin = 5; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, HIGH); // turn LED OFF
} else {
digitalWrite(ledPin, LOW); // turn LED ON
}
Serial.println(val);
delay(1000);
}
Here is my problem: When i short pin 5 to VCC to make it high, the relay will respond, but when I remove VCC from pin 5, it takes a second or two for the relay to respond again. It is sluggish in the time it takes for the arduino to interpret the signal, and I need it to be quicker. I realize that relays are relatively slow compared to mosfets and transistors, but my relays are going much slower than they are capable of going.
This same problem occurs when I remove the relay board, and instead set the output pin (LED pin in the code) from 10 to 13 (onboard LED). Again, when I short pin 5 to VCC and remove it instantly, the LED takes a couple of seconds to respond. Generally, once Pin 5 is shorted to VCC, the LED (or relay) turns on instantly, but takes a couple of seconds to shut off after the VCC to pin 5 has been removed. Its very frustrating!
Any ideas on whats going on?