Last active
March 23, 2017 15:52
-
-
Save Ravensgun/8b04f9497fb19dbc0bb149b41be02152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <inttypes.h> | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
#include <avr/sleep.h> | |
#include <util/delay.h> | |
int main() | |
{ | |
int raw[8] = {0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b00000,0b11111}; // matriz das linhas | |
int i=0; // contador do DS | |
int j=0; // contador do SC e SD | |
int k=0; // sem uso | |
DDRD =0xff; | |
DDRC =0xff; | |
DDRB =0xff; | |
while (1) | |
{ | |
i++; | |
j++; | |
PORTB = raw[i]; // rodar a matriz de linha | |
// clock do DS | |
if(i>=17){ | |
i=0; | |
} | |
if (i==16) // com 16 ele faz uma varredura dupla | |
{ | |
PORTC =0xff; // ta habilitando todos os DS | |
i=0; | |
} | |
if (i==1) | |
{ | |
PORTC = 0x00; // Zerando todos os DS | |
} | |
// aqui seria o MR, mas nao ta funcionando | |
if(k>=4){ | |
k=0; | |
} | |
// con3 aqui ta o SH e SC, coloquei de forma que ficasse 50/50 | |
if(j>=20){ | |
j=0; | |
} | |
if (j==10) | |
{ | |
PORTD = 0x03; | |
j=0; | |
} | |
else | |
{ | |
PORTD = 0x00; | |
} | |
} | |
; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment