FW LP Part 3
Congratulations on making it to part 3 of Launchpad! Now that we have a way to interact with peripheral devices, we will make a virtual car that is controlled by the buttons, LEDs, and potentiometer we learned how to interact with in the previous parts. We will also be introducing FreeRTOS, a tool used by this team for multithreading on embedded systems. Multithreading is a technology that allows for different threads of computation to happen on the same computer, and a thread is a sequence of instructions that is grouped together. In this part, you will be making three threads, one for each type of peripheral, to separate the logic for the LEDs, buttons, and potentiometer. You will be using FreeRTOS, a type of real time operating system that we use in all but one of our embedded systems. Write a program that meets the requirements below.
Requirements
There is a task dedicated to reading the buttons, a task dedicated to reading the potentiometer, and a task dedicated to the LEDs
The car accelerates when one of the buttons is pressed
The car decelerates when the other button is pressed
One LED that is off when the car is driving forwards, and on when the car is driving backwards
An LED that displays the speed of the car through its blink rate, where faster blinking means the car is moving faster, and a speed of zero means the LED is off (put a limit on speed so that the LED blinking accurately displays the speed of the car)
A potentiometer that controls how quickly the car accelerates (suggestion: give the car 4 gears)
The direction switch button changes the direction that the car drives in. If the button is pressed and held down, the direction of the car only changes once.
The velocity of the car is calculated and printed to the terminal
References that you will need to complete this task:
Suggested steps to get started on this part
Make sure you understand FreeRTOS and multi-threading
Make a way to keep track of the state of the car (make a state machine diagram)
Make a way to transfer data between processes (make a diagram if you get stuck here)
Once the previous two are done, then you should start to program the logic of the car