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: QEI MFRC522 HTS221 IoTKit BMP180 MQTT
Fork of MQTTPublish by
Diff: main.cpp
- Revision:
- 26:cf9cf40c63ea
- Parent:
- 25:5e982d03e7d1
- Child:
- 27:43f3a9552db2
--- a/main.cpp Sun Sep 09 11:56:38 2018 +0000 +++ b/main.cpp Mon Sep 10 16:47:34 2018 +0000 @@ -6,6 +6,7 @@ #include "MQTTmbed.h" #include "MQTTClient.h" #include "OLEDDisplay.h" +#include "Motor.h" static DevI2C devI2c(PTE0,PTE1); static HTS221Sensor hum_temp(&devI2c); @@ -31,6 +32,10 @@ DigitalOut led1( D10 ); DigitalOut alert( D13 ); +// Aktore(n) +Motor m1(D3, D2, D4); // PWM, Vorwaerts, Rueckwarts +PwmOut speaker( D12 ); + /** Hilfsfunktion zum Publizieren auf MQTT Broker */ void publish( MQTTNetwork &mqttNetwork, MQTT::Client<MQTTNetwork, Countdown> &client, char* topic ) { @@ -100,9 +105,19 @@ hum_temp.get_temperature(&temp); hum_temp.get_humidity(&hum); if ( type == 0 ) + { temp -= 5.0f; + m1.speed( 0.0f ); + } else if ( type == 2 ) + { temp += 5.0f; + m1.speed( 1.0f ); + } + else + { + m1.speed( 0.75f ); + } sprintf( buf, "0x%X,%2.2f,%2.1f,%s", id, temp, hum, cls[type] ); type++; if ( type > 2 ) @@ -122,9 +137,17 @@ publish( mqttNetwork, client, topicALERT ); alert = 1; } + speaker.period( 1.0 / 3969.0 ); // 3969 = Tonfrequenz in Hz + speaker = 0.5f; + wait( 0.5f ); + speaker.period( 1.0 / 2800.0 ); + wait( 0.5f ); } else + { alert = 0; + speaker = 0.0f; + } wait ( 2.0f ); } }