Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**********************************************************************
- * A test driver for using the Radio Shack 7-segment component 276-0075
- * with an Aruino Uno R3 and a Sparkfun 74HC595 IC.
- **********************************************************************/
- // Setup the SIPO pins
- int dataPin = 13; //Pin connected to DS of 74HC595
- int latchPin = 12; //Pin connected to ST_CP of 74HC595
- int clockPin = 11; //Pin connected to SH_CP of 74HC595
- // Counter
- int counter = 0;
- // The binary numbers to activate the 74HC595 pins. 0-F
- int pins[] = {B10111101, B10100000, B00111110, B10111010,
- B10100011, B10011011, B10011111, B10110000,
- B10111111, B10111011, B10110111, B10001111,
- B00011101, B10101110, B00011111, B00010111};
- // The length of the pins array.
- const int MAX = sizeof(pins)/sizeof(int);
- // Start
- void setup() {
- //set pins to output so you can control the shift register
- pinMode(latchPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
- }
- // Main loop
- void loop() {
- changePattern(pins[counter]);
- counter++;
- if (counter == MAX) counter = 0;
- delay(500);
- }
- // Sets the write to low, changes the number, and sets write to high to
- // light up the display.
- void changePattern(int n) {
- digitalWrite(latchPin, LOW);
- shiftOut(dataPin, clockPin, MSBFIRST, n);
- digitalWrite(latchPin, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement