You are on page 1of 8

Challenge 1

Microcontrollers Lab

Leonardo Valencia Benitez


Ángel Omar Medrano Castro
How the system works
Inputs
First part: dip-switch combinations.
Second part: string with the direction and the time it must follow each direction.

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:

Dip switch(Inputs) Motors(Outputs) Display(Outputs)


PA8 PA7 PA6 PB11 PB10 PB9 PB8 PD15 PD14 PD13 PD12 PD11 PD10 PD9
S 0 x x 0 0 0 0 0 0 1 0 0 1 0
F 1 0 1 1 0 1 0 0 0 0 1 1 1 0
R 1 1 0 1 0 0 1 0 1 0 1 1 1 1
L 1 1 1 0 1 1 0 1 0 0 0 1 1 1
B 1 0 0 0 1 0 1 0 0 0 0 0 1 1
States Table
Second part:

String (Input) Motors (Outputs) 7-segment display (Outputs)

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

You might also like