

In this lesson, we will show how to use the OSOYOO IoT App to build a remote-controlled ambient light. You can change the light color at home through the mobile app to create more colorful moments.


First, plug the OSOYOO MEGA-IoT Extension Board into the MEGA2560 board:

RGB Module → RGB Port


Prerequisite:
Before running the code, make sure you have downloaded and installed the following libraries. If you installed them in Lesson 1, skip this step.
WifiEsp-master library, download link: https://osoyoo.com/driver/WiFiEsp-master.zip
OsoyooIOT Library, download link: https://osoyoo.com/driver/wifi-iot/OsoyooIOT.zip
Download the OSOYOO IoT App by searching OSOYOO IoT UDP Robot Car App in the App Store (iPhone/iPad) or Google Play Store (Android).
Download and Edit the Lesson 2-7 Arduino Code
Step 1: Download the code from the link below and unzip it:
https://osoyoo.com/driver/smart-home-v2-udp/lesson8/smart-home-lesson8.zip
Step 2: After completing the above steps, connect the OSOYOO MEGA2560 board to your PC with a USB cable.
Step 3: Open Arduino IDE and choose the correct board type and port for your project.

Step 4: In Arduino IDE, click File → Open, then select the code file from the folder and load the sketch onto your Arduino.

You need to edit the code as follows:
**********************************************************
Note: In the sketch, find the code at lines 13–14:
Replace *** with your Wi-Fi SSID and password:
char ssid[] = "***";//replace this line with your wifi ssid char pass[] = "***"; //replace this line with your wifi password
Make sure to replace *** with your correct Wi-Fi SSID and password, or the project will not be able to connect to the internet.
Upload the sketch to the board and wait until you see the Arduino’s IP address.

Now open the OSOYOO IoT UDP App. (If you don’t have it, search for OSOYOO IoT UDP Robot App in the App Store or Google Play Store.)
Tap the Settings icon, enter the Arduino IP address as shown below, and tap Save.


Now you can change the LED color:
Press F1 to turn on RED; press F5 to turn it off.
Press F2 to turn on Green; press F6 to turn it off.
Press F3 to turn on Blue; press F7 to turn it off.
You can combine these 6 keys to create different colors.

| No. | Picture | Device | Qty. | Link |
| 1 | ![]() |
OSOYOO MEGA2560 Board | 1 | Click here to buy |
| 2 | ![]() |
OSOYOO MEGA-IoT Extension Board | 1 | Click here to buy |
| 3 | ![]() |
Photosensitive Sensor | 1 | Click here to buy |
| 4 | ![]() |
Temp & Hum Sensor | 1 | Click here to buy |
| 5 | OSOYOO Active Buzzer Module | 1 | Click here to buy | |
| 6 | ![]() |
Flame Detection Sensor | 1 | Click here to buy |
| 7 | ![]() |
Fan Motor Module | 1 | Click here to buy |
| 8 | ![]() |
Micro Servo Motor | 1 | Click here to buy |
| 9 | ![]() |
RGB Module | 1 | Click here to buy |
| 10 | ![]() |
Ultrasonic Sensor | 1 | Click here to buy |
| 11 | PIR Motion Sensor | 1 | Click here to buy | |
| 12 | ![]() |
Microphone Module | 1 | Click here to buy |
| 13 | ![]() |
1602 I2C LCD Screen | 1 | Click here to buy |
| 14 | ![]() |
RFID Module | 1 | Click here to buy |
| 15 | ![]() |
White LED Module | 1 | Click here to buy |
| 16 | ![]() |
Red LED Module | 1 | Click here to buy |
| 17 | ![]() |
Colorful Light | 1 | Click here to buy |
| 18 | ![]() |
Red Button Module | 1 | Click here to buy |
| 19 | ![]() |
Blue Button Module | 1 | Click here to buy |
| 20 | ![]() |
Philips Screwdriver | 1 | Click here to buy |
DownLoad Url osoyoo.com