This program works on conditional loops based on if the what statements are true.

Dependencies:   mbed TTU_CSC1300

Committer:
willmyers
Date:
Mon Apr 19 02:21:16 2021 +0000
Revision:
0:9fb27c952eb1
Commited

Who changed what in which revision?

UserRevisionLine numberNew contents of line
willmyers 0:9fb27c952eb1 1 /*
willmyers 0:9fb27c952eb1 2 Lab Title: Counting in Binary with Loops
willmyers 0:9fb27c952eb1 3 Author: Will Myers
willmyers 0:9fb27c952eb1 4 Date: 4/18/21
willmyers 0:9fb27c952eb1 5 Purpose: How to use conditional loops with led's.
willmyers 0:9fb27c952eb1 6 */
willmyers 0:9fb27c952eb1 7
willmyers 0:9fb27c952eb1 8 #include "mbed.h"
willmyers 0:9fb27c952eb1 9 #include "TTU_CSC1300.h"
willmyers 0:9fb27c952eb1 10
willmyers 0:9fb27c952eb1 11 //Function Prototypes//
willmyers 0:9fb27c952eb1 12
willmyers 0:9fb27c952eb1 13 BusOut all_leds(LED0_PIN, LED1_PIN, LED2_PIN);
willmyers 0:9fb27c952eb1 14
willmyers 0:9fb27c952eb1 15 int main()
willmyers 0:9fb27c952eb1 16 {
willmyers 0:9fb27c952eb1 17
willmyers 0:9fb27c952eb1 18 //while(TRUE) to keep the program going//
willmyers 0:9fb27c952eb1 19 while(TRUE)
willmyers 0:9fb27c952eb1 20 {
willmyers 0:9fb27c952eb1 21 while(sw5 == true)
willmyers 0:9fb27c952eb1 22 {
willmyers 0:9fb27c952eb1 23 all_leds = 7;
willmyers 0:9fb27c952eb1 24 wait_ms(10);
willmyers 0:9fb27c952eb1 25 all_leds = 0;
willmyers 0:9fb27c952eb1 26 }
willmyers 0:9fb27c952eb1 27
willmyers 0:9fb27c952eb1 28 do
willmyers 0:9fb27c952eb1 29 {
willmyers 0:9fb27c952eb1 30 int i;
willmyers 0:9fb27c952eb1 31 for (i = 0; i <= 7; i++) {
willmyers 0:9fb27c952eb1 32 all_leds = i;
willmyers 0:9fb27c952eb1 33 wait_ms(300);
willmyers 0:9fb27c952eb1 34 }
willmyers 0:9fb27c952eb1 35 }while (sw5 == false);
willmyers 0:9fb27c952eb1 36
willmyers 0:9fb27c952eb1 37 }
willmyers 0:9fb27c952eb1 38 }