This code will be implemented on the receiving end of the device, which contains a speaker, an Emic2 text-to-speech converter, as well as a vehicle module that can move or rotate upon request
Dependencies: mbed 4DGL-uLCD-SE emic2 PinDetect
Revision 0:28bd5ee534a3, committed 2018-12-04
- Comitter:
- CharlesXu
- Date:
- Tue Dec 04 15:19:56 2018 +0000
- Child:
- 1:8771f19aeeab
- Commit message:
- transmitter code for Air Rendezvous
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Tue Dec 04 15:19:56 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/kennyainny/code/4DGL-uLCD-SE/#19588ac80c02
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PinDetect.lib Tue Dec 04 15:19:56 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/AjK/code/PinDetect/#cb3afc45028b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emic2.lib Tue Dec 04 15:19:56 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/4180_1/code/emic2/#b95ede38e19d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Dec 04 15:19:56 2018 +0000
@@ -0,0 +1,91 @@
+#include "mbed.h"
+#include "emic2.h"
+ //serial RX,TX pins to emic
+Serial xbee1(p9,p10);
+DigitalOut rst1(p11);
+//emic2 myTTS(p13, p14);
+AnalogIn a1(p15);
+AnalogIn a2(p16);
+AnalogIn a3(p17);
+AnalogIn a4(p18);
+AnalogIn a5(p19);
+Serial pc(USBTX, USBRX);
+float i1;
+float i2;
+float i3;
+float i4;
+float i5;
+float ref1;
+float ref2;
+float ref3;
+float ref4;
+float ref5;
+
+
+
+int counter;
+
+int main() {
+ counter = 0;
+ rst1 = 0;
+ wait_ms(1);
+ rst1 = 1;
+ wait_ms(1);
+ float avg = 0;
+ float max = 0;
+ float diff = 0;
+ char c;
+ while(1) {
+ if (counter % 100) //update reference data every 100 inputs
+ {
+ ref1 = a1;
+ ref2 = a2;
+ ref3 = a3;
+ ref4 = a4;
+ ref5 = a5;
+
+ }
+ counter++;
+ wait(0.5);
+ i1 = a1;
+ i2 = a2;
+ i3 = a3;
+ i4 = a4;
+ i5 = a5;
+
+ c = 'I';
+ if (i1 > i2) {
+ max = i1;
+ c = 'A';
+ } else
+ {
+ max = i2;
+ c = 'B';
+ }
+ if (max < i3)
+ {
+ max = i3;
+ c = 'C';
+ }
+ if (max < i4)
+ {
+ max = i4;
+ c = 'D';
+ }
+ if (max < i5)
+ {
+ max = i5;
+ c = 'E';
+ }
+ avg = (i1 + i2 + i3 + i4 + i5) / 5;
+ diff = max - avg;
+ if (diff*100 > 0.7)
+ {
+ xbee1.putc(c);
+ } else
+ {
+ xbee1.putc ('I');
+ }
+ pc.printf("%4.2f ", diff*100);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 04 15:19:56 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file