Created
April 10, 2019 06:33
-
-
Save faraazahmad/874e959ea27fa3b13b798d7c19a16611 to your computer and use it in GitHub Desktop.
ir sensor array
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 <LCD.h> | |
#include <stdio.h> | |
sbit IR1=P1^0; | |
sbit IR2=P1^1; | |
sbit IR3=P1^2; | |
sbit IR4=P1^3; | |
sbit IR5=P1^4; | |
// intuitive code | |
void timer_delay() /* Timer0 delay function */ | |
{ | |
TH0 = 0x00; /* Load higher 8-bit in TH0 */ | |
TL0 = 0x00; /* Load lower 8-bit in TL0 */ | |
TR0 = 1; /* Start timer0 */ | |
while(TF0 == 0); /* Wait until timer0 flag set */ | |
TR0 = 0; /* Stop timer0 */ | |
TF0 = 0; /* Clear timer0 flag */ | |
} | |
void main() | |
{ | |
char l1, l2, l3, l4, l5; | |
char str[50]; | |
TMOD = 0x01; /* Timer0 mode1 (16-bit timer mode) */ | |
LCD_INIT(); | |
LCD_WRITE("1 2 3 4 5", 0, 0); | |
while(1) { | |
l1 = IR1 ? 'D' : 'N'; | |
l2 = IR2 ? 'D' : 'N'; | |
l3 = IR3 ? 'D' : 'N'; | |
l4 = IR4 ? 'D' : 'N'; | |
l5 = IR5 ? 'D' : 'N'; | |
sprintf(str, "%c %c %c %c %c", l1, l2, l3, l4, l5); | |
LCD_WRITE(str, 1, 0); | |
timer_delay(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment