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: EthernetInterface IrcBot mbed-rtos mbed
main.cpp
- Committer:
- deton
- Date:
- 2014-09-20
- Revision:
- 0:e4e22c85b47f
- Child:
- 2:23c9ee69c999
File content as of revision 0:e4e22c85b47f:
#include "mbed.h" #include "EthernetInterface.h" #include "IrcBot.h" #define NICKNAME "detonPHS" //#define IRCSERVER "192.168.0.2" #define IRCSERVER "10.254.166.45" #define RINGNOTIFYCMD "PRIVMSG deton :@deton RING" #define DEADTIME 10 // [sec] Serial pc(USBTX, USBRX); // tx, rx AnalogIn ain(p17); DigitalOut led(LED1); int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); IrcBot irc(NICKNAME, IRCSERVER, 6667, NULL); irc.connect(); set_time(1408859241); // need for time(NULL), otherwise time(NULL) returns -1 time_t prevOnTime = 0; float f; while (1){ f = ain.read(); pc.printf("%.2f,", f); if (f > 0.3) { led = 1; time_t now = time(NULL); //pc.printf("[%ld,%ld,%ld]", now, prevOnTime, now - prevOnTime); if (now - prevOnTime > DEADTIME) { irc.printfln("%s (%.2f)", RINGNOTIFYCMD, f); prevOnTime = now; } } else { led = 0; } irc.read(); } }