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.
main.cpp
- Committer:
- destradafilm
- Date:
- 2015-09-16
- Revision:
- 0:00bceb1fa958
File content as of revision 0:00bceb1fa958:
#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); } }