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 mbed-rtos mbed
Revision 5:18415c556f04, committed 2014-05-04
- Comitter:
- MalcolmNixon
- Date:
- Sun May 04 14:11:44 2014 +0000
- Parent:
- 4:f2789e665f4e
- Commit message:
- Initial Revision
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun May 04 04:31:58 2014 +0000
+++ b/main.cpp Sun May 04 14:11:44 2014 +0000
@@ -2,14 +2,10 @@
#include "Thread.h"
#include "mbed.h"
-// Configure the LEDs (off)
-DigitalOut led1(LED1, 1);
-DigitalOut led2(LED2, 1);
-
-
-void ledThreadProc(const void *param)
+void led2ThreadProc(const void *param)
{
- // Toggle the Green LED
+ // Toggle LED2
+ DigitalOut led2(LED2, 1);
for (;;)
{
led2 = !led2;
@@ -17,21 +13,33 @@
}
}
+void led3ThreadProc(const void *param)
+{
+ // Toggle LED3
+ DigitalOut led3(LED3, 1);
+ for (;;)
+ {
+ led3 = !led3;
+ Thread::wait(2000);
+ }
+}
+
int main(void)
{
- Thread ledThread(ledThreadProc);
+ // Start LED toggle(s)
+ Thread led2(led2ThreadProc);
+ Thread led3(led3ThreadProc);
// Start the network
- EthernetInterface eth;
- eth.init("192.168.5.100", "255.255.255.0", "0.0.0.0");
- eth.connect();
+ EthernetInterface::init("192.168.5.100", "255.255.255.0", "0.0.0.0");
+ EthernetInterface::connect();
// Construct the server
- TCPSocketConnection conn;
TCPSocketServer svr;
svr.bind(1234);
svr.listen();
+ TCPSocketConnection conn;
for (;;)
{
// Accept the next connection
@@ -48,9 +56,6 @@
break;
}
- // Toggle the output on led1
- led1 = !led1;
-
// Write the response twice
conn.send(buf, nr);
conn.send(buf, nr);