This example shows how to control the brightness of an Arduino LED from an Apple iOS device.
Apple iOS devices provide wireless access and a user interface. Arduino is an open-source platform used for building electronics projects. Arduino consists of both a hardware board with a micontroller and a software Integrated Development Environment (IDE) that runs on your computer, used to write and upload computer code to the physical board. Using these two, you can, for example control Arduino hardware using an Apple iOS device by connecting them wirelessly.
This example provides two Simulink models,
In the iOS model, the slider block present on iOS is used to control the brightness of Arduino onboard LED.
In the Arduino model, data recieved from your Apple iOS device is sent as an input to the PWM block of Arduino, to control the brightness of LED.
With these models, you will:
Set up a network connection between an Apple iOS device and Arduino
Configure and run Simulink models for Apple iOS device and Arduino to remotely control the brightness of the LED on the Arduino.
Complete the Getting Started with Apple iOS Devices example.(recommended)
Complete the Getting Started with Arduino Hardware example.(recommended)
Complete the Getting started with WiFi on Arduino Hardware example.(recommended)
Arduino Mega 2560/Mega ADK/Due/Leonardo/MKR1000
iPhone, iPod or iPad
Arduino WiFi Shield/ ESP8266
You can skip this task if you are using the Arduino Mega ADK board.
In this task, you will configure the model for the supported Arduino board.
1. In your Simulink model, click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.
2. Select the Hardware Implementation pane and select your required Arduino hardware from the Hardware board parameter list. Do not change any other settings.
3. Click OK.
Set up a network connection between an Apple iOS device and an Arduino. The communication protocol used in this example is TCP/IP.
1. Connect the WiFi hardware to the Arduino board.
For more details on connecting the Arduino to WiFi Shield, see Connect Arduino WiFi Shield to Arduino Hardware.
For more details on connecting the Arduino to ESP8266, refer to Connect ESP8266 to Arduino Hardware in the documentation.
The Arduino MKR1000 has an on-board WiFi chip. It can be used directly without any additional WiFi hardware.
2. Open the Arduino model. To configure the network settings for the Arduino WiFi Shield, go to Configuration Parameters > Hardware Implementation > Target hardware resources > WiFi properties.
3. Specify the SSID of your WiFi network in the Service set identifier (SSID) parameter.
4. Select the WiFi encryption parameter based on your WiFi network encryption settings.
For more details on configuring the network settings for Arduino WiFi Hardware, see
5. Connect your Apple iOS device to the same WiFi network to which the Arduino is connected.
1. Open the Arduino model.
2. Click Deploy to Hardware button of Arduino model to run this model on your Arduino hardware
3. In the Diagnostic viewer, find the dynamically assigned IP address of Arduino below the memory usage information. Alternatively, a MATLAB base workspace variable with the name 'modelname_IPaddress' is created with the value of the IP address.
4. Open the iOS model.
5. Double-click on the TCP/IP Send block and change the Remote address to the IP address of the Arduino hardware.
6. Click Deploy to Hardware button of iOS model to run this model on Apple iOS device.
7. In the Apple iOS device, change the Slider value on Apple iOS device to control the brightness of LED.
Replace WiFi Block in Arduino model with Ethernet block.
Connect the Arduino hardware to the electronic appliances using relays and with the help of button Block on Apple iOS, control them.
This example showed you how to
Wirelessly connecting an Apple iOS device to Arduino using TCP/IP.
Remotely control the brightness of an Arduino onboard LED using the iOS Slider block.