Trying LED Blinking Control (L-Chika) with MATLAB/Simulink and Arduino
Back to Top
To reach a broader audience, this article has been translated from Japanese.
You can find the original version here.
Introduction: Getting Started with "L-Chika" Using Simulink and Arduino
#"L-Chika" (LED blinking) is the most fundamental experiment for an introduction to hardware control.
In this article, we explain how to create a program to blink an LED by integrating MATLAB/Simulink with Arduino.
Preparing the Development Environment
#- Software
- MATLAB (Version: R2025a)
- Simulink (Version: 25.1)
- App (for Simulink)
- Simulink Support Package for Arduino Hardware (Version: 25.1.0)
- Hardware
- Arduino Uno/Nano (or compatible board)
- USB cable (for communication between PC and Arduino)
- (Optional)
- LED + resistor (around 330 Ω)
- Breadboard, jumper wires
Detailed Steps for Environment Setup:
#1. Install MATLAB and Simulink
- Download the installer from MathWorks’ official website
- Perform license activation and install MATLAB and Simulink
- Make sure to check the “Simulink” component during installation
2. Install the Arduino Support Package
-
Launch MATLAB → From the menu, select Add-Ons → Get Hardware Support Packages (This opens the Add-On Explorer)
-
Type "Arduino" into the search box and select
Simulink Support Package for Arduino Hardware
-
Click Install to add the package
-
After installation, the “Simulink Support Package for Arduino Hardware” blocks will appear in the Simulink library
3. Verify Arduino Serial Communication
- When you connect the Arduino board to your PC via USB, the driver is automatically recognized
- If it’s not recognized, check the port in Device Manager (Windows) or with
ls /dev/tty*
(Mac/Linux) (the example below shows it connected to COM7)
Circuit Connection
#Connect the LED + resistor between Arduino pin 13 and GND.
(If you use the built-in LED, no external wiring is required.)
Circuit diagram example:
(Arduino 13) ----[330Ω resistor]----|>|(LED)---- (GND)
Creating the Simulink Model
#Creating a New Model
#-
From the block library, add the following blocks:
Parameter Settings
#Set the parameters for the blocks you placed.
-
Pulse Generator
-
Digital Output
With a sample time of 0.001 seconds and a sample period of 1000, the period (time) becomes 1 second.
Since the pulse width is set to 500, the LED will toggle ON/OFF every 500 milliseconds with this configuration.
Model Configuration
#Configure the hardware board as follows.
(In this example, we used an Arduino Nano-compatible board. The compatible board’s bootloader was an older version, so the baud rate for application download is lower.)
Verifying the Pulse Generator Output
#Before uploading the application to the Arduino, verify that the pulse is being output correctly.
-
Set up signal logging (click the connection line and enable “Log Signal”)
You can confirm that signal logging is enabled by the icon
Monitor and Tune (Verifying Execution via USB Port)
#Transfer the program to the Arduino Nano via USB and verify that the program runs correctly.
-
In the Hardware tab, select “Monitor & Tune” (set the stop time to “inf” so it continues running until you stop it)
-
If the Arduino’s built-in LED blinks with a 1-second period, the model is running correctly
Writing to Arduino and Execution
#Upload the program to the Arduino and enable automatic execution.
-
The process compiles and transfers to the Arduino.
When the transfer succeeds, the following log is displayed.
If the LED blinks every second, the transfer was successful.
Results and Discussion
#- With just two blocks connected, it was easy to create an LED blinking program.
- Reducing the period results in “fast blinking” (for example, a period of 100 and a pulse width of 50).
- By changing the pulse width (duty cycle), you can also apply this to brightness control (the basics of PWM).
Conclusion
#- Combining MATLAB/Simulink with Arduino demonstrated that you can intuitively develop control programs using block diagrams.
- Although LED blinking is a simple example, it can be extended to PWM control, sensor input, motor control, and more.
If you only need to blink an LED, programming in an environment such as the Arduino IDE or PlatformIO might be faster. However, for more complex programming in the future, I feel that MATLAB/Simulink will become a powerful tool for model-based design (MBD) development.
Going forward, I plan to create custom libraries and connect advanced peripherals to tackle more detailed programming challenges.