
Final Revision
main.cpp
- Committer:
- m182376
- Date:
- 2015-09-29
- Revision:
- 1:4c233736f4b2
- Parent:
- 0:fc1503207544
File content as of revision 1:4c233736f4b2:
// Lab 1 Program B // Program Allow the user to do different functions with the LED lights using the Logic Switches 1 and 2. // Written by: MIDN 3/C Hague 9/28/15 #include "mbed.h" DigitalIn LS1(p16);// Switch 1 DigitalIn LS2(p17);// Switch 2 int main() { int number1, number2;// used for rand functions later while(1) { //Continuous While Loop if ((LS1 == 0 && LS2 == 0) || (LS1 == 1 && LS2 == 0) || (LS1 == 0 && LS2 == 1)) {// Huge if statement so that I can use BusOut and DigitalOut in the next if BusOut lights(p26, p27, p28, p29, p30); // Date bus for LEDs if (LS1 == 0 && LS2 == 0) {// If both switches are off LEDs Flash lights = 31; //All LEDs On wait(.2); // Wait .2 seconds lights = 0; //All LEDs off wait(.8); // Wait .8 seconds } if (LS1 == 1 && LS2 == 0) {// If Switch 1 is on and Switch 2 is off Lgiht up LEDs left to Right then back down lights = 16; // LED 1 on wait(.4); // Wait .4 seconds lights = 24; // LED 1&2 on wait(.4); // Wait .4 seconds lights = 28; // LED 1&2&3 on wait(.4); // Wait .4 seconds lights = 30; // LED 1&2&3&4 on wait(.4); //Wait .4 seconds lights = 31; // LED 1&2&3&4&5 on wait(.4); //Wait .4 seconds lights = 30; //LED 1&2&3&4 on wait(.4); //Wait .4 seconds lights = 28; // LED 1&2&3 on wait(.4); //Wait .4 seconds lights = 24; //LED 1&2 on wait(.4); //Wait .4 seconds lights = 16; //LED 1 on } if (LS1 == 0 && LS2 == 1) { lights = 16; // LED 1 on wait(.125); // Wait .4 seconds lights = 8; // LED 1&2 on wait(.125); // Wait .4 seconds lights = 4; // LED 1&2&3 on wait(.125); // Wait .4 seconds lights = 2; // LED 1&2&3&4 on wait(.125); //Wait .4 seconds lights = 1; // LED 1&2&3&4&5 on wait(.125); //Wait .4 seconds lights = 2; //LED 1&2&3&4 on wait(.125); //Wait .4 seconds lights = 4; // LED 1&2&3 on wait(.125); //Wait .4 seconds lights = 8; //LED 1&2 on wait(.125); //Wait .4 seconds lights = 16; //LED 1 on } } number1 = rand()%5;// Used for two random LEDs number2 = rand()%5;// Used for two random LEDs if (LS1 == 1 && LS2 == 1) {// second if statement different use of communicating to LEDs DigitalOut D_lights[5]={p26, p27, p28, p29, p30}; //DigitalOut to use pins with array if((number1 != number2) ) { // If both of the numbers do not equal eachother therefore there is always two leds lit D_lights[number1]=1; D_lights[number2]=1; wait(1); } } } }