Brian Moloney / Mbed 2 deprecated Final_Project_Brian_Moloney

Dependencies:   mbed C12832

Files at this revision

API Documentation at this revision

Comitter:
bmol
Date:
Tue Aug 18 13:12:15 2020 +0000
Commit message:
IT Tralee

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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r edb9a7b809a2 C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Tue Aug 18 13:12:15 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
diff -r 000000000000 -r edb9a7b809a2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Aug 18 13:12:15 2020 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+#include "C12832.h"
+
+C12832 lcd(p5, p7, p6, p8, p11);//Lcd and connections
+
+InterruptIn joystickcenter(p14);//Pushbutton on center of joystick
+Timer debounce; // define debounce timer
+
+AnalogIn pot1(p19); // Pot 1-Program setpoint.Tank level setpoint
+AnalogIn pot2(p20); // Pot 2-Program variable.Simulate output flow from tank. Process variable (PV)
+
+DigitalOut led(LED1);
+DigitalOut led4(LED4);
+
+PwmOut red(p23); //RGB LED with 3 PWM outputs for dimmer control
+PwmOut green(p24);//Green Led- Status OK
+PwmOut blue(p25);//Red Led- Alarm Condition
+PwmOut speaker(p26); //Onboard Speaker- Audible alarm
+
+Serial pc(USBTX,USBRX); // Printf to PC over USB
+
+void flip()
+{
+
+    if (debounce.read_ms()>200) { // only allow toggle if debounce timer has passed 200ms
+        led4 =!led4;// Invert Led4
+        debounce.reset(); // restart timer when
+        wait(0.5);//pause before moving on in program
+    }
+
+}
+
+int main ()
+    {
+    float  pv ;
+    float  setpoint;
+
+    joystickcenter.rise(&flip); // attach the function address to the rising edge
+
+    speaker.period(1.0/1000.0); // 1000hz period
+    red=1.0; //RGB LED off - PWM 100% duty cycle
+    green=1.0;
+    blue=1.0;//Not used in project
+
+
+    while (1) {//continuous loop
+
+        lcd.cls();//clears LCD
+        lcd.locate(0,0); // Lcd coordinates
+        pv = pot2;//read simulated output flow
+        pv = 100.0 * pot2; // Tank level simulated value in %
+        lcd.printf("Tank Level = %.1f\n\r",pv);
+        setpoint = pot1;// Level simulated setpoint
+        setpoint = 100.0 * pot1; // Tank level setpoint in %
+        lcd.printf("Setpoint = %.1f\n\r",setpoint);
+        debounce.start();//Start of the debounce timer
+        
+        //Serial interface
+        pc.printf("Tank Level = %.1f\n\r",pv); //send tank level to PC
+        pc.printf("          Level setpoint = %.1f\n\r",setpoint); //send setpoint to PC with spacing for clarity
+        wait(0.5);//pause before moving on in program
+
+        if(pv <= setpoint) { // Determines action of inputs pot1 and pot2
+            red = 1.0 - pot2; //RGB LED red
+            green = 1.0;
+            led=1.0;
+            speaker = 0.5; //alarm tone using Pwm
+            pc.printf(" Alarm!! Tank Level Low....Top-up valve open\n"); //send setpoint to PC
+            wait(0.5);
+
+        } else {
+            green = 1.0 - pot2; //RGB LED green
+            red = 1.0;
+            led=0.0;
+            speaker = 0.0;
+            wait(0.5);
+        }
+        if (led4) {
+            pc.printf("................. Outlet valve open\n\r");
+            wait(0.5);
+        } else {
+            pc.printf("**\n\r");// No alarm
+            wait(0.5);
+     }
+
+  }
+
+}
diff -r 000000000000 -r edb9a7b809a2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 18 13:12:15 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file