Tiva Lab 02: Doorbell and Lights Control
Objective
- Understand I/O operation in Tiva TM4C LaunchPads
- Learn the steps of GPIO configuration on Tiva TM4C LaunchPads
- Learn how to read data from the input pin, and write a data to output pin
Required Reading Material
- Lesson 07: Create an ARM C Application with Keil μVision MDK-ARM
- Breadboard
- Input Signal Edge Detection using Software
- Set, Clear, Toggle and Check Bit Value in C
Background Information
GPIOs are the basic interfaces of any microcontroller. For a positive logical system, a GPIO pin can be set high (taking the value 1) by connecting it to a voltage supply or set low (taking the value 0) by connecting it to the ground. The Tiva LaunchPad can set the GPIO pin to take either value and treat it as an output, or it can detect the value of the pin and treat it as an input.
You will learn how to write a C code to configure the GPIO ports, read the status of switches, and turn on/off the LEDs.
The first important thing for this lab is the GPIO configuration. When the processor has started executing, but before you can run application software on the processor, it must be initialized, including loading the appropriate software-configuration. The "Lesson 10: GPIO Ports and Configurations"describes the detailed steps that the software must take to initialize the GPIO Ports after reset.
You can read the following articles to get more information about LED and push-button:
- LED: Digital Logic Lab- Lab 01: Introduction to Electrical Circuits: Exp# 1.2
- Push-button: Digital Logic Lab- Lab 01: Introduction to Electrical Circuits: Exp# 1.3
Requirements
Now, a customer asks you to remodel his house. He wants to use an embedded system to control all lighting systems in the house, including doorbells. Three types of control systems could be used in a home:
- A button controls a device, such as a doorbell: when the user presses the doorbell button, the system triggers the doorbell until the button is released.
- A switch controls a light set: when the user presses the switch, the light is on. Press again to turn off the light.
- Multiple switches control lighting sets, such as the stairwell lighting control system: The switches are installed on the first and second floors near the stairs. When the user presses any switch, the light is on, pressing any switch again to turn off the light.
Required Components List
![]() |
Push Button (Switch) | × 4 |
![]() |
220-ohm Resistor | × 3 |
![]() |
LED | × 2 |
![]() |
S8050 NPN Transistor | × 1 |
![]() |
Active Buzzer | × 1 |
![]() |
Breadboard | × 1 |
Circuit / Schematic Diagram
Then, you will create a prototype system to simulate all three types of control systems. The prototype circuit is shown below.
EK-TM4C123GXL LaunchPad
![]() |
![]() |
![]() |
Figure 1: The Simulation Circuit for Home Using TM4C123GXL
Figure 1.2: The Circuit Connection on the Breadboard
Table 1: Pin Configurations:
Device | Port.Pin | Signal Type | PCTL | Direction: | Drive Mode |
---|---|---|---|---|---|
You have to place all the components on the breadboard and use wires to connect the components to the Tiva board. The main functions you must implement are as follows.
- The SW1 is used to control the buzzer (doorbell).
- The SW2 is used to control LED1
- The SW3 and SW4 are used to control LED2, which is installed on the stair.
Procedures
- Create a new folder under the EE3450 folder and name it Lab02_DoorbellLightsControl. Then double-click the folder you just created to jump into it.
- Launch the Keil μVisio and create a new project, save the project as Lab02_DoorbellLightsControl.
- Add MyDefines.h to the Source Group, and then add the Common folder to the include paths under the "Options for Target" setting.
Configurations
Implement the Setup_GPIO() function to initialize the GPIO Ports based on the PIN Configuration table.
Example Source Code
Copy the following example code to your main.c file.
Note: The example code is not yet complete, you must implement all functions following the lab instructions.
Lab Experiments