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
Diff: main.cpp
- Revision:
- 0:9661d4f543d7
diff -r 000000000000 -r 9661d4f543d7 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Oct 29 09:51:51 2016 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#define soglia 1000
+Serial pc(USBTX,USBRX);
+unsigned int RCtime();
+unsigned int photoR;
+DigitalOut out(D6);
+DigitalInOut sens(D4);
+
+int main()
+{
+ pc.printf("ADC data values...\n\r");
+ while (1) {
+ photoR = RCtime();
+
+ if(photoR == 30000){
+ pc.printf("Nothing connected...\n\r");
+ }
+ else {
+ pc.printf("RC time reading = ");
+ pc.printf("%u\n\r",photoR);
+
+ if(photoR>soglia){
+ out=1;
+ }
+ else{
+ out=0;
+ }
+ }
+ wait(0.1);
+ }
+ }
+
+unsigned int RCtime()
+{
+ int reading = 0;
+ sens.output();
+ sens=0;
+ wait_ms(10);
+ sens.input();
+ while(sens == 0){
+ reading++;
+ if(reading == 30000){
+ break;
+ }
+ }
+ return reading;
+ }
\ No newline at end of file