Final Revision

Dependencies:   mbed

Committer:
m182376
Date:
Mon Sep 28 23:07:43 2015 +0000
Revision:
0:fc1503207544
Child:
1:4c233736f4b2
Final Revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m182376 0:fc1503207544 1 #include "mbed.h"
m182376 0:fc1503207544 2
m182376 0:fc1503207544 3 DigitalIn LS1(p16);// Switch 1
m182376 0:fc1503207544 4 DigitalIn LS2(p17);// Switch 2
m182376 0:fc1503207544 5
m182376 0:fc1503207544 6
m182376 0:fc1503207544 7
m182376 0:fc1503207544 8
m182376 0:fc1503207544 9
m182376 0:fc1503207544 10 int main()
m182376 0:fc1503207544 11 {
m182376 0:fc1503207544 12
m182376 0:fc1503207544 13 int number1, number2;
m182376 0:fc1503207544 14
m182376 0:fc1503207544 15 while(1) { //Continuous While Loop
m182376 0:fc1503207544 16
m182376 0:fc1503207544 17 if ((LS1 == 0 && LS2 == 0) || (LS1 == 1 && LS2 == 0) || (LS1 == 0 && LS2 == 1)) {
m182376 0:fc1503207544 18
m182376 0:fc1503207544 19 BusOut lights(p26, p27, p28, p29, p30); // Date bus for LEDs
m182376 0:fc1503207544 20
m182376 0:fc1503207544 21 if (LS1 == 0 && LS2 == 0) {// If both switches are off LEDs Flash
m182376 0:fc1503207544 22
m182376 0:fc1503207544 23 lights = 31; //All LEDs On
m182376 0:fc1503207544 24 wait(.2); // Wait .2 seconds
m182376 0:fc1503207544 25 lights = 0; //All LEDs off
m182376 0:fc1503207544 26 wait(.8); // Wait .8 seconds
m182376 0:fc1503207544 27
m182376 0:fc1503207544 28 }
m182376 0:fc1503207544 29
m182376 0:fc1503207544 30 if (LS1 == 1 && LS2 == 0) {// If Switch 1 is on and Switch 2 is off Lgiht up LEDs left to Right then back down
m182376 0:fc1503207544 31
m182376 0:fc1503207544 32 lights = 16; // LED 1 on
m182376 0:fc1503207544 33 wait(.4); // Wait .4 seconds
m182376 0:fc1503207544 34 lights = 24; // LED 1&2 on
m182376 0:fc1503207544 35 wait(.4); // Wait .4 seconds
m182376 0:fc1503207544 36 lights = 28; // LED 1&2&3 on
m182376 0:fc1503207544 37 wait(.4); // Wait .4 seconds
m182376 0:fc1503207544 38 lights = 30; // LED 1&2&3&4 on
m182376 0:fc1503207544 39 wait(.4); //Wait .4 seconds
m182376 0:fc1503207544 40 lights = 31; // LED 1&2&3&4&5 on
m182376 0:fc1503207544 41 wait(.4); //Wait .4 seconds
m182376 0:fc1503207544 42 lights = 30; //LED 1&2&3&4 on
m182376 0:fc1503207544 43 wait(.4); //Wait .4 seconds
m182376 0:fc1503207544 44 lights = 28; // LED 1&2&3 on
m182376 0:fc1503207544 45 wait(.4); //Wait .4 seconds
m182376 0:fc1503207544 46 lights = 24; //LED 1&2 on
m182376 0:fc1503207544 47 wait(.4); //Wait .4 seconds
m182376 0:fc1503207544 48 lights = 16; //LED 1 on
m182376 0:fc1503207544 49
m182376 0:fc1503207544 50 }
m182376 0:fc1503207544 51
m182376 0:fc1503207544 52 if (LS1 == 0 && LS2 == 1) {
m182376 0:fc1503207544 53
m182376 0:fc1503207544 54 lights = 16; // LED 1 on
m182376 0:fc1503207544 55 wait(.125); // Wait .4 seconds
m182376 0:fc1503207544 56 lights = 8; // LED 1&2 on
m182376 0:fc1503207544 57 wait(.125); // Wait .4 seconds
m182376 0:fc1503207544 58 lights = 4; // LED 1&2&3 on
m182376 0:fc1503207544 59 wait(.125); // Wait .4 seconds
m182376 0:fc1503207544 60 lights = 2; // LED 1&2&3&4 on
m182376 0:fc1503207544 61 wait(.125); //Wait .4 seconds
m182376 0:fc1503207544 62 lights = 1; // LED 1&2&3&4&5 on
m182376 0:fc1503207544 63 wait(.125); //Wait .4 seconds
m182376 0:fc1503207544 64 lights = 2; //LED 1&2&3&4 on
m182376 0:fc1503207544 65 wait(.125); //Wait .4 seconds
m182376 0:fc1503207544 66 lights = 4; // LED 1&2&3 on
m182376 0:fc1503207544 67 wait(.125); //Wait .4 seconds
m182376 0:fc1503207544 68 lights = 8; //LED 1&2 on
m182376 0:fc1503207544 69 wait(.125); //Wait .4 seconds
m182376 0:fc1503207544 70 lights = 16; //LED 1 on
m182376 0:fc1503207544 71
m182376 0:fc1503207544 72 }
m182376 0:fc1503207544 73 }
m182376 0:fc1503207544 74
m182376 0:fc1503207544 75 number1 = rand()%5;
m182376 0:fc1503207544 76 number2 = rand()%5;
m182376 0:fc1503207544 77
m182376 0:fc1503207544 78 if (LS1 == 1 && LS2 == 1) {
m182376 0:fc1503207544 79
m182376 0:fc1503207544 80 DigitalOut D_lights[5]={p26, p27, p28, p29, p30};
m182376 0:fc1503207544 81
m182376 0:fc1503207544 82 if((number1 != number2) ) {
m182376 0:fc1503207544 83
m182376 0:fc1503207544 84 D_lights[number1]=1;
m182376 0:fc1503207544 85 D_lights[number2]=1;
m182376 0:fc1503207544 86 wait(1);
m182376 0:fc1503207544 87 }
m182376 0:fc1503207544 88
m182376 0:fc1503207544 89 }
m182376 0:fc1503207544 90
m182376 0:fc1503207544 91 }
m182376 0:fc1503207544 92 }