BinaryOnSeg

Dependencies:   mbed

Committer:
Eduvance
Date:
Tue May 27 07:27:47 2014 +0000
Revision:
1:725074331ef6
Parent:
0:ad2c8f6517f2
A

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Eduvance 0:ad2c8f6517f2 1 #include "mbed.h"
Eduvance 0:ad2c8f6517f2 2
Eduvance 1:725074331ef6 3 DigitalIn sw0(p14);
Eduvance 1:725074331ef6 4 DigitalIn sw1(p15);
Eduvance 1:725074331ef6 5 DigitalIn sw2(p16);
Eduvance 1:725074331ef6 6 DigitalIn sw3(p17);
Eduvance 1:725074331ef6 7
Eduvance 1:725074331ef6 8 BusOut Disp(p26,p25,p24,p23,p22,p21,p20); // ABCDEFGdp
Eduvance 1:725074331ef6 9 DigitalOut vdd1(p19);
Eduvance 1:725074331ef6 10 DigitalOut vdd2(p18);
Eduvance 1:725074331ef6 11
Eduvance 0:ad2c8f6517f2 12
Eduvance 1:725074331ef6 13 void setvdd1()
Eduvance 1:725074331ef6 14 {vdd1 = 1;
Eduvance 1:725074331ef6 15 vdd2 =0;}
Eduvance 1:725074331ef6 16
Eduvance 1:725074331ef6 17 void setvdd2()
Eduvance 1:725074331ef6 18 {vdd1 = 0;
Eduvance 1:725074331ef6 19 vdd2 = 1;}
Eduvance 1:725074331ef6 20
Eduvance 1:725074331ef6 21 void setvdd()
Eduvance 1:725074331ef6 22 {vdd1=1;
Eduvance 1:725074331ef6 23 vdd2=1;}
Eduvance 1:725074331ef6 24 int i=0;
Eduvance 0:ad2c8f6517f2 25 int main() {
Eduvance 1:725074331ef6 26 while(1)
Eduvance 1:725074331ef6 27 {
Eduvance 1:725074331ef6 28 if (sw0 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 0)
Eduvance 1:725074331ef6 29 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 30 {setvdd();
Eduvance 1:725074331ef6 31 Disp = 0xC0;
Eduvance 1:725074331ef6 32 wait(0.01);}
Eduvance 1:725074331ef6 33 }
Eduvance 1:725074331ef6 34
Eduvance 1:725074331ef6 35 if (sw0 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 1)
Eduvance 1:725074331ef6 36 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 37 {setvdd2();
Eduvance 1:725074331ef6 38 Disp = 0xC0;
Eduvance 1:725074331ef6 39 wait(0.01);
Eduvance 1:725074331ef6 40 setvdd1();
Eduvance 1:725074331ef6 41 Disp = 0xF9;
Eduvance 1:725074331ef6 42 wait(0.01);}
Eduvance 1:725074331ef6 43 }
Eduvance 1:725074331ef6 44
Eduvance 1:725074331ef6 45 if (sw0 == 0 && sw1 == 0 && sw2 == 1 && sw3 == 0)
Eduvance 1:725074331ef6 46 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 47 {setvdd2();
Eduvance 1:725074331ef6 48 Disp = 0xC0;
Eduvance 1:725074331ef6 49 wait(0.01);
Eduvance 1:725074331ef6 50 setvdd1();
Eduvance 1:725074331ef6 51 Disp = 0xA4;
Eduvance 1:725074331ef6 52 wait(0.01);}
Eduvance 1:725074331ef6 53 }
Eduvance 1:725074331ef6 54
Eduvance 1:725074331ef6 55 if (sw0 == 0 && sw1 == 0 && sw2 == 1 && sw3 == 1)
Eduvance 1:725074331ef6 56 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 57 {setvdd2();
Eduvance 1:725074331ef6 58 Disp = 0xC0;
Eduvance 1:725074331ef6 59 wait(0.01);
Eduvance 1:725074331ef6 60 setvdd1();
Eduvance 1:725074331ef6 61 Disp = 0xB0;
Eduvance 1:725074331ef6 62 wait(0.01);}
Eduvance 1:725074331ef6 63 }
Eduvance 1:725074331ef6 64
Eduvance 1:725074331ef6 65 if (sw0 == 0 && sw1 == 1 && sw2 == 0 && sw3 == 0)
Eduvance 1:725074331ef6 66 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 67 {setvdd2();
Eduvance 1:725074331ef6 68 Disp = 0xC0;
Eduvance 1:725074331ef6 69 wait(0.01);
Eduvance 1:725074331ef6 70 setvdd1();
Eduvance 1:725074331ef6 71 Disp = 0x99;
Eduvance 1:725074331ef6 72 wait(0.01);}
Eduvance 1:725074331ef6 73 }
Eduvance 1:725074331ef6 74
Eduvance 1:725074331ef6 75 if (sw0 == 0 && sw1 == 1 && sw2 == 0 && sw3 == 1)
Eduvance 1:725074331ef6 76 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 77 {setvdd2();
Eduvance 1:725074331ef6 78 Disp = 0xC0;
Eduvance 1:725074331ef6 79 wait(0.01);
Eduvance 1:725074331ef6 80 setvdd1();
Eduvance 1:725074331ef6 81 Disp = 0x92;
Eduvance 1:725074331ef6 82 wait(0.01);}
Eduvance 1:725074331ef6 83 }
Eduvance 1:725074331ef6 84
Eduvance 1:725074331ef6 85 if (sw0 == 0 && sw1 == 1 && sw2 == 1 && sw3 == 0)
Eduvance 1:725074331ef6 86 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 87 {setvdd2();
Eduvance 1:725074331ef6 88 Disp = 0xC0;
Eduvance 1:725074331ef6 89 wait(0.01);
Eduvance 1:725074331ef6 90 setvdd1();
Eduvance 1:725074331ef6 91 Disp = 0x82;
Eduvance 1:725074331ef6 92 wait(0.01);}
Eduvance 1:725074331ef6 93 }
Eduvance 1:725074331ef6 94
Eduvance 1:725074331ef6 95 if (sw0 == 0 && sw1 == 1 && sw2 == 1 && sw3 == 1)
Eduvance 1:725074331ef6 96 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 97 {setvdd2();
Eduvance 1:725074331ef6 98 Disp = 0xC0;
Eduvance 1:725074331ef6 99 wait(0.01);
Eduvance 1:725074331ef6 100 setvdd1();
Eduvance 1:725074331ef6 101 Disp = 0xF8;
Eduvance 1:725074331ef6 102 wait(0.01);}
Eduvance 1:725074331ef6 103 }
Eduvance 1:725074331ef6 104
Eduvance 1:725074331ef6 105 if (sw0 == 1 && sw1 == 0 && sw2 == 0 && sw3 == 0)
Eduvance 1:725074331ef6 106 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 107 {setvdd2();
Eduvance 1:725074331ef6 108 Disp = 0xC0;
Eduvance 1:725074331ef6 109 wait(0.01);
Eduvance 1:725074331ef6 110 setvdd1();
Eduvance 1:725074331ef6 111 Disp = 0x80;
Eduvance 1:725074331ef6 112 wait(0.01);}
Eduvance 1:725074331ef6 113 }
Eduvance 1:725074331ef6 114
Eduvance 1:725074331ef6 115 if (sw0 == 1 && sw1 == 0 && sw2 == 0 && sw3 == 1)
Eduvance 1:725074331ef6 116 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 117 {setvdd2();
Eduvance 1:725074331ef6 118 Disp = 0xC0;
Eduvance 1:725074331ef6 119 wait(0.01);
Eduvance 1:725074331ef6 120 setvdd1();
Eduvance 1:725074331ef6 121 Disp = 0x90;
Eduvance 1:725074331ef6 122 wait(0.01);}
Eduvance 1:725074331ef6 123 }
Eduvance 1:725074331ef6 124
Eduvance 1:725074331ef6 125 if (sw0 == 1 && sw1 == 0 && sw2 == 1 && sw3 == 0)
Eduvance 1:725074331ef6 126 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 127 {setvdd2();
Eduvance 1:725074331ef6 128 Disp = 0xF9;
Eduvance 1:725074331ef6 129 wait(0.01);
Eduvance 1:725074331ef6 130 setvdd1();
Eduvance 1:725074331ef6 131 Disp = 0xC0;
Eduvance 1:725074331ef6 132 wait(0.01);}
Eduvance 1:725074331ef6 133 }
Eduvance 1:725074331ef6 134
Eduvance 1:725074331ef6 135
Eduvance 1:725074331ef6 136 if (sw0 == 1 && sw1 == 0 && sw2 == 1 && sw3 == 1)
Eduvance 1:725074331ef6 137 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 138 {setvdd2();
Eduvance 1:725074331ef6 139 Disp = 0xF9;
Eduvance 1:725074331ef6 140 wait(0.01);
Eduvance 1:725074331ef6 141 setvdd1();
Eduvance 1:725074331ef6 142 Disp = 0xF9;
Eduvance 1:725074331ef6 143 wait(0.01);}
Eduvance 1:725074331ef6 144 }
Eduvance 1:725074331ef6 145
Eduvance 1:725074331ef6 146 if (sw0 == 1 && sw1 == 1 && sw2 == 0 && sw3 == 0)
Eduvance 1:725074331ef6 147 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 148 {setvdd2();
Eduvance 1:725074331ef6 149 Disp = 0xF9;
Eduvance 1:725074331ef6 150 wait(0.01);
Eduvance 1:725074331ef6 151 setvdd1();
Eduvance 1:725074331ef6 152 Disp = 0xA4;
Eduvance 1:725074331ef6 153 wait(0.01);}
Eduvance 1:725074331ef6 154 }
Eduvance 1:725074331ef6 155
Eduvance 1:725074331ef6 156 if (sw0 == 1 && sw1 == 1 && sw2 == 0 && sw3 == 1)
Eduvance 1:725074331ef6 157 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 158 {setvdd2();
Eduvance 1:725074331ef6 159 Disp = 0xF9;
Eduvance 1:725074331ef6 160 wait(0.01);
Eduvance 1:725074331ef6 161 setvdd1();
Eduvance 1:725074331ef6 162 Disp = 0xB0;
Eduvance 1:725074331ef6 163 wait(0.01);}
Eduvance 1:725074331ef6 164 }
Eduvance 1:725074331ef6 165
Eduvance 1:725074331ef6 166 if (sw0 == 1 && sw1 == 1 && sw2 == 1 && sw3 == 0)
Eduvance 1:725074331ef6 167 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 168 {setvdd2();
Eduvance 1:725074331ef6 169 Disp = 0xF9;
Eduvance 1:725074331ef6 170 wait(0.01);
Eduvance 1:725074331ef6 171 setvdd1();
Eduvance 1:725074331ef6 172 Disp = 0x99;
Eduvance 1:725074331ef6 173 wait(0.01);}
Eduvance 1:725074331ef6 174 }
Eduvance 1:725074331ef6 175
Eduvance 1:725074331ef6 176 if (sw0 == 1 && sw1 == 1 && sw2 == 1 && sw3 == 1)
Eduvance 1:725074331ef6 177 { for (i=0 ; i<10; i++)
Eduvance 1:725074331ef6 178 {setvdd2();
Eduvance 1:725074331ef6 179 Disp = 0xF9;
Eduvance 1:725074331ef6 180 wait(0.01);
Eduvance 1:725074331ef6 181 setvdd1();
Eduvance 1:725074331ef6 182 Disp = 0x92;
Eduvance 1:725074331ef6 183 wait(0.01);}
Eduvance 1:725074331ef6 184 }
Eduvance 1:725074331ef6 185
Eduvance 0:ad2c8f6517f2 186 }
Eduvance 1:725074331ef6 187
Eduvance 1:725074331ef6 188 }
Eduvance 1:725074331ef6 189