hi, how are you today

Let's learn how to interface a MOC sensor with our baby (8051uC)
For enhance concept just visit www.salahtutorials.com

Let's learn how to interface a MOC sensor with our baby (8051uC)
Description
This article helps you to understand the concept behind the interfacing of MOC(Motorola Opto Coupler). It basically consists of IR(Infra-red) transmitter and a photo-diode. Normally Photo-diode continuously receives the signal form IR transmitter, the moment between any obstacle inside the sensor, photo-diode stops receiving the IR from IR Transmitter and transmits a low pulse. We have to read that low pulse and have to make logic , what we have to control as an output device.Programming
1: #include<reg51.h> // header file
2: void delay(int time) // function to generate delay
3: {
4: int i,j;
5: for(i=0;i<=time;i++) // i will run from 0 to user defined value
6: for(j=0;j<=1275;j++); // j will run from 0 to 1275 "time" times
7: }
8: sbit sensor=P3^0;
9: sbit led=P3^1;
10: /*if sensor transmits high pulse*/
11: void main() // main function
12: {
13: led=0; // setting led initially off
14: sensor=0;// putting sensor pin to 0 so that we can read high pulse
15: while(1) // while(1)used to provide continous loop
16: {
17: if(sensor==1) // if sensor provides high input
18: {
19: led=1; // light will be on
20: delay(200) // light will remain on for this specified delay
21: led=0; // light will off and again on when sensor will be 1
22: }
23: }
24: }
For enhance concept just visit www.salahtutorials.com
Hope you all like this post and I wish this must be useful for you.
Thanks :)
Comments
Post a Comment