Priyank Kalgaonkar
/
TALab3BsliderECE595
ECE595 - Lab 3 Part 2 - Slider Potentiometer Program - TA
Diff: main.cpp
- Revision:
- 2:adc51888ece5
- Parent:
- 1:93e233c997ad
--- a/main.cpp Sat Jan 16 00:47:35 2021 +0000 +++ b/main.cpp Sat Jan 16 00:53:52 2021 +0000 @@ -1,53 +1,14 @@ #include "mbed.h" -#include "DigitDisplay.h" - -DigitalOut myled(LED1); -DigitDisplay display(D2, D3); - -Ticker tick; - -uint8_t hour = 20; -uint8_t minute = 14; -uint8_t second = 0; +AnalogIn pot(A0); +DigitalOut led(A1); -void beat() -{ - static uint8_t colon = 0; - display.setColon(colon); - if (colon) { - second++; - if (second >= 60) { - second = 0; - minute++; - if (minute >= 60) { - minute = 0; - - hour++; - if (hour >= 24) { - hour = 0; - } - display.write(0, hour / 10); - display.write(1, hour % 10); - } - display.write(2, minute / 10); - display.write(3, minute % 10); - } - } - colon = 1 - colon; -} - -int main() { - display.write(0, hour / 10); - display.write(1, hour % 10); - display.write(2, minute / 10); - display.write(3, minute % 10); - display.setColon(true); - tick.attach(&beat, 0.5); +int main (void) { + float value = 0.0f; while(1) { - myled = 1; - wait(0.5); - myled = 0; - wait(0.5); + value = pot; + printf("Slide location %3.2f\n", value); + wait(0.5f); + led = !led; } } \ No newline at end of file