simplify version, but need 3.3v for the photodiode

Dependencies:   mbed

Fork of Nucleo_read_analog_value by Robocon_IPS

Committer:
iskenny4
Date:
Thu Jun 01 01:10:26 2017 +0000
Revision:
1:5bc3306dd478
Parent:
0:f3b9844205f2
if the photodiode can set at 3.3v, then try this program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cc061495 0:f3b9844205f2 1 #include "mbed.h"
iskenny4 1:5bc3306dd478 2 InterruptIn sensor(PA_0);
cc061495 0:f3b9844205f2 3
cc061495 0:f3b9844205f2 4 Serial pc(USBTX,USBRX,115200);
iskenny4 1:5bc3306dd478 5
cc061495 0:f3b9844205f2 6 Timer t;
cc061495 0:f3b9844205f2 7
iskenny4 1:5bc3306dd478 8 void start() {
iskenny4 1:5bc3306dd478 9 t.start();
iskenny4 1:5bc3306dd478 10 }
iskenny4 1:5bc3306dd478 11
iskenny4 1:5bc3306dd478 12 void stop() {
iskenny4 1:5bc3306dd478 13 t.stop();
iskenny4 1:5bc3306dd478 14 pc.printf("%f seconds\n", t.read());
iskenny4 1:5bc3306dd478 15 t.reset();
iskenny4 1:5bc3306dd478 16 }
iskenny4 1:5bc3306dd478 17
cc061495 0:f3b9844205f2 18 int main() {
cc061495 0:f3b9844205f2 19 pc.format(8,SerialBase::None,1);
iskenny4 1:5bc3306dd478 20 sensor.fall(&start); // voltage drops below 3.3v
iskenny4 1:5bc3306dd478 21 sensor.rise(&stop); // voltage rises above 3.3v
iskenny4 1:5bc3306dd478 22 while(1);
cc061495 0:f3b9844205f2 23 }