Akira Kashihara / Challenge2_simple
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn illu(p15);
00004 DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
00005 float lx;
00006 
00007 int main()
00008 {
00009     while(1) {
00010         lx = illu * 3.3 / 3 * 1000;
00011         float powr = 0 ;
00012         powr = (lx/100.0) * (4.0/11.0);
00013 
00014         for(int i = 0; i < powr; i++) {
00015             myleds[i] = 1;
00016         }
00017         for(int i = powr ; i < 4; i++) {
00018             myleds[i] = 0;
00019         }
00020     }
00021 }