LED can be controlled by remote TCP client. This code was tested with WIZwiki-W7500 platform board.
Fork of TCP_LED_Control-WIZwiki-W7500 by
WIZwiki-W7500 TCP LED Control Example
The WIZwiki board series has an Ethernet interface with an RJ-45 connector, so you can quickly implement various network applications. This example controls the on-board LED by sending the specified command string to the board with Ethernet - TCP data.
The following items are required to implement this example project.
- Ethernet Hub or Router (supports DHCP IP allocation)
If there is no Ethernet hub or router, you can connect PC and device directly with LAN cable.
The on-board LED (red) used to verify the transmission of TCP data is connected to the PC_08 pin and is declared as LED1 in the mbed library.
The following three command strings are implemented in this example project.
- LED blinks every 200 milliseconds.
- Implemented using mbed Ticker APIs
For Ethernet networking, each network device must have its own unique hardware address. that hardware address is called MAC address, and typically the MAC address is represented by six bytes hex separated by a colon. e.g., 00:08:DC:XX:XX:XX
The MAC address is defined in the code as follows.
#define MAC "\x00\x08\xDC\x55\x51\x52"
IP address allocation method
Use Static IP address
The 'Static IP address' setting is the default value, and the device is configured with the network information defined in the code. It can be used when connecting the device directly to the PC or through an Ethernet hub. The IP address of the PC should be set to the same ip address range as the device.
The network information is defined in the code as follows.
#define IP "192.168.0.20" // IP address #define SUBNET "255.255.255.0" // Subnet Mask #define GATEWAY "192.168.0.1" // Gateway address
The following is an example of the PC's network settings that can connect with the device's settings.
|PC's network setting example|
Routers that support DHCP automatically assign a leased range of IP addresses to each connected devices. If your PC is connected to a router, uncomment the following define and the device will be automatically assigned network information.
The network information assigned by the router can be checked through the debug messages output to the serial terminal.
Building and Running an Example
1. Import this project into your mbed compiler.
2. View the default program source code and modify what you need.
- Network settings and so on.
3. Compile and Download the Program.
- To compile the program, click the Compile button in the toolbar. This will compile all the program source code files within the program folder to create a binary program.
- After a successful compile, you will get a "Success!" message in the compiler output and the download dialog will pop up. Save it to the location of the mbed Microcontroller drive, and then hit reset on the microcontroller to start it running!
4. Run the serial terminal program and check the messages.
- Device's network settings and supported command strings.
- Default UART baudrate: 115200bps
5. Run the TCP client terminal program and Connect to your device.
6. Send command to your device and check status of LED and serial messages
2017-04-13, by hkjung [Thu, 13 Apr 2017 23:16:22 +0000] rev 16
Added UART configuration code for debug message print out
2017-04-12, by hkjung [Wed, 12 Apr 2017 00:50:20 +0000] rev 15
Command 'LED_BLINK' added
2017-04-11, by hkjung [Tue, 11 Apr 2017 05:24:40 +0000] rev 14
Code modified / mbed and ethernet library updated
2015-07-27, by kzl108 [Mon, 27 Jul 2015 01:31:48 +0000] rev 13
LED can be controlled by remote TCP client
2015-07-20, by kzl108 [Mon, 20 Jul 2015 07:54:18 +0000] rev 12
LED Control by TCP
2015-06-29, by hjjeon [Mon, 29 Jun 2015 09:46:12 +0000] rev 11
2015-06-29, by hjjeon [Mon, 29 Jun 2015 09:19:24 +0000] rev 10
HTTP server example program for WIZwiki-W7500.
2015-06-29, by hjjeon [Mon, 29 Jun 2015 09:04:29 +0000] rev 9
httpServer example program for WIZwiki-W7500 platform; release version
2015-06-23, by justinkim [Tue, 23 Jun 2015 00:36:34 +0000] rev 8
TCPEchoServer example for WIZwiki-W7500
2015-05-04, by mbedAustin [Mon, 04 May 2015 22:47:02 +0000] rev 7
updated example code to be more verbose