Advertisement
bitwise_gamgee

Untitled

Jul 7th, 2023
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. // Pins connected to 74HC595
  2. const int latchPin = 8;
  3. const int clockPin = 12;
  4. const int dataPin = 11;
  5.  
  6. // Mapping of digits to segments for a common-anode 7-segment display
  7. const byte digitToSegment[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
  8.  
  9. void setup() {
  10.   pinMode(latchPin, OUTPUT);
  11.   pinMode(clockPin, OUTPUT);
  12.   pinMode(dataPin, OUTPUT);
  13. }
  14.  
  15. void loop() {
  16.   for (int i = 0; i < 10; i++) {
  17.     digitalWrite(latchPin, LOW);
  18.     shiftOut(dataPin, clockPin, MSBFIRST, digitToSegment[i]);
  19.     digitalWrite(latchPin, HIGH);
  20.     delay(1000);
  21.   }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement