Vježba 7.4
Dependencies: mbed
main.cpp
- Committer:
- imihalj
- Date:
- 2016-11-17
- Revision:
- 1:d9a5781cd7ce
- Parent:
- 0:bb76d7021216
File content as of revision 1:d9a5781cd7ce:
#include "mbed.h" BusOut Seg1(p5,p6,p7,p8,p9,p10,p11,p12); // A,B,C,D,E,F,G,DP BusOut Seg2(p13,p14,p15,p16,p17,p18,p19,p20); char SegConvert(char SegValue); // function prototype int main() // main program { while (1) { // infinite loop for (char j=0; j<10; j++) { // counter loop 1 Seg2=SegConvert(j); // tens column for (char i=0; i<10; i++) { // counter loop 2 Seg1=SegConvert(i); // units column wait(0.2); } } } } char SegConvert(char SegValue) // function 'SegConvert' { char SegByte=0x00; switch (SegValue) { //DPGFEDCBA case 0 : SegByte = 0x3F; break; // 00111111 binary case 1 : SegByte = 0x06; break; // 00000110 binary case 2 : SegByte = 0x5B; break; // 01011011 binary case 3 : SegByte = 0x4F; break; // 01001111 binary case 4 : SegByte = 0x66; break; // 01100110 binary case 5 : SegByte = 0x6D; break; // 01101101 binary case 6 : SegByte = 0x7D; break; // 01111101 binary case 7 : SegByte = 0x07; break; // 00000111 binary case 8 : SegByte = 0x7F; break; // 01111111 binary case 9 : SegByte = 0x6F; break; // 01101111 binary } return SegByte; }