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:
- 1:506c8ffad3d8
- Parent:
- 0:1dbc25c03bad
diff -r 1dbc25c03bad -r 506c8ffad3d8 main.cpp
--- a/main.cpp Fri Sep 04 19:07:09 2015 +0000
+++ b/main.cpp Tue Oct 06 19:17:32 2015 +0000
@@ -1,8 +1,13 @@
#include "mbed.h"
-
+
+DigitalOut dout1(LED1);
+DigitalOut dout2(LED2);
+DigitalOut dout3(LED3);
+DigitalOut dout4(LED4);
+AnalogIn ain(p15);
// The sinewave is created on this pin
AnalogOut aout(p18);
-
+
int main()
{
const double pi = 3.141592653589793238462;
@@ -18,5 +23,43 @@
sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
aout.write_u16(sample);
}
+
+ //Sharp IR sensor display
+ if (ain.read() > 0.9f) //less than 7 cm
+ {
+ dout1 = 1;
+ dout2 = 1;
+ dout3 = 1;
+ dout4 = 1;
+ }
+ else if (ain.read() > 0.68f && ain.read() <= 0.9f) //7-10
+ {
+ dout1 = 0;
+ dout2 = 1;
+ dout3 = 1;
+ dout4 = 1;
+ }
+ else if (ain.read() > 0.53f && ain.read() <= 0.68f) //10-13
+ {
+ dout1 = 0;
+ dout2 = 0;
+ dout3 = 1;
+ dout4 = 1;
+ }
+ else if (ain.read() > 0.45f && ain.read() <= 0.53f) //13-17
+ {
+ dout1 = 0;
+ dout2 = 0;
+ dout3 = 0;
+ dout4 = 1;
+ }
+ else //greater than 17
+ {
+
+ dout1 = 0;
+ dout2 = 0;
+ dout3 = 0;
+ dout4 = 0;
+ }
}
}