Petar Jandrlic
/
Vjezba2
vjezba za cadu
Revision 0:df316145e042, committed 2013-11-19
- Comitter:
- perodot
- Date:
- Tue Nov 19 18:36:33 2013 +0000
- Commit message:
- cadi
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r df316145e042 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 19 18:36:33 2013 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + +// SegDisplay.cpp file for Exercise 6 +//#include "SegDisplay.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); // A,B,C,D,E,F,G,DP +//void SegInit(void) { +// Seg1=SegConvert(0); // initialise to zero +// Seg2=SegConvert(0); // initialise to zero +//} + +BusOut Seg1(p5,p6,p7,p8,p9,p10,p11,p12); // A,B,C,D,E,F,G,DP +AnalogIn pot(p19); + +char SegConvert(char SegValue) { // function 'SegConvert' + char SegByte=0x00; + switch (SegValue) { //DP G F E D C B A + case 0 : SegByte = 0xC0; break; // 0 0 0 0 0 0 1 1 binary + case 1 : SegByte = 0xF9; break; // 0 0 0 0 0 1 1 0 binary + case 2 : SegByte = 0xA4; break; // 0 1 0 1 1 0 1 1 binary + case 3 : SegByte = 0xB0; break; // 0 1 0 0 1 1 1 1 binary + case 4 : SegByte = 0x99; break; // 0 1 1 0 0 1 1 0 binary + case 5 : SegByte = 0x92; break; // 0 1 1 0 1 1 0 1 binary + case 6 : SegByte = 0x82; break; // 0 1 1 1 1 1 0 1 binary + case 7 : SegByte = 0xF8; break; // 0 0 0 0 0 1 1 1 binary + case 8 : SegByte = 0x80; break; // 0 1 1 1 1 1 1 1 binary + case 9 : SegByte = 0x90; break; // 0 1 1 0 1 1 1 1 binary + + } + + return SegByte; +} +char prikaz; +float ain; + +int main(){ + + while(1){ + //for (char i=0; i<10; i++){ + //prikaz = SegConvert(i); + //Seg1= prikaz; + + ain = pot.read() * 10.0; + char ch = (char)ain; + Seg1 = SegConvert(ch); + + wait(0.1); + + + } + + + + + } + + +
diff -r 000000000000 -r df316145e042 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 19 18:36:33 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file