Professional Documents
Culture Documents
Microcontrollers Lab
Outputs
First part and Second part: combinations to activate the motors and the 7 segment
display
Tools
We use for loops, if clauses , switch cases and a while loop.
Methodology
1. First we did a table with all the inputs and outputs.
2. Then we draw our machine state.
3. We write the code, using an if at the begining in order to control the most significant bit,
and in order to be able to go from one state to another we use a switch case.
4. We check in the debug viewer that it was switching between cases
5. We build the corresponding circuit
6. Finally we upload the code.
• What we did different in the second code is that we use an array, where the string is written,
and a for loop to run through the array.
States Table
First part:
ID State Letter Delay PB11 PB10 PB9 PB8 PD15 PD14 PD13 PD12 PD11 PD10 PD9
S IDLE S 1...9 0 0 0 0 0 0 1 0 0 1 0
F S4 F 1...9 1 0 1 0 0 0 0 1 1 1 0
R S3 R 1…9 1 0 0 1 0 1 0 1 1 1 1
L S2 L 1…9 0 1 1 0 1 0 0 0 1 1 1
B S1 B 1…9 0 1 0 1 0 0 0 0 0 1 1
Finite State Machine Diagram
Section A and B
Finite State Machine Diagram
Section C
THANKS