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.
Revision 0:00bceb1fa958, committed 2015-09-16
- Comitter:
- destradafilm
- Date:
- Wed Sep 16 16:24:20 2015 +0000
- Commit message:
- HW 4.1 q3
Changed in this revision
| 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Sep 16 16:24:20 2015 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+#define PROGNAME "DEstra_HW 4_1 QUESTION 3"
+#define DATATIME 0.5
+
+#define PRINTDEBUG
+
+AnalogIn LightSensor(PTE22); // define light sensor
+PwmOut redLed(LED_RED);
+PwmOut greenLed(LED_GREEN);
+
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+ float lightVal;
+ unsigned short lightWord;
+
+ pc.printf(PROGNAME);
+
+ while(true){
+ lightVal = LightSensor.read();
+ lightWord = LightSensor.read_u16();
+ redLed = 1.0 - lightVal; // redLed shines brighter as it gets darker outside
+ greenLed = 1.0 - lightVal;
+
+ #ifdef PRINTDEBUG
+ pc.printf("LS => %1.3f %5 \r\n", (1.0 - lightVal), lightWord);
+ pc.printf("other => %\r\n", lightWord);
+ #endif
+ wait(DATATIME);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Sep 16 16:24:20 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad \ No newline at end of file