Welcome to the coding part of Launchpad! All the code written in Launchpad, and most of the code on the car, is written in C. If you are unfamiliar with programming in C or want a refresher on it, go through this tutorial, skipping the "C Files” section and stopping at the “C reference section” (link). Secondly, all of your code will run on a microcontroller, specifically an ESP32, so you should read through this article if you are unfamiliar with the concept of a microcontroller. With the previously mentioned concepts in mind, write code to meet the specification below and submit it to GitHub classroom for review. When you run into a wall and cannot google yourself out of your issue, you should ask leads for help, and if you are doing it over Slack, which is the best way to ask for help, do it in the public #fw_launchpad channel.
The result of Launchpad will be a simulated car running on an embedded system, and to get to that endpoint, we will be starting small. In this part of Launchpad, you will be working with the general-purpose input-output (GPIO) ports of an ESP32 microcontroller. On the breadboard provided in the bay there are buttons and light emitting diodes (LEDs) connected to the GPIO pins of an ESP32. The buttons will be the acceleration and brake pedals of the car, and the LEDs will display the speed and state of the car. In this part, you will write the functions for reading and outputting the voltage levels of the ESP32's GPIO pins.
Deliverables:
A function for configuring the GPIO pins of the ESP32 microcontroller
A function for reading the voltage level of a GPIO pin
A function for setting the voltage level of a GPIO pin
References that you will need to complete this task:
Suggested steps to get started on this part
Look at the schematic to know pin mappings, and assign pin mappings to the GPIOs
Look at the programming guide to learn the API for accessing the GPIO ports. Using the
gpio_config
function is not recommended as it is harder to get right.
Test Criteria
Ensure you can toggle both On LED and Spedometer
Ensure you can read whether Accelerate, Brake, and Direction are being pressed down.
Make sure you put your code in the function that has been labeled for this part. Ignore all of the other parts of the code for now, as those are concepts that we will go over later in Launchpad. For this part and the rest of Launchpad, you must demonstrate the proper functioning of your program in order for you to move on to the next part.