Tiva Lab 02: Doorbell and Lights Control


  • 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

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:



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:

  1. 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.
  2. A switch controls a light set: when the user presses the switch, the light is on. Press again to turn off the light.
  3. 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

Button Small 64 Push Button (Switch) × 4
Resistor 64 220-ohm Resistor × 3
LED Green 64 LED × 2
Trnasistor 64 S8050 NPN Transistor × 1
ActiveBuzzer 64 Active Buzzer × 1
breadboard s 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.

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.


  1. 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.
  2. Launch the Keil μVisio and create a new project, save the project as Lab02_DoorbellLightsControl.
  3. Add MyDefines.h to the Source Group, and then add the Common folder to the include paths under the "Options for Target" setting.


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