Created
February 6, 2019 06:11
-
-
Save faraazahmad/a1bc63ff2134adcb6dd278f79d520744 to your computer and use it in GitHub Desktop.
Embedded lab #3
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 <p89v51rx2.h> | |
void delay(unsigned int dela) | |
{ | |
unsigned int i,j; | |
for(i=0;i<=1000;i++) | |
for(j=0;j<=dela;j++); | |
} | |
sbit l1 = P3^0; | |
sbit l2 = P3^1; | |
sbit l3 = P3^6; | |
sbit l4 = P3^7; | |
void main() { | |
int count = 0; | |
int tmp; | |
l2 = l3 = l4 = 1; | |
while(1) | |
{ | |
delay(250); | |
count = (count + 1) % 16; | |
tmp = count; | |
l4 = !(tmp % 2); | |
tmp /= 2; | |
l3 = !(tmp % 2); | |
tmp /= 2; | |
l2 = !(tmp % 2); | |
tmp /= 2; | |
l1 = !(tmp % 2); | |
tmp /= 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment