Course Solutions Uncategorized (Solved) : Include Enum States Start Init Ledlit1 State Unsigned Char Button Define Button Pina 0x01 Q30985858 . . . .

(Solved) : Include Enum States Start Init Ledlit1 State Unsigned Char Button Define Button Pina 0x01 Q30985858 . . . .

 

#include

enum States {Start, Init, LED_Lit1} state;
unsigned char button;
#define button PINA & 0x01

void tick_LED()
{
switch(state) {    // Transitions
case Start:       // Starttransition
state = Init;
break;

case Init:        // Initialtransition
if(button == 1){ // If PINA0 is 1 state goes to led_lit inLED_Lit1
state = LED_Lit1;
}
else{           // If PINA0 is 0 state remains in initial
state = Init;  
}
break;

case LED_Lit1:    // LED_Lit1 Transition
if(button == 0){ // If PA0 is 1 state remains in LED_Lit1
state = LED_Lit1;  
}
else {
state = Init;   // if PA1 is 1 state goes toinitial
}
break;

default:
state = Start;
break;
}

switch(state) { // Actions
case Start:
PORTB = 0x01;   // PB0 set to 1
break;      
case Init:
PORTB = 0x01;   // PB0 set to 1
break;
case LED_Lit1:
PORTB =

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post