81. MATRIZ DE LEDS 1A PARTE ****PIC16F887*****
Introduction to LED Matrix
In this section, the speaker introduces the concept of working with LED matrices in relative addressing mode. The LED matrix used for demonstration is a 8x8 red LED matrix model 1088A.
Working with LED Matrices
- An 8x8 LED matrix consists of 64 LEDs connected internally.
- LEDs can be controlled by rows or columns.
- Rows can be controlled using transistors that allow current flow towards the reference voltage.
- Columns require limiting resistors to control the current flow through each column.
- Careful attention must be paid to connections between rows and columns.
Controlling an LED Matrix
- To control an LED matrix, saturate the transistor corresponding to the row you want to light up.
- Use limiting resistors on each column to control current flow through each column.
- Use a buffer circuit or integrated circuit with open collector output for more efficient control.
Tips for Working with an LED Matrix
- Use appropriate limiting resistors on each column to ensure stable current flow through each column.
- Pay careful attention to connections between rows and columns when wiring an LED matrix.
Calculating LED Current
In this section, the speaker discusses how to calculate the current that would flow through an LED.
LED Current Calculation
- The voltage drop across a red LED is approximately 1.8 volts.
- To calculate the current, subtract the voltage drop from the supply voltage (5 volts in this case), which gives 3.2 volts.
- Divide this by the resistance of the circuit (3000 ohms in this case).
- This results in a relatively high current.
Controlling LEDs with Code
In this section, the speaker demonstrates how to control LEDs using code.
Diagonal LED Control Code
- The first example code will turn on one LED at a time and move diagonally across rows and columns.
- The program will activate each row by setting it low and then set individual data bits for each column to turn on specific LEDs.
- The program uses bit shifting to move through each column and row.
Setting Ports as Outputs
- Before running any code, it's important to set all necessary ports as outputs or inputs.
- Use bs.f estatus command to change bank status for output ports.
Initializing Data Ports
In this section, the speaker explains how to initialize data ports before running any code.
Initializing Data Ports
- All ports are initially set to zero when starting a program.
- To avoid turning on all rows at once, make sure that both data and row ports are initialized as zero before running any code.
- Use bs.f estatus command followed by complementing port values with c_port_w command.
Setting a Time of 500 Milliseconds
In this section, the speaker discusses setting a time of 500 milliseconds.
Setting Values for Subroutine
- The values 79, 3, and 253 are used to call the subroutine.
- These values are constructed into three variables.
- The values are in decimal.
Recurring Until Carry is Gone
In this section, the speaker discusses recurring until carry is gone.
Clearing Carry
- If carry is active, it will be cleared.
- This ensures that the program does not get stuck in an infinite loop.
Moving to Left Side of Port Cortez
- The program moves to the right side of port cortez and saves it in port Y.
- It checks if carry is active because it wants to avoid getting stuck at half a second on carry.
- If carry is active, it clears it and places one in port zero.
Complementing Port Y
- If there's no carry yet, then complement port Y and pass it through port V.
- Then go back to clearing carry again.
Assembling Code and Testing
In this section, the speaker assembles code and tests it.
Assembling Code
- The first errors encountered are syntax errors.
- After fixing these errors, any remaining errors would be programming-related.
Testing Code
- The speaker has connected resistors to ports A and B for testing purposes.
- There are some strange delays due to simulation issues but they don't affect functionality.
- LED lights can be controlled properly with this code.