Day 5: Switching an LED
Today’s program is finally about controlling hardware via the UDP protocol. In this case, an LED is switched on and off with simple commands.
You will find an LED board behind the fifth door. The right dropping resistor already was in yesterday’s door. Build the circuit as the picture shows.
The program: Day5_UDPLED
! Attention: Some MAC-Users reportet a bug in the PacketSender-Software. This bug doesn’t allow you to change the ports. If you have problems with this bug you can change the ports in the Arduino program. All you have to do for todays project is to change the line 83 from
succes &= sendCom(“AT+CIPSTART=\”UDP\”,\”192.168.4.255\”,90,91″, “OK”);
succes &= sendCom(“AT+CIPSTART=\”UDP\”,\”192.168.4.255\”,5505,5506″, “OK”);
While the previous example programs needed many user inputs, today’s program is to work autonomously. Nevertheless, the serial monitor will continue to output information for debugging purposes.
The controller will now wait for data received from the module that are announced by the +IPD message. Legitimate commands that you can send through the Packet Sender are led1 and led0. The controller interprets them and switches the LED on and off accordingly. Feedback to the transmitter is transmitted as well. If another command is sent, the serial monitor reports “Wrong UDP Command”. The same message is also submitted to the transmitter via the network.