Yeah, I am sorry about that. Had a nice explanation all typed up, the forum bounced it on me as a first post, the whole thing got lost and I had to re-do it.
Here's the better explanation.
I have 5 bytes repetitive serial data coming in, I want to turn on the LEDs to represent high bits in one of the bytes, changing only when the bits do. So read in a byte, write it to the outputs pins.
(just a simple serial to parallel converter, seemed like it would be pretty straightforward).
I have a Duemilanove, Code -0018, Windows Vista. I know the Arduino & resisters/LEDs are good as I have tried code to turn them all on for a second or two & then off again before the Void loop.
I have an external box that continously puts out 5 bytes of data, updated at 200 Hz rate, so each byte gets updated at a 40 Hz rate, output level is 0-5V.
The box is a fencing scoring machine, the data represents the information being displayed as lights, I want to remote display the same lights.
I have pins 2 & 5 from scoring machines 9-pin serial port connected to Arduino's Rx & Gnd.
The first byte has the bits that show left & right lights when a touch is scored, left & right lights when if a touch is scored off target, left & right lights if electrical ground is touched. The 2-3-4-5 bytes have other info I don't care about (weapon type and time info). I only want to duplicate the 6 lights.
Byte 1 always has MSB =1 , the others have MSB =0. so that's pretty easy to screen for.
I can see that the code sits & waits for valid serial data to come in by watching bit 12 on a scope - it starts toggling when I connect the Rx to the Arduino (I have an inline switch as I noted that I couldn't program when the RX was connected. I realized eventually that my RX might have been getting corrupted by having the USB connected at the same time, so now after downloading I disconnect the USB and plug in external power.)
I can see that it apparently recognizes valid words coming in by bit 11 toggling.
What I can't seem to get is the LEDs to turn on when the different score lights turn on.
I have hooked up the scoring machine to my PC and see the MSB data change as the lights change. Typical data is
80 (no lights on)
04
1A
2A
3A
endlessly repeated.
Bit 0 of MSB = touch left
Bit 1 = touch right
Bit 2 = invalid touch left
Bit 3 = invald tough right
Bit 4 = left grounded
bit 5 = right grounded
bit 6 = buzzer
None are exclusive of the other, and is common for more than one to be on.
So, watching the data scroll by on my PC, the 5 bytes above keep scroilling by, and the 80 can be seen to change to follow the lights:
81 (left touch scored, also E0 with buzzer)
82 (right touch scored, also C2 with buzzer)
83 (both touch scored, also C3 with buzzer)
84 (left off target)
88 (right off target)
8C (both off target)
90 (left ground)
A0 (right ground)
B0 (both ground)
just about any combination is possible and can be on for any duration.
So, I've got the Arduino wired up with 10 resisters/LEDs, pins 2-9 to represent the bits in MSB, and 2 more to toggle so I can see where the program is.
Typing this up, I am realizing the bar-graph display is not the right method, as I want multiple lights turned on, and they could very well not be next to each other.
I had tried before this method to bit-mask for the various bits, but it did not seem like the outputs would stay turned on after being written to. Am not sure the masking was working, and I don't think I revised that after I realized that I needed to disconnect the USB while the program was running.
I want to stay away from adding an external latch. My goal is to port this to a Mini Pro with just a few wires coming off for actual use.
(Serial data, gnd, +5V, the 6 outputs). The external lights will be on another board with +12V, a 7805, and LEDs/transistors for higher current control (not much, 80-100mA for 4 columns of 4-5 LEDs/resistor in a parallel).
Thanks in advance for the help.
Bob