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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 #define soglia 1000 00003 Serial pc(USBTX,USBRX); 00004 unsigned int RCtime(); 00005 unsigned int photoR; 00006 DigitalOut out(D6); 00007 DigitalInOut sens(D4); 00008 00009 int main() 00010 { 00011 pc.printf("ADC data values...\n\r"); 00012 while (1) { 00013 photoR = RCtime(); 00014 00015 if(photoR == 30000){ 00016 pc.printf("Nothing connected...\n\r"); 00017 } 00018 else { 00019 pc.printf("RC time reading = "); 00020 pc.printf("%u\n\r",photoR); 00021 00022 if(photoR>soglia){ 00023 out=1; 00024 } 00025 else{ 00026 out=0; 00027 } 00028 } 00029 wait(0.1); 00030 } 00031 } 00032 00033 unsigned int RCtime() 00034 { 00035 int reading = 0; 00036 sens.output(); 00037 sens=0; 00038 wait_ms(10); 00039 sens.input(); 00040 while(sens == 0){ 00041 reading++; 00042 if(reading == 30000){ 00043 break; 00044 } 00045 } 00046 return reading; 00047 }
Generated on Tue Aug 16 2022 02:32:32 by
1.7.2