Go Down

Topic: What to Buy and help programming  (Read 447 times) previous topic - next topic

boxy1200

Hi All
i need some help and i am not shore what to buy and where to start so first hear is a pic of what i wont to do

it needs to have 12 momentary push button (1 to 12) and 12 relays

so what i need it to do is when lets say button 1 is pressed relay 1 will turn on and stay on when button 2 is pressed relay 1 needs to turn off and relay 2 turn on and stay on and when button 3 is pressed relay 2 needs to turn off and relay 3 turns on and stays on and so on all the way to 12 but regardless witch button is press that any relay that is on must turn off so for example relay 7 is on and someone press's button 1 relay 7 will turn off and relay 1 will turn on    

the image i have supplied is just for example
and im looking for someone to help with or even Wright the code for the Arduino
Please

PaulMurrayCbr

#1
Jan 16, 2016, 06:19 pm Last Edit: Jan 16, 2016, 06:22 pm by PaulMurrayCbr
You could probably do this without an arduino. But, with an arduino:

12 relays.
12 relay driver circuits (a transistor, a flashback diode, maybe a resistor)
2 8-bit serial-in, parallel-out shift registers
12 pushuttons
12 pull-up resistors for the pushbuttons
2 8-bit parallel-in, serial-out shift registers


hookup wire, stripboard, solder, gaffer tape (because everything needs gaffer tape.) Oh, and a box to put it all in.

Do you really need relays? Why not power transistors? It depends on how much current you are pulling, I suppose. If you are working with mains voltage AC, relays are a simple option.


Code is pretty straightforwrd:

Code: [Select]

void loop() {
  read in the switches from the serial out shift register (stuff the bits into newbits)
  have any of the switches gone down since we last executed this loop? (downbits = ~(prevbits & ~newbits))
  {
    ok, grab (say) the lowest bit that went down (((downbits ^ (downbits-1))+1)>>>1)
    and send that to the serial in shift register
  }
  save the new current state (prevbits=newbits)
}
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

PaulMurrayCbr

I just checked out your pic - I see you have 3 relay driver boards. In that case, you don't need the driver circutry (that's what the boards do). you'll drive the pins of the boards off the serial-in shift register.

But to read 12 buttons, you will either want a shift register or else you will want to use some sort of resistor network. Shift registers are neater, less fooling about.



http://paulmurraycbr.github.io/ArduinoTheOOWay.html

Go Up