hi
I'm trying to control relays , 74HC595 and use a 7- segments
the problem is that i want to add to buttons one for counting for the 7 segments and other is to active
like num 1 is for relay 4 and num 7 for relay 5 it's too complicated to run this code any one can help or just tel me what i have to do ..... :o :o
Maybe a better description of the problem is needed.
Certainly a better title is required.
And post the code you are having trouble with.
Please use the code button </> so your code looks like this and is easy to copy to a text editor.
...R
I'm trying to control relays , 74HC595 and use a 7- segments
the problem is that i want to add to buttons one for counting for the 7 segments and other is to active
like num 1 is for relay 4 and num 7 for relay 5 it's too complicated to run this code any one can help or just tel me what i have to do ..... :o :o
Well, it helps to defne your problem more clearly.
"One button increments the display when pressed, the other activates a relay selected according to the current value of the display."
That's a start, but you'll need to specify:
- what does 'increment' mean? Does the display have some sort of limit? Should the value loop around?
- what's the relation between the display and which relay is selected? Is it simple - '1' means relay 1, '2' means relay 2, etc?
- what does "activate" mean? Should the relay be on while the button is down? Should it be toggled on and off by the button? Should it stay down for a certain amount of time?
- what should happen if the display increment button is pressed while a relay is activated? Should it immediately deactivate the relay and activate the next one?
At that point, you code becomes:
loop() {
read the buttons.
work out if there was a button press.
decide what to do about it :
maybe activate and deactivate some relays
maybe update the display.
}
I'd suggest d=starting with your display. Write code to make it cycle though digits once a second. Then modify that to increment when there's a button push. Then add the relay on/off code.
thanks man that what i want to know
![]()