Last active
December 17, 2021 06:46
-
-
Save Uberi/8378784 to your computer and use it in GitHub Desktop.
Spinning Thing source code for PIC16F684 microcontrollers compiling with MikroC. See ![picture](http://i.imgur.com/gT8NVeR.jpg) for a picture!
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
/* | |
Anthony Zhang | |
Spinning Thing source code for PIC16F684 microcontrollers compiling with MikroC. | |
*/ | |
#define PIN1 PORTA.RA0 | |
#define PIN2 PORTA.RA1 | |
#define PIN3 PORTA.RA2 | |
#define PIN4 PORTC.RC0 | |
#define PIN5 PORTC.RC1 | |
#define PIN6 PORTC.RC2 | |
char values[] = { | |
0b111111, | |
0b001100, | |
0b111111, | |
0b000000, | |
0b111111, | |
0b101101, | |
0b101101, | |
0b000000, | |
0b111111, | |
0b110000, | |
0b110000, | |
0b000000, | |
0b111111, | |
0b110000, | |
0b110000, | |
0b000000, | |
0b111111, | |
0b110011, | |
0b111111, | |
}; | |
int index = 0; | |
void main() { | |
CMCON0 = 0b111; // comparator configuration | |
ANSEL = 0; // use digital I/O | |
TRISA = 0x00; // PORTA as output | |
TRISC = 0x00; // PORTC as output | |
while (1) { | |
if (index == sizeof(values)) | |
index = 0; | |
if (index == 0) { | |
PIN1 = PIN2 = PIN3 = PIN4 = PIN5 = PIN6 = 0; | |
delay_ms(40); | |
} | |
PIN1 = values[index] & 1; | |
PIN2 = (values[index] >> 1) & 1; | |
PIN3 = (values[index] >> 2) & 1; | |
PIN4 = (values[index] >> 3) & 1; | |
PIN5 = (values[index] >> 4) & 1; | |
PIN6 = (values[index] >> 5) & 1; | |
index ++; | |
delay_ms(3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment