Traffic Light Controller The tried and true traffic light controller with assemb
ID: 1845938 • Letter: T
Question
Traffic Light Controller
The tried and true traffic light controller with assembly language subroutines
Goals:
- Do some more programming in a high level language
- More practice writing assembly
- Write code that passes parameters between C++ and assembly
What you
/* Develop the assembly level code for the function calls Write the high level traffic light controller code Extra Credit: Replace the digital Write function calls with your own custom assembly level functions Replace all of the high level C code with assembly. You'll only have one function call in the setup section that calls your assembly function */ #include #include "Arduino.h" extern "C" {int get_switch_value();}; //This function returns 0 if the switch input is set to GND //and 255 (0xFF) if the switch input is set to 5V //You need to write some of this code in the assembly file functions.s extern "C" {int mydelay(int val);}; //This is a delay loop that you need to write in the assembly file //It takes an integer value and goes into a time delay loop of approximately //one hundred microseconds times the value passed to the function //For example mydelay(10) would run for about 1 millisecond (1000 microseconds) void setup() { Serial.begin(9600); //if you want to print things out to the serial monitor } Bvoid loop() { //Write a traffic light controller here //If the switch is to ground //Green rightarrow Yellow rightarrow Red // 1 sec 3 sec 5 sec //If the switch is to 5V //Green rightarrow Yellow rightarrow Red // 5 sec 3 sec 5 sec //Use the get_switch_value function to detect the state of the switch //Use your mydelay function to provide the time delays between light changes }Explanation / Answer
Start a new Arduino project, and begin with these lines:
Next, let
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.