Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Compile and test the blink state-machine code (code provided) In this project you are required to implement a state machine. Part 1 : Modify the

Compile and test the blink state-machine code (code provided)

In this project you are required to implement a state machine.

Part 1 :

  • Modify the code to make 3 LEDs (min you can use more ) to create a blinking LED Binary counter
    • LEDs should blink this sequence: 000, 001, 010, 011, 100, 101, 110, 111
  • Once it ends , it your choice if to go to zero or to go in reverse

Part 2:

  • Add 2 buttons to your project - Adding buttons lab pdf provided( attached )
  • Button 1:
    • Pressing it once and releasing it should reverse the binary counter
    • Keeping it pressed should not do anything until the button is released
  • Button 2
    • Pressing it once and releasing it should increase the speed of the binary counter
    • The counter should have 3 speeds : slow, med, fast
    • Button 2 should change the speed in this sequence: Slow, med, fast, med, slow, med, fast, med , slow ..
    • Same behavior on press/release as button 1

      enum SM_States { SM_Start, SM_s0, SM_s1 } SM_State; int gDelay = 500;

      void TickFct_GenericSM() { switch(SM_State) { // Transitions case SM_Start: // Initial transition SM_State = SM_s0; break; case SM_s0: SM_State = SM_s1; break; case SM_s1: SM_State = SM_s0; break; default: SM_State = SM_Start; break; } // Transitions switch(SM_State) { // State actions case SM_s0: digitalWrite(12, HIGH); break; case SM_s1: digitalWrite(12, LOW); break; default: break; } // State actions }

      void setup() { SM_State = SM_Start; // Indicates initial call pinMode(12, OUTPUT); } void loop() { // put your main code here, to run repeatedly: TickFct_GenericSM(); delay(gDelay); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Accounting questions

Question

L A -r- P[N]

Answered: 1 week ago