I'm making a lamp using 40W incandescent bulbs due to their size and brightness, but I want it so that there are 9 different bulbs that turn on one by one using a push button (or be able to reverse and turn them off one by one with a second push button). I'm wondering how feasible this is. Is it recommended I use a wall adapter and do it all in DC?
40W incandescent bulbs
What current/voltage?
This is quite doable.
Maybe use these Bulbs Grain of Wheat, drive them with MOS fets or UNL2803
EDIT: 40W incandescent bulbs I guess not these bulbs
It would be much safer to use low-voltage bulbs (like the 12V bulbs used in cars and boats) than to use AC line voltage bulbs.
360 Watts total (40 Watts x 9) would be 30 Amps at 12 Volts. That is quite a hefty power supply. You can turn each bulb on and off with a power MOSFET.
LED lamps can produce the same quantity of light at a much lower wattage.
If you go with AC line current bulbs you will probably want relays to control them. Boards of 1, 2, 4, or 8 relays are quite common.
The other alternative if you are using mains bulbs is to drive them with relays driven by an Arduino.
ChilliTronix:
The other alternative if you are using mains bulbs is to drive them with relays driven by an Arduino.
Seems like the obvious way to go.
johnwasser:
It would be much safer to use low-voltage bulbs (like the 12V bulbs used in cars and boats) than to use AC line voltage bulbs.360 Watts total (40 Watts x 9) would be 30 Amps at 12 Volts. That is quite a hefty power supply. You can turn each bulb on and off with a power MOSFET.
LED lamps can produce the same quantity of light at a much lower wattage.
If you go with AC line current bulbs you will probably want relays to control them. Boards of 1, 2, 4, or 8 relays are quite common.
I'm exploring my 12V options, but let's say I go with some AC 7W LED bulbs. I would probably need a relay for each bulb (so 8 relay board + 1 relay board in my case). How would I go about hooking this all up as such to be able to function like I described?
I glanced at the board and I assume the AC hot wire would connected to "COM", then the other AC wire would be connected to the bulbs (in series?). Then have "NO" also connected to the bulbs. And then hook up the Arduino to the board (5V to vcc, gnd to gnd, Digital Pin to IN). Then hook up a push button and somehow work to code to say if button1 is HIGH then digitalwrite relay1 to low, if HIGH again (I will have some questions about this) then digitalwrite relay2 to low....
Am I missing something or is it really this easy?
It's almost that easy... What relay boards are you using?
I would expect you to have each relay able to switch on its own. You could common one side of all relays switched circuit and attach a lamp to each relay then to the return of the mains.
Typically relay boards would have an opto isolator, so you would ground one end of that and then drive the other with the Arduino.
I hope that makes sense.
jsmiller12009:
Am I missing something or is it really this easy?
Well you could multiply the input pin by pi and then divide it by the ratio of a circles circumference to it's diameter, then adjust for inaccuracies created by the problems of the floating point implementation if you really feel the need for a challenge
glanced at the board and I assume the AC hot wire would connected to "COM", then the other AC wire would be connected to the bulbs (in series?). Then have "NO" also connected to the bulbs.
Right... The relay goes in series with the bulb. 'NO' means normally open (no connection) when the relay is not energized. When you energize the relay's coil, the contacts close and you get a connection between 'COM' and 'NO', current flows and the light goes on.
If you connect between COM and NC, the light will be on when the relay is not energized, then go off when you apply voltage to the relay coil.
And then hook up the Arduino to the board (5V to vcc, gnd to gnd, Digital Pin to IN). Then hook up a push button and somehow work to code to say if button1 is HIGH then digitalwrite relay1 to low, if HIGH again (I will have some questions about this) then digitalwrite relay2 to low....
We need to know what relay or what relay board you are using. The relay coil goes to the Arduino, and it's electrically isolated from the contacts (where you have the AC voltage).
I'm making a lamp using 40W incandescent bulbs due to their size and brightness, but I want it so that there are 9 different bulbs that turn on one by one using a push button (or be able to reverse and turn them off one by one with a second push button).
I recommend you figure-out your logic using LEDs before you hook-up the relays and AC power.
And if I understand you correctly and you want to make the lights sequence, you might want to start by making the LEDs sequence automatically under software control (with just some delays) before making it respond to switch inputs.
And then before you hook-up all of the lamps & relays. just hook-up one relay to pin 13 with one lamp, and run the Blink LED example program to blink the AC lamp with the relay to test-out basic AC wiring.
I guess it'd be good to know the board. Something like this seems perfect.
And getting the logic down before using the bulbs and AC is a really good idea, thanks.
EDIT: I decided a 16-relay module is just as much as an 8 and 1, and probably a tad easier to implement.
You may need driver transistors and an external power supply to drive all those relays at once.
So this is the code I have for LED's that I'll want the light bulbs to do. I'm under the impression I can replace all of the led pins with whatever digital pins the relays are set at in the final code. Tell me if this assumption is wrong and/or if there is a more efficient coding methods than I have.
const int buttonPin = 7;
const int ledPin1 = 13;
const int ledPin2 = 11;
const int ledPin3 = 9;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
}
}
lastButtonState = buttonState;
if (buttonPushCounter == 0) {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
}
if (buttonPushCounter == 1) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
}
if (buttonPushCounter == 2) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, LOW);
}
if (buttonPushCounter == 3) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
}
if (buttonPushCounter == 4) {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
}
}
If that code works as you want, you just drive the relays with the LED pins... assuming they are normally open or invert the logic if not.
So I can't get it to light. I hooked it up perfectly like this guy's example:
And used the same code. The led on the relay board shows the signal but I can't get the lightbulb to do the same. I continuity tested the socket, and checked the resistance of the relays and they all check out. What could it be?
Show us a picture of your wiring
This is the whole system. I snapped a pic showing the relay 2 led on.
This is the Arduino hooked up to the board. Black is 5v, white is gnd, and brown is digital pin 7 to relay 2.
This is the lightbulb and power into the relay. I have the hot wire (smooth w/ writing) going into COM. Then a terminal of the lightbulb in the NO port. The other terminal of the light bulb is hooked to the neutral wire (grooved) of the power.
It looks like you just need to plug the power cord into the wall.
Those are 12 volt coils on the relays.
You are going to have 12dc supplied to the board also.
Hi, I'm not familiar with the relay board, but I would say you need a supply to power the relay coils,.
It looks like they are 12V Coils, so you will need a 12V dc supply connected as well.
There is a two pole terminal that doesn't have anything connected to it, check the instructions that come with it to find out if that is where it should be connected.
At the moment your are turning the opto on but because there is no 12V supply, the coil is not being activated.
Tom.......
I would not connect the 5 volt line on the Arduino to this board!
If it is the same as in the attached PDF drawing, you only need to connect the Arduino ground and an external 12DC volt supply.
Please confirm the PDF is for your PCB.
I'll send it in the next post.