Discussion in "8051 Discussion Forum" started by    SkyTerror17    Sep 26, 2011.
Mon Sep 26 2011, 06:51 AM
Hi guys,
My project is a medical reminder and dispenser system.
So I am planning to use LDR to act like a switch to send a high or low to a 8051 pin with only just my circuit.
My main idea was to use sbit to turn off a buzzer and LED when it is low and turn on a buzzer and LED when it is high.

I need help for the programming codes as I am bad at it.
Any help or tips would be greatly appreciated!

[ Edited Mon Sep 26 2011, 06:55 AM ]
Mon Sep 26 2011, 07:56 AM
sbit is used in c it means u want to do coding in c
// let say pins are as i suppose
sbit LDR = P1^0;
sbit LED = P1^1;
sbit BUZ = P1^2;

void main (void)
BUZ=LED=0;  // off the buzzer and led at start up
while(1)         // forever loop
if(LDR==1)   // if high
else           // it means low
Mon Sep 26 2011, 03:32 PM
Oh ya, I wanna code in with C programming, forgotten to mention it!
Alright, thanks for the help! I will give it a shot and update you about it!
Sun Oct 02 2011, 12:35 PM
We are waiting for update..
Tue Oct 04 2011, 02:48 AM
Just got back from a school overseas industrial visit, sorry for not updating!
Apparently, I am having some trouble to allow the LDR to communicate with the 8051, as the LDR is analog while 8051 is digital.
So I am finding a way to convert the analog signal to digital as they cant communicate directly.
The LED has 2V when high, 1.5V when low.
While my LDR has 0.7V when high, 0.5V when low.
And I am figuring how to adjust the LED port to 3.3V at the moment.

[ Edited Tue Oct 04 2011, 03:10 AM ]
Tue Oct 04 2011, 05:23 AM
@ SkyTerror17
u can use op amp LM741 as a comparator
Tue Oct 04 2011, 06:35 AM
Alright, am trying it now. But judging from my current schematic, I need to replace the LM741 with the 2N3904 transistor?
Tue Oct 04 2011, 06:43 AM

There is also an exmple project here for LDR and 8051..

Tue Oct 04 2011, 07:30 AM
Is there any single supply op amp that you guys could recommend?
Tue Oct 04 2011, 07:32 AM
u can use LDR as
it is better way of using LDR

Get Social


Powered by e107 Forum System


Wed Nov 08 2017, 01:35 PM
Anirudh jain
I want to burn code in atmel 89s51 24pc 0329 but cannot get the connection with the burner. Can somebody provide me with the circuit diagram for connecting controller to burner. I'm using usb burner
Thu Nov 02 2017, 11:44 AM
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 05:47 PM
i am using the DHT11 but i'm getting some errors in the simulate the programe in proteus 8 professional,: 1)cannot find model file 'DHTXX.MDF'.2)simulation failed due to netlist linker error(s).
Fri Sep 29 2017, 02:45 AM
i am doing the same project on verilog please contact me [email protected]
Wed Sep 20 2017, 12:36 AM
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 02:29 PM
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
Sun Aug 20 2017, 10:23 AM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
Sun Aug 20 2017, 10:22 AM
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem



Mon Nov 20 2017, 07:40 PM
Sun Nov 19 2017, 07:34 PM
Wed Nov 15 2017, 10:46 AM
Sat Nov 11 2017, 03:43 AM
Fri Nov 10 2017, 06:53 AM
Wed Nov 08 2017, 05:27 PM
Tue Nov 07 2017, 09:08 AM
Sat Nov 04 2017, 10:46 PM


Guests: 54, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37918
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 20 2017, 10:18 PM
Here is a version of the tutorial that reads a key...
Ansh12 Avatar
Posted By Ansh12
Mon Nov 20 2017, 02:15 AM
As a starting point, can you tell us how much of t...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Nov 19 2017, 08:35 PM
As a starting point, can you tell us how much of t...
Ansh12 Avatar
Posted By Ansh12
Fri Nov 17 2017, 04:07 AM
I am looking keypad interfacing program. I was rea...
JardCrocker Avatar
Posted By JardCrocker
Wed Nov 08 2017, 05:29 PM
Hi...i am a new user here. I was also facing the s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 07 2017, 07:13 PM
> It employs a fairly advanced technique to detect...
vivitern Avatar
Posted By vivitern
Tue Nov 07 2017, 09:33 AM
I own a used Clavia ddrum4 SE drum module. It empl...
bvdb Avatar
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...