LDR light sensor controlling green LED on or off

Dependencies:   mbed C12832

Files at this revision

API Documentation at this revision

Comitter:
tollidal
Date:
Sun Oct 17 10:28:03 2021 +0000
Commit message:
Strawberry Forever Light sensor controlled LED

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 f612b9501960 C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Sun Oct 17 10:28:03 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/askksa12543/code/C12832/#990d5eec2ef6
diff -r 000000000000 -r f612b9501960 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 17 10:28:03 2021 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"       //LPC 1768 header file
+#include "C12832.h"     //LCD header file
+
+
+//read ambiant light levels 
+
+C12832 lcd(p5, p7, p6, p8, p11);        //lcdscreen
+DigitalOut myled(p14);                  //assigning greenled as digital output pin14
+AnalogIn ldr(p15);                      //assigning ldr as analog input p15
+
+
+int main()
+{
+    while(1) {
+        float ldrout=ldr.read();                        //read ldr value
+        lcd.printf("ldr value is %f\n :",ldrout);       //print ldr value on LCD
+        if(ldrout<0.6) {                                //if ldr value is smaller than 0.6 green LED turns on
+ 
+            myled = 1;                                  //LED on
+        } else {
+            myled=0;                                    //LED off
+        }
+    }
+}
+ 
+
+
+
diff -r 000000000000 -r f612b9501960 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 17 10:28:03 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file