5v relay and IR sensor interface 8051
What is Relay, IR sensor interface with 8051?
The relay is a switch like our home switch using light, fan, TV etc., single channel relay to use Light or fan or TV.
Relay Function:
Inside the relay have coil, low power circuit to operate high volts, it generates magnet filed then its Open and Close the relay.
It required diodes 1n4007, resistor and transistor BC547 or BC548. when giving power supply 5v need transistor BC547 or 12v to relay need ULN drivers for 4 channel relays. Remember need to see amps like 10amp, 20amp or 30amp, it will give lifetime to use.
![]() |
| 5v 30Amp single channel Relay |
If you want to do Relay project to ON and OFF the Light, then need to do that first prepare C code in Embedded language. By using Keil C51 software to do program in it. When doing the project need to concentrate the pins of microcontroller and resistors. use resistors like 1k, 220ohms or 330ohms.
When connection relay to microcontroller 8051 need BC547 transistor, it has three terminals one is Vcc, GND and output pin. based on requirement need to connect 5v to Vcc, Gnd and output pin its microcontroller in between put transistor middle pin. 1st pin is Vcc, 2nd pin connect to microcontroller or Arduino uno and 3rd pin is Gnd.
IR sensor Function:
IR sensor is an infra-red rays led, to detect the object or human hand it detects the light rays, how it reflects the rays, if happens any object, its Active if not No signal.
You can use it for counting seeds or apples with plenty, it's helpful the IR sensor. It's also had power supply 5v or 3.3v, GND and output pin.
![]() |
| IR sensor with Adjust frequency |
It's also had Embedded C code by using Microcontroller or Arduino uno just change the pins or delay, need 2x16 LCD display.
You can adjust the frequency distance like 2cm to 5cm of IR sensor. You can do project on it to count the seeds.
If you want to know about 8051 microcontrollers, click it and 8051 Flash programmer of 8051 click it. We clearly given the topic on it.
Conclusion:
As per my understanding about the IR sensor and Relay, if you want clear understanding just to LED blink ON and OFF. just edit the program like Sbit LED = P1^0; change it as Sbit Relay =P1^0; You will get simple C code from internet by using Embedded C code of Light ON and OFF.


What is diode value?
ReplyDeleteA. 1n4007
B. 1n5002