Created
July 11, 2018 02:34
-
-
Save li2hub/b40c8c228cbc50364af0d21a91b61e35 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
void main() | |
{ | |
TRISB = 0x00; // Sets all pins in PORTB as output | |
PORTB = 0b00000001; // Set RB0 to high 00000001 | |
TRISA = 0x00; // Sets all pins in PORTB as output | |
PORTA = 0b00000000; // Set RB0 to high 00000001 | |
CMCON = 0x07; // To turn off comparators | |
ADCON1 =0x06; //Turne off adc | |
do // To set infinite loop | |
{ | |
Delay_ms(100); // 300 mili seconds delay | |
PORTA = PORTA<<1; //Shifting right by one bit | |
if(PORTA >= 0b10000000) //To reset to 00000001 | |
{ //when the count becomes 10000000 | |
Delay_ms(100); | |
PORTA = 0b00000000 | |
PORTB = 0b00000001 | |
} | |
if(PORTB >= 0b00000001) //If RB7 =1 | |
{ | |
Delay_ms(100); | |
PORTB = PORTB<<1; //Shift one bit right | |
{ | |
if(PORTB >= 0b10000000) //To reset to 00000001 | |
{ | |
Delay_ms(100); // | |
PORTB =0b00000000; //RB low | |
PORTA =0b00000001; | |
} | |
} | |
while(1); // To set infinite loop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment