Hi all, I'm very new to Arduino, I have bought and read through Getting started with Arduino by Massimo and done all the sketches in that. I'm trying to build a digital scoreboard that keeps score for two players. I am using a pair of 2 digit 7 segment LED's that I bought from sure electronics (http://www.sureelectronics.net/goods.php?id=1164). Each LED setup has two 74HC164 shift registers coupled with two darlington arrays to drive the pair of LEDs. The shift registers are in series. I think I'm pretty solid on using the shiftout command to send serial data to the first shift register, then sending another set of data to the first register thus causing the first set of data to be moved to the second shift register causing both LEDs to display the desired numbers.
To keep up with score I plan on using two 3-way momentary toggle switches. So when you flip Player 1 toggle switch up once it adds one to Player 1's score. I'm pretty sure I understand how to do that; use a digitalRead command and when the pin that corresponds to that input is HIGH its P1 = P1 + 1 so it adds one point to Player 1's score. Same for Player 1 toggling the switch down it would subtract 1 point and be P1 = P1 -1. Same for Player 2. To reset both players back to Zero I would just have both switches toggled down for at least half a second at the same time.
The part that I'm having trouble figuring out is taking the values from variables P1 and P2 and then breaking them into two separate digits and then converting those decimal values into the correct binary output to send to the shift register via the shiftout command. For example if Player 1 had a score of 15. I would need to display "1" on the first 7 seg LED and "5" on the second 7 seg LED. And to get "1" to display on the 7 seg LED I need to send out the following data to the shift register B01100000 (LSB). Since the number ONE in binary is B00000001, they obviously aren't equal. Same with "5". How do I get the decimal value 5 converted to B10110110 (LSB)? Is there a library in the Arduino IDE that would make this simpler? Any help would be greatly appreciated! Thanks!