


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Christian Noel Eslit BCA151 B Laboratory 3 #include<reg52.h> sbit OUT0 = P1^3; sbit OUT1 = P1^4; sbit OUT2 = P1^5; sbit OUT3 = P1^6; sbit OUT4 = P1^7; void delay1() { unsigned char m; TR0 = 0; for(m=0; m<30; m++) { TH0 = 60; TL0 = 176; TF0 = 0; TR0 = 1; while(TF0==0); TR0 = 0; } } void delay2() { unsigned char m; TR0 = 0; for(m=0; m<50; m++)
while(TF0==0); TR0 = 0; } } void main() { unsigned char x; TMOD = TMOD & 0xF0; TMOD = TMOD | 0x01; P1 = 0x03; while(1) { x = P1 & 0x03; switch(x) { case 0x00: OUT0 = 1; OUT1 = 1; OUT2 = 1;
delay2(); OUT0 = 0; OUT1 = 0; OUT2 = 0; OUT3 = 1; OUT4 = 1; delay2(); break; case 0x03: OUT0 = 0; OUT1 = 0; OUT2 = 0; OUT3 = 0; OUT4 = 0; } } }