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:
- bky
- Date:
- 2020-12-01
- Revision:
- 9:b7e8d0372f53
- Parent:
- 8:9f59ef177620
- Child:
- 10:8d86e59fb408
File content as of revision 9:b7e8d0372f53:
#include "mbed.h"
#include <time.h>
# include <stdbool.h>
# define LIGHT_SENSOR_PIN p15
AnalogIn lightSensorVoltage(LIGHT_SENSOR_PIN);
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
float voltage0 = 0;
float voltage1 = 0;
bool flashDetected() {
bool flashDetected = (voltage1 < voltage0) && (voltage0 > lightSensorVoltage.read());
// update stored values
voltage1 = voltage0;
voltage0 = lightSensorVoltage;
return flashDetected;
}
void sendFloat(float value) {
for (int i=0; i<4; i++)
pc.putc(*(((char*) &value)+i));
}
int main() {
//int flashTime = 0;
printf("starting\n");
while(1) {
sendFloat(lightSensorVoltage.read());
wait(0.1);
}
}
