"Hello World" program for using potentiometers with mBed. ECE4180 Lab 4.

Dependencies:   4DGL-uLCD-SE mbed

Files at this revision

API Documentation at this revision

Comitter:
jderiso2
Date:
Tue Mar 10 20:06:49 2015 +0000
Commit message:
First Commit;

Changed in this revision

4DGL-uLCD-SE.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 50013e3eded8 4DGL-uLCD-SE.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Tue Mar 10 20:06:49 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
diff -r 000000000000 -r 50013e3eded8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 10 20:06:49 2015 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+
+
+DigitalOut _led1(LED1);
+DigitalOut _led2(LED2);
+DigitalOut _led3(LED3);
+DigitalOut _led4(LED4);
+AnalogIn pot(p20);
+uLCD_4DGL lcd(p28, p27, p30);
+
+const int startX = SIZE_X / 3;
+const int stopX = startX * 2;
+const int stopY = SIZE_Y;
+int startY = 0;
+void PrintLCDGraph(float value){
+    int prevY = startY;
+    startY = SIZE_Y * (1 - value);
+    // clear part of graph that doesn't overlap between samples
+    lcd.filled_rectangle(startX, prevY, stopX, startY, BLACK);
+    lcd.filled_rectangle(startX, startY, stopX, stopY, RED);
+}
+void PrintLEDGraph(float value){
+    _led1 = (value >= 0.2) ? 1 : 0;
+    _led2 = (value >= 0.4) ? 1 : 0;
+    _led3 = (value >= 0.6) ? 1 : 0;
+    _led4 = (value >= 0.8) ? 1 : 0;
+}
+int main() {
+    float sample;
+    while(1) {
+        sample = pot;
+        PrintLEDGraph(sample);
+        PrintLCDGraph(sample);
+        wait(0.1);
+    }
+}
diff -r 000000000000 -r 50013e3eded8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 10 20:06:49 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file