![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test
main.cpp@0:733484e5b3e5, 2020-09-18 (annotated)
- Committer:
- rogerzuber
- Date:
- Fri Sep 18 06:04:14 2020 +0000
- Revision:
- 0:733484e5b3e5
Demo 7 Segment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rogerzuber | 0:733484e5b3e5 | 1 | #include "mbed.h" |
rogerzuber | 0:733484e5b3e5 | 2 | #include "ShiftOut.h" |
rogerzuber | 0:733484e5b3e5 | 3 | |
rogerzuber | 0:733484e5b3e5 | 4 | ShiftOut Seg7(D8, D7, D4, D13, D12); |
rogerzuber | 0:733484e5b3e5 | 5 | |
rogerzuber | 0:733484e5b3e5 | 6 | const char SEGMENT_MAP[] = {0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09}; |
rogerzuber | 0:733484e5b3e5 | 7 | const char SEGMENT_SELECT[] = {0x8F,0x4F,0x2F,0x1F}; |
rogerzuber | 0:733484e5b3e5 | 8 | |
rogerzuber | 0:733484e5b3e5 | 9 | int counter = 0; |
rogerzuber | 0:733484e5b3e5 | 10 | |
rogerzuber | 0:733484e5b3e5 | 11 | int main() { |
rogerzuber | 0:733484e5b3e5 | 12 | while(1) { |
rogerzuber | 0:733484e5b3e5 | 13 | for (int delay = 0 ; delay < 100 ; delay++) { |
rogerzuber | 0:733484e5b3e5 | 14 | Seg7.write2Byte(SEGMENT_MAP[counter/1000] + (SEGMENT_SELECT[0]<<8)); |
rogerzuber | 0:733484e5b3e5 | 15 | Seg7.write2Byte(SEGMENT_MAP[counter%1000/100] + (SEGMENT_SELECT[1]<<8)); |
rogerzuber | 0:733484e5b3e5 | 16 | Seg7.write2Byte(SEGMENT_MAP[counter%100/10] + (SEGMENT_SELECT[2]<<8)); |
rogerzuber | 0:733484e5b3e5 | 17 | Seg7.write2Byte(SEGMENT_MAP[counter%10] + (SEGMENT_SELECT[3]<<8)); |
rogerzuber | 0:733484e5b3e5 | 18 | } |
rogerzuber | 0:733484e5b3e5 | 19 | if (counter < 9999) { |
rogerzuber | 0:733484e5b3e5 | 20 | counter++; |
rogerzuber | 0:733484e5b3e5 | 21 | } else { |
rogerzuber | 0:733484e5b3e5 | 22 | counter = 0; |
rogerzuber | 0:733484e5b3e5 | 23 | } |
rogerzuber | 0:733484e5b3e5 | 24 | } |
rogerzuber | 0:733484e5b3e5 | 25 | } |