tp_iot

Dependencies:   mbed DHT HC_SR04_Ultrasonic_Library

Committer:
Cornetin
Date:
Wed May 24 13:54:35 2017 +0000
Revision:
2:d1555ccd1c6d
Parent:
1:fdbb495760fc
Child:
3:fcc03d78faf4
Led blinking, trying to send message to actoboard

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Cornetin 0:911000364564 1 #include "mbed.h"
Cornetin 1:fdbb495760fc 2 #include "Serial.h"
Cornetin 2:d1555ccd1c6d 3 #include <string>
Cornetin 2:d1555ccd1c6d 4
Cornetin 1:fdbb495760fc 5 // WE USE PA_2 = TX } CN9
Cornetin 1:fdbb495760fc 6 // PA_3 = RX } CN9
Cornetin 1:fdbb495760fc 7
Cornetin 0:911000364564 8
Cornetin 0:911000364564 9 AnalogIn analog_value(A0);
Cornetin 0:911000364564 10
Cornetin 2:d1555ccd1c6d 11 DigitalOut led(LED2);
Cornetin 0:911000364564 12
Cornetin 0:911000364564 13 int main() {
Cornetin 0:911000364564 14 float meas;
Cornetin 1:fdbb495760fc 15 Serial serial_td1208(PA_2, PA_3);
Cornetin 1:fdbb495760fc 16
Cornetin 2:d1555ccd1c6d 17 std::string init("AT");
Cornetin 2:d1555ccd1c6d 18 std::string query("AT$SS=00 12 FF 42");
Cornetin 2:d1555ccd1c6d 19 serial_td1208.printf("%s", init);
Cornetin 2:d1555ccd1c6d 20
Cornetin 0:911000364564 21
Cornetin 0:911000364564 22 printf("\nAnalogIn example\n");
Cornetin 2:d1555ccd1c6d 23 led = 1;
Cornetin 0:911000364564 24
Cornetin 0:911000364564 25 while(1) {
Cornetin 2:d1555ccd1c6d 26 /*
Cornetin 0:911000364564 27 meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
Cornetin 0:911000364564 28 meas = meas * 3300; // Change the value to be in the 0 to 3300 range
Cornetin 0:911000364564 29 printf("measure = %.0f mV\n", meas);
Cornetin 0:911000364564 30 if (meas > 2000) { // If the value is greater than 2V then switch the LED on
Cornetin 0:911000364564 31 led = 1;
Cornetin 0:911000364564 32 }
Cornetin 0:911000364564 33 else {
Cornetin 0:911000364564 34 led = 0;
Cornetin 2:d1555ccd1c6d 35 }*/
Cornetin 2:d1555ccd1c6d 36 if (led == 1)
Cornetin 2:d1555ccd1c6d 37 led = 0;
Cornetin 2:d1555ccd1c6d 38 else
Cornetin 2:d1555ccd1c6d 39 led = 1;
Cornetin 2:d1555ccd1c6d 40 serial_td1208.printf("%s", query);
Cornetin 2:d1555ccd1c6d 41 wait(10); // 750 ms
Cornetin 0:911000364564 42 }
Cornetin 0:911000364564 43 }