Skip to content

Instantly share code, notes, and snippets.

@faraazahmad
Created February 6, 2019 06:11
Show Gist options
  • Save faraazahmad/a1bc63ff2134adcb6dd278f79d520744 to your computer and use it in GitHub Desktop.
Save faraazahmad/a1bc63ff2134adcb6dd278f79d520744 to your computer and use it in GitHub Desktop.
Embedded lab #3
#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