Study up on bit manipulation.
I'm trying. :D
So you have decoupling for both the shift registers? Failure to decouple them could lead to various hard
to fathom bugs. 0.1uF ceramic from Vcc to ground right next the the chips.
As in this image: http://www.gammon.com.au/images/74HC595_schematic.png
Why use that? :D I don't know what are you saying by "decouple", my english is not so good. :(
[quote author=Nick Gammon link=topic=184338.msg1365306#msg1365306 date=1377388179]
I have a sketch here that does that:
However basically it does what the other posters said, you keep a copy of the bit patterns that you want on/off and send that when required.
I will try this now.
Good tutorial here as well:
I tried this first, but i didn't make the code to work.
[quote author=Runaway Pancake link=topic=184338.msg1365278#msg1365278 date=1377385098]
What are you trying to accomplish?
What's the situation?
What's the objective?
I will explain my project:
I receive comands (one char at the time) through the serial port. Then, the arduino lights up the LED according to the command that it received.
I send commands like "a", "g", "d" and so on. I have 18 LED, so i use the first 18 letters of the alphabet. For example, the letter "a" (since is the first letter of the alphabet) will toggle the LED 1. The letter "d" will toggle LED 4. Easy to to that.
But i can't use all my pins to do that. So that's why i want to use the 74HC595.
In my code, i used some booleans to keep track of my LEDs. So when i receive a command (for example "a") i check to see if the boolean for that LED is HIGH or LOW, then i toggle the LED according to its boolean.
So i think that i need to use a function like this:
1. In "void setup" i set all my booleans to LOW, then i send all "0" to the 74HC595.
2. After i receive a command, i modify only the boolean for the LED according to that command.
3. Then need a function to convert all the booleans to 1 and 0
4. Then i send the data to 74HC595
Lets say that my booleans are like this:
HIGH, LOW, LOW, LOW, HIGH, HIGH, LOW, HIGH, (and 8 more)
So i have to convert that in: 1 0 0 0 1 1 0 1
PS: Yes, i have two 74HC595 wired up just like this: http://www.gammon.com.au/images/74HC595_schematic.png