school project

Dependencies:   MMA8451Q mbed

Committer:
xlizne01
Date:
Mon Jan 11 22:12:12 2016 +0000
Revision:
0:ae588eb31707
Child:
1:b23831b703fe
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xlizne01 0:ae588eb31707 1 #include "mbed.h"
xlizne01 0:ae588eb31707 2
xlizne01 0:ae588eb31707 3 DigitalOut prvni(PTE5);
xlizne01 0:ae588eb31707 4 DigitalOut druhy(PTE4);
xlizne01 0:ae588eb31707 5 DigitalOut treti(PTE3);
xlizne01 0:ae588eb31707 6 DigitalOut ctvrty(PTE2);
xlizne01 0:ae588eb31707 7 DigitalOut paty(PTB11);
xlizne01 0:ae588eb31707 8 DigitalOut sesty(PTB10);
xlizne01 0:ae588eb31707 9 DigitalOut sedmy(PTB9);
xlizne01 0:ae588eb31707 10 DigitalOut osmy(PTB8);
xlizne01 0:ae588eb31707 11
xlizne01 0:ae588eb31707 12 DigitalOut Rled1(PTC9);
xlizne01 0:ae588eb31707 13 DigitalOut Rled2(PTC8);
xlizne01 0:ae588eb31707 14 DigitalOut Rled3(PTA5);
xlizne01 0:ae588eb31707 15 DigitalOut Rled4(PTA4);
xlizne01 0:ae588eb31707 16 DigitalOut Rled5(PTA12);
xlizne01 0:ae588eb31707 17 DigitalOut Rled6(PTD4);
xlizne01 0:ae588eb31707 18 DigitalOut Rled7(PTA1);
xlizne01 0:ae588eb31707 19 DigitalOut Rled8(PTA2);
xlizne01 0:ae588eb31707 20
xlizne01 0:ae588eb31707 21 DigitalOut Gled1(PTA13);
xlizne01 0:ae588eb31707 22 DigitalOut Gled2(PTD5);
xlizne01 0:ae588eb31707 23 DigitalOut Gled3(PTD0);
xlizne01 0:ae588eb31707 24 DigitalOut Gled4(PTD2);
xlizne01 0:ae588eb31707 25 DigitalOut Gled5(PTD3);
xlizne01 0:ae588eb31707 26 DigitalOut Gled6(PTD1);
xlizne01 0:ae588eb31707 27 DigitalOut Gled7(PTE31);
xlizne01 0:ae588eb31707 28 DigitalOut Gled8(PTB0);
xlizne01 0:ae588eb31707 29
xlizne01 0:ae588eb31707 30 DigitalOut Bled1(PTC1);
xlizne01 0:ae588eb31707 31 DigitalOut Bled2(PTE29);
xlizne01 0:ae588eb31707 32 DigitalOut Bled3(PTC2);
xlizne01 0:ae588eb31707 33 DigitalOut Bled4(PTB3);
xlizne01 0:ae588eb31707 34 DigitalOut Bled5(PTB2);
xlizne01 0:ae588eb31707 35 DigitalOut Bled6(PTE21);
xlizne01 0:ae588eb31707 36 DigitalOut Bled7(PTE20);
xlizne01 0:ae588eb31707 37 DigitalOut Bled8(PTB1);
xlizne01 0:ae588eb31707 38
xlizne01 0:ae588eb31707 39
xlizne01 0:ae588eb31707 40 int i,j,k;
xlizne01 0:ae588eb31707 41 int RED, GREEN, BLUE;
xlizne01 0:ae588eb31707 42 int RledA, RledB, GledA, GledB, BledA, BledB;
xlizne01 0:ae588eb31707 43
xlizne01 0:ae588eb31707 44 int main()
xlizne01 0:ae588eb31707 45 {
xlizne01 0:ae588eb31707 46
xlizne01 0:ae588eb31707 47 while(1)
xlizne01 0:ae588eb31707 48 {
xlizne01 0:ae588eb31707 49
xlizne01 0:ae588eb31707 50 for(k=1;k<5;k++)
xlizne01 0:ae588eb31707 51 {
xlizne01 0:ae588eb31707 52
xlizne01 0:ae588eb31707 53 if(k==1)
xlizne01 0:ae588eb31707 54 {
xlizne01 0:ae588eb31707 55 prvni=1;
xlizne01 0:ae588eb31707 56 druhy=1;
xlizne01 0:ae588eb31707 57 treti=0;
xlizne01 0:ae588eb31707 58 ctvrty=0;
xlizne01 0:ae588eb31707 59 paty=0;
xlizne01 0:ae588eb31707 60 sesty=0;
xlizne01 0:ae588eb31707 61 sedmy=0;
xlizne01 0:ae588eb31707 62 osmy=0;
xlizne01 0:ae588eb31707 63 }
xlizne01 0:ae588eb31707 64
xlizne01 0:ae588eb31707 65 if(k==2)
xlizne01 0:ae588eb31707 66 {
xlizne01 0:ae588eb31707 67 prvni=0;
xlizne01 0:ae588eb31707 68 druhy=0;
xlizne01 0:ae588eb31707 69 treti=1;
xlizne01 0:ae588eb31707 70 ctvrty=1;
xlizne01 0:ae588eb31707 71 paty=0;
xlizne01 0:ae588eb31707 72 sesty=0;
xlizne01 0:ae588eb31707 73 sedmy=0;
xlizne01 0:ae588eb31707 74 osmy=0;
xlizne01 0:ae588eb31707 75 }
xlizne01 0:ae588eb31707 76
xlizne01 0:ae588eb31707 77 if(k==3)
xlizne01 0:ae588eb31707 78 {
xlizne01 0:ae588eb31707 79 prvni=0;
xlizne01 0:ae588eb31707 80 druhy=0;
xlizne01 0:ae588eb31707 81 treti=0;
xlizne01 0:ae588eb31707 82 ctvrty=0;
xlizne01 0:ae588eb31707 83 paty=1;
xlizne01 0:ae588eb31707 84 sesty=1;
xlizne01 0:ae588eb31707 85 sedmy=0;
xlizne01 0:ae588eb31707 86 osmy=0;
xlizne01 0:ae588eb31707 87 }
xlizne01 0:ae588eb31707 88
xlizne01 0:ae588eb31707 89 if(k==4)
xlizne01 0:ae588eb31707 90 {
xlizne01 0:ae588eb31707 91 prvni=0;
xlizne01 0:ae588eb31707 92 druhy=0;
xlizne01 0:ae588eb31707 93 treti=0;
xlizne01 0:ae588eb31707 94 ctvrty=0;
xlizne01 0:ae588eb31707 95 paty=0;
xlizne01 0:ae588eb31707 96 sesty=0;
xlizne01 0:ae588eb31707 97 sedmy=1;
xlizne01 0:ae588eb31707 98 osmy=1;
xlizne01 0:ae588eb31707 99 }
xlizne01 0:ae588eb31707 100
xlizne01 0:ae588eb31707 101 for(j=1;j<5;j++)
xlizne01 0:ae588eb31707 102 {
xlizne01 0:ae588eb31707 103
xlizne01 0:ae588eb31707 104 if(j==1)
xlizne01 0:ae588eb31707 105 {
xlizne01 0:ae588eb31707 106 RED=0;
xlizne01 0:ae588eb31707 107 BLUE=0;
xlizne01 0:ae588eb31707 108 GREEN=2;
xlizne01 0:ae588eb31707 109 }
xlizne01 0:ae588eb31707 110
xlizne01 0:ae588eb31707 111 if(j==2)
xlizne01 0:ae588eb31707 112 {
xlizne01 0:ae588eb31707 113 RED=3;
xlizne01 0:ae588eb31707 114 BLUE=0;
xlizne01 0:ae588eb31707 115 GREEN=2;
xlizne01 0:ae588eb31707 116 }
xlizne01 0:ae588eb31707 117
xlizne01 0:ae588eb31707 118 if(j==3)
xlizne01 0:ae588eb31707 119 {
xlizne01 0:ae588eb31707 120 RED=10;
xlizne01 0:ae588eb31707 121 BLUE=0;
xlizne01 0:ae588eb31707 122 GREEN=1;
xlizne01 0:ae588eb31707 123 }
xlizne01 0:ae588eb31707 124
xlizne01 0:ae588eb31707 125 if(j==4)
xlizne01 0:ae588eb31707 126 {
xlizne01 0:ae588eb31707 127 RED=10;
xlizne01 0:ae588eb31707 128 BLUE=0;
xlizne01 0:ae588eb31707 129 GREEN=0;
xlizne01 0:ae588eb31707 130 }
xlizne01 0:ae588eb31707 131
xlizne01 0:ae588eb31707 132 for(i=11;i>0;i--)
xlizne01 0:ae588eb31707 133 {
xlizne01 0:ae588eb31707 134
xlizne01 0:ae588eb31707 135 if(RED>0)
xlizne01 0:ae588eb31707 136 {
xlizne01 0:ae588eb31707 137 RledA=1;
xlizne01 0:ae588eb31707 138 RledB=1;
xlizne01 0:ae588eb31707 139 }
xlizne01 0:ae588eb31707 140 else
xlizne01 0:ae588eb31707 141 {
xlizne01 0:ae588eb31707 142 RledA=0;
xlizne01 0:ae588eb31707 143 RledB=0;
xlizne01 0:ae588eb31707 144 }
xlizne01 0:ae588eb31707 145
xlizne01 0:ae588eb31707 146 if(GREEN>0)
xlizne01 0:ae588eb31707 147 {
xlizne01 0:ae588eb31707 148 GledA=1;
xlizne01 0:ae588eb31707 149 GledB=1;
xlizne01 0:ae588eb31707 150 }
xlizne01 0:ae588eb31707 151 else
xlizne01 0:ae588eb31707 152 {
xlizne01 0:ae588eb31707 153 GledA=0;
xlizne01 0:ae588eb31707 154 GledB=0;
xlizne01 0:ae588eb31707 155 }
xlizne01 0:ae588eb31707 156
xlizne01 0:ae588eb31707 157 if(BLUE>0)
xlizne01 0:ae588eb31707 158 {
xlizne01 0:ae588eb31707 159 BledA=1;
xlizne01 0:ae588eb31707 160 BledB=1;
xlizne01 0:ae588eb31707 161 }
xlizne01 0:ae588eb31707 162 else
xlizne01 0:ae588eb31707 163 {
xlizne01 0:ae588eb31707 164 BledA=0;
xlizne01 0:ae588eb31707 165 BledB=0;
xlizne01 0:ae588eb31707 166 }
xlizne01 0:ae588eb31707 167
xlizne01 0:ae588eb31707 168 if(j==1)
xlizne01 0:ae588eb31707 169 {
xlizne01 0:ae588eb31707 170 Rled1=RledA;
xlizne01 0:ae588eb31707 171 Rled2=RledB;
xlizne01 0:ae588eb31707 172 Gled1=GledA;
xlizne01 0:ae588eb31707 173 Gled2=GledB;
xlizne01 0:ae588eb31707 174 Bled1=BledA;
xlizne01 0:ae588eb31707 175 Bled2=BledB;
xlizne01 0:ae588eb31707 176 }
xlizne01 0:ae588eb31707 177
xlizne01 0:ae588eb31707 178 if(j==2)
xlizne01 0:ae588eb31707 179 {
xlizne01 0:ae588eb31707 180 Rled3=RledA;
xlizne01 0:ae588eb31707 181 Rled4=RledB;
xlizne01 0:ae588eb31707 182 Gled3=GledA;
xlizne01 0:ae588eb31707 183 Gled4=GledB;
xlizne01 0:ae588eb31707 184 Bled3=BledA;
xlizne01 0:ae588eb31707 185 Bled4=BledB;
xlizne01 0:ae588eb31707 186 }
xlizne01 0:ae588eb31707 187
xlizne01 0:ae588eb31707 188 if(j==3)
xlizne01 0:ae588eb31707 189 {
xlizne01 0:ae588eb31707 190 Rled5=RledA;
xlizne01 0:ae588eb31707 191 Rled6=RledB;
xlizne01 0:ae588eb31707 192 Gled5=GledA;
xlizne01 0:ae588eb31707 193 Gled6=GledB;
xlizne01 0:ae588eb31707 194 Bled5=BledA;
xlizne01 0:ae588eb31707 195 Bled6=BledB;
xlizne01 0:ae588eb31707 196 }
xlizne01 0:ae588eb31707 197
xlizne01 0:ae588eb31707 198 if(j==4)
xlizne01 0:ae588eb31707 199 {
xlizne01 0:ae588eb31707 200 Rled7=RledA;
xlizne01 0:ae588eb31707 201 Rled8=RledB;
xlizne01 0:ae588eb31707 202 Gled7=GledA;
xlizne01 0:ae588eb31707 203 Gled8=GledB;
xlizne01 0:ae588eb31707 204 Bled7=BledA;
xlizne01 0:ae588eb31707 205 Bled8=BledB;
xlizne01 0:ae588eb31707 206 }
xlizne01 0:ae588eb31707 207
xlizne01 0:ae588eb31707 208 wait(0.00005);
xlizne01 0:ae588eb31707 209 RED--;
xlizne01 0:ae588eb31707 210 BLUE--;
xlizne01 0:ae588eb31707 211 GREEN--;
xlizne01 0:ae588eb31707 212
xlizne01 0:ae588eb31707 213 }
xlizne01 0:ae588eb31707 214 }
xlizne01 0:ae588eb31707 215 }
xlizne01 0:ae588eb31707 216 }
xlizne01 0:ae588eb31707 217 }
xlizne01 0:ae588eb31707 218
xlizne01 0:ae588eb31707 219
xlizne01 0:ae588eb31707 220