Hisyam Sulaiman
/
lab2part7decreament
decrement
main.cpp
- Committer:
- HisyamSulaiman
- Date:
- 2018-05-24
- Revision:
- 0:78c6e2cff91a
File content as of revision 0:78c6e2cff91a:
#include "mbed.h" DigitalIn button (D4); char i; BusOut seg1(D13,D12,D11,D10,D9,D8,D7); char segConvert(char SegValue); int main (){ i=0; while(1) { if(button==1) { i=i+1 ; seg1=segConvert(i); wait(1); while(button==1) { seg1=segConvert(i); } if (i==10) { i=0; seg1=segConvert(i); } else { i=0; seg1=segConvert(i); } } } } char segConvert(char SegValue) { char SegByte=0x00; switch (SegValue) { case 0 : SegByte = 0x1;break; case 1 : SegByte = 0x4f;break; case 2 : SegByte = 0x12;break; case 3 : SegByte = 0x6;break; case 4 : SegByte = 0x4c;break; case 5 : SegByte = 0x24;break; case 6 : SegByte = 0x20;break; case 7 : SegByte = 0xf;break; case 8 : SegByte = 0x0;break; case 9 : SegByte = 0xc;break; } return SegByte; }