Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD mbed-rtos mbed
Fork of ELEC_350_CourseWork by
Revision 1:e21c07d7c3a3, committed 2017-11-25
- Comitter:
- chills
- Date:
- Sat Nov 25 15:54:21 2017 +0000
- Parent:
- 0:8f564feffdd8
- Commit message:
- 2017_11_25_001
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Nov 25 15:39:56 2017 +0000
+++ b/main.cpp Sat Nov 25 15:54:21 2017 +0000
@@ -3,23 +3,46 @@
#include "rtos.h"
#include "TextLCD.h"
+//Sets up LCD
Led GreenLed(D5);
-TextLCD lcd(A0, A1, A2, A3, A4, A5,TextLCD::LCD16x2); // rs, e, d4-d7 Sets up LCD
-float TimeBase = 0.5;
-Thread LCD;
-float LDR = 1.5;
-void LCD_Thread()
+TextLCD lcd(A0, A1, A2, A3, A4, A5,TextLCD::LCD16x2); // rs, e, d4-d7
+
+AnalogueIn LDR(D11);
+
+//Declare Threads
+Thread take_sample;
+
+//Declare Thread IDs
+OSThreadId tidmain;
+OSThreadId take_sample_id;
+
+//Declare Ticker
+Ticker sample_interval;
+
+void LCD_Write();
+void LDR_Read();
+
+int main()
+{
+ take_sample.start(LDR_Read); //Start LDR Reading Thread
+ sample_interval.attach(&sampling_ISR, 15000); //Set the sampling interval to 15 seconds
+
+}
+
+void sampling_ISR(){
+ osSignalSet(take_sample_id, true); //Set the sampling thread signal to true
+}
+
+void LDR_Read(){
+ osSignalWait(true, osWaitForever); //Wait until the sampling thread signal is set to true
+ osSignalSet(take_sample_id, false); //Set the sampling signal thread to false
+ LCD_Write(LDR);
+}
+
+void LCD_Write(float LDR)
{
lcd.printf("LDR Value is %1.1f \n",LDR);
}
-int main()
-{
-
- LCD.start(LCD_Thread);
- GreenLed.switchOff();
- while(1)
- {
- GreenLed.Toggle();
- wait(TimeBase);
- }
-}
+
+
+
