

Tactile Button Switch Exercise | ACE-Lab ACE-Lab ExerciseTactile Button Switch Exercise
Learn how to build and test a simple tactile button switch circuit with an Arduino Uno and Simulink, using PWM-based LED control and a practical breadboard setup.
Arduino Uno Simulink Support Package Digital / PWM ExerciseSection 1
Learning Outcomes
After completing this section, you will be able to:
- Understand the use of the Simulink Arduino support package for algorithm design for a simple circuit, for example an LED containing a tactile button switch.
- Understand the functions of the Arduino Uno and the digital pins for use with a simple circuit, such as using PWM to control an LED in combination with a tactile push-button switch.
Why this exercise matters
This task reinforces core embedded-control concepts: physical interfacing, signal flow, model-based design, and the practical relationship between hardware configuration and Simulink deployment.
Section 2
Hardware Set-Up
The exercise involves connecting an LED to a switch that can control the LED state through physical force applied to the tactile button switch.
Note that while the ACE-Box can be used for all the exercises, it is not required and only the individual components are needed.
Required hardware
- Arduino Uno board (supported by Simulink)
- USB cable Type A to B
- Breadboard
- LED
- 220 Ohm resistor
- 2 × male-to-male breadboard wires
- Tactile button switch
Assembly steps
- Insert the tactile button switch across the centre gap of the breadboard.
- Connect Arduino Pin 9 to one leg of the tactile switch using a jumper wire.
- Place a 220 Ohm resistor from the opposite leg of the switch into a separate row.
- Connect the LED anode to the free end of the resistor and the cathode to Arduino GND.
Replace this block with the hardware setup figure or breadboard diagram for the tactile button switch exercise.Download NowDownload the PDF version of the exercise
Use the original ACE-Lab document as a downloadable reference for students.
Section 3
Simulink Setup and Tactile Button Switch Testing
As a tactile button switch has been added to the hardware, with no extra inputs or outputs, the Simulink setup remains the same as the LED (PWM) and on/off power switch exercises. For completeness, the full setup is outlined again here.
Model construction steps
- Use a Sine Wave block from Sources and connect it to an Abs block from Math Operations.
- Add a Slider Gain block from Math Operations. The lower and upper limits can be used to constrain the output voltage. For example, limiting the voltage to 2.3 V gives 256 × 2.3 = 117.76 ≈ 117. For this exercise, set the upper limit to 255, equivalent to 5 V on the Arduino Uno.
- Add a PWM block from Common in the Simulink Support Package for Arduino Hardware and connect three Scope blocks.
- Run the code-generation steps from the previous exercise to deploy the model and create an LED that varies in brightness. Explore the effect of the Slider Gain value during testing.
A demonstration video and recap link can be added below this section if you want this page to match the full behaviour of the live ACE-Lab exercise pages.
Download Simulink FileReplace this block with the Simulink model screenshot for the tactile button switch exercise.Key Properties to Modify
Sine Wave (Sine type)Sample-basedSine Wave (Sample per period)Sample-basedSine Wave (Samples per period)300Sine Wave (Sample time)0.01 sSlider Gain (High)255All other properties may remain as their default values.Download NowDownload the PDF version of the exercise
Keep the document link visible at the end of the workflow section for consistency with other ACE pages.

