lab05-app-shield-potentiometer

Dependencies:   C12832

Files at this revision

API Documentation at this revision

Comitter:
namcheol
Date:
Mon May 11 13:40:55 2020 +0000
Parent:
0:f31836d48420
Commit message:
lab05-app-shield-potentiometer

Changed in this revision

C12832.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f31836d48420 -r 4a8a315ea215 C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Mon May 11 13:40:55 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
diff -r f31836d48420 -r 4a8a315ea215 main.cpp
--- a/main.cpp	Sun Mar 29 19:41:28 2020 +0000
+++ b/main.cpp	Mon May 11 13:40:55 2020 +0000
@@ -1,18 +1,22 @@
 #include "mbed.h"
+#include "C12832.h"
 
-// https://os.mbed.com/docs/mbed-os/v5.15/tools/creating-a-new-program.html
-
-Serial pc(USBTX, USBRX, 115200);    // baud rate 115200
-DigitalOut led(LED1);               // led = LED1
+C12832 lcd(D11, D13, D12, D7, D10); //lcd = (MOSI, SCK, RESET, A0, nCS)
+AnalogIn pot1(A0);
+AnalogIn pot2(A1);
+PwmOut led_r(D5);
+PwmOut led_g(D9);
 
 int main()
 {
-    while (true) {
-        led = 0;
-        printf("LED1 is ON\r\n");
-        thread_sleep_for(500);
-        led = 1;
-        printf("LED1 is OFF\r\n");
-        thread_sleep_for(500);
+    lcd.cls();  //clear screen
+    lcd.locate(0, 6);
+    lcd.printf("Rotate Potentiometers!");
+    while(true) {
+        lcd.locate(0,16);
+        lcd.printf("Pot1=%4.2f, Pot2=%4.2f", pot1.read(), pot2.read());
+        led_r = 1.0 - pot1.read();
+        led_g = 1.0 - pot2.read();
+        thread_sleep_for(200);
     }
 }
\ No newline at end of file