Example code to toggle the RGB LED of the application shield with a State Machine

Committer:
pcordemans
Date:
Wed Oct 28 12:17:07 2020 +0000
Revision:
0:00a89ddb74dc
Toggles RGB led with a State Machine

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pcordemans 0:00a89ddb74dc 1 #ifndef STATEMACHINE_H
pcordemans 0:00a89ddb74dc 2 #define STATEMACHINE_H
pcordemans 0:00a89ddb74dc 3
pcordemans 0:00a89ddb74dc 4 #include "mbed.h"
pcordemans 0:00a89ddb74dc 5
pcordemans 0:00a89ddb74dc 6 enum State {RED, GREEN, BLUE, CERROR};
pcordemans 0:00a89ddb74dc 7
pcordemans 0:00a89ddb74dc 8 class StateMachine {
pcordemans 0:00a89ddb74dc 9 private:
pcordemans 0:00a89ddb74dc 10 State currentState;
pcordemans 0:00a89ddb74dc 11 void actionRed();
pcordemans 0:00a89ddb74dc 12 void actionGreen();
pcordemans 0:00a89ddb74dc 13 void actionBlue();
pcordemans 0:00a89ddb74dc 14 PwmOut* r;
pcordemans 0:00a89ddb74dc 15 PwmOut* g;
pcordemans 0:00a89ddb74dc 16 PwmOut* b;
pcordemans 0:00a89ddb74dc 17
pcordemans 0:00a89ddb74dc 18 public:
pcordemans 0:00a89ddb74dc 19
pcordemans 0:00a89ddb74dc 20 StateMachine();
pcordemans 0:00a89ddb74dc 21 ~StateMachine();
pcordemans 0:00a89ddb74dc 22
pcordemans 0:00a89ddb74dc 23 void start();
pcordemans 0:00a89ddb74dc 24 };
pcordemans 0:00a89ddb74dc 25
pcordemans 0:00a89ddb74dc 26 #endif