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
```#include<reg51.h>
// 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
{
LED=BUZ=1;
}
else           // it means low
{
LED=BUZ=0;
}
}
}
```
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
Hi,

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
http://www.matni.com/Arabic/Elec-Info/LIGHT%20SWITCH/sensor2.htm
it is better way of using LDR

### Information

#### Conversation

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
karpal
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 05:47 PM
sanae
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
Maaz
Wed Sep 20 2017, 12:36 AM
Ted
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
martymarty
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
hello
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

### Recent

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

#### Online

Guests: 54, Members: 0 ...

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

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