HI, I have an LED traffic light model that has been wired completeley backward in my oppinion, is there any way of converting the GND pin to a + and 3 other pins to a -?
the LED is a sealed unit with the red, yellow and green LEDs all having a common positive but 3 seperate - (GND) connections.
I have run the below code, but obviously it needs 3 + and one -, can this be reversed?
// Arduino Trafic Lights - www.101computing.net/arduino-traffic-lights
void setup()
{
pinMode(13, OUTPUT); // Red LED
pinMode(12, OUTPUT); // Amber LED
pinMode(11, OUTPUT); // Green LED
}
void loop()
{
// Green
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(3000); // Wait for 3000 millisecond(s)
// Amber
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
delay(1000); // Wait for 1000 millisecond(s)
// Red
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
delay(3000); // Wait for 3000 millisecond(s)
// Red + Blinking Amber
digitalWrite(13, HIGH);
digitalWrite(11, LOW);
for (int i = 0; i < 3; i++) {
digitalWrite(12, HIGH);
delay(500); // Wait for 500 millisecond(s)
digitalWrite(12, LOW);
delay(500); // Wait for 500 millisecond(s)
}
}
If an LED and resistor are wired between an output pin and ground, it illuminates when you write HIGH to the pin.
If an LED and resistor are wired between Vcc (5 volts) and the pin, it illuminates when you write LOW to the pin.
So depending on how you must wires the three LEDs and three series current limiting resistor, you just adjust the code to write HIGH or LOW as appropriate for that wiring for the LED to go on or off as you desire.
Do you have a part number you can reference for the LED sealed unit?
How did you wire up your circuit if the sealed LED is questionable?
You mentioned that you ran the code, with what circuit layout, and what was observed?
Hi alto777,
sorry I am new to this, so on the code just swap the HIGH for LOW and vice versa, and leave the wiring as it is? I would re wire the units but they are sealed and looks like SMD so no way will I be able to solder those with my kit.
If they are lighting up now exactly backwards to what you are hoping to achieve then
Yes!
just say HIGH instead of LOW and vice versa.
Ppl sometimes write
const int ON = LOW;
const int OFF = HIGH;
at the top of the program, then use ON And OFF everywhere else, makes the code read better and you can change it back and forth in one place, if, say, you ever had the other kind of three LED LED.
red LED - to pin 13
yellow Led to pin 12
Green LED to pin 11
then Black to ground
the problem is the black wire is common + and the RYG wires are all -
You have described an LED as "common anode", so this willwork.
I just want to be sure you include a series current limiting resistor in each of the the paths between Vcc and an output pin.
If you plan to have more than one illuminated at a time, each LED needs its own.
You will find the trick of fixing something "upside down" in software very handy, and it will be useful when you are dealing with push buttons, which often are wired to read LOW when pressed.
marked is the place where you solder wires from LED unit. upper three are negative.
right on the board are control pins with common anode, just like a RGB LED strip.