Discussion in "8051 Discussion Forum" started by    SkyTerror17    Sep 26, 2011.
Mon Sep 26 2011, 06:51 AM
#1
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
#2
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
#3
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
#4
We are waiting for update..
Tue Oct 04 2011, 02:48 AM
#5
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
#6
@ SkyTerror17
u can use op amp LM741 as a comparator
Tue Oct 04 2011, 06:35 AM
#7
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
#8
Hi,

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

http://romelemperado.blogspot.com/2011/08/inout-door-counter-with-nokia-3310-lcd.html
Tue Oct 04 2011, 07:30 AM
#9
Is there any single supply op amp that you guys could recommend?
Tue Oct 04 2011, 07:32 AM
#10
u can use LDR as
http://www.matni.com/Arabic/Elec-Info/LIGHT%20SWITCH/sensor2.htm
it is better way of using LDR

Get Social

Information

Powered by e107 Forum System

Conversation

rawat742
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 01:45 PM
angel patel
hey any one help to make the led scrolling display
desuza6
Sat Jul 29 2017, 07:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
rammichael
Thu Jul 27 2017, 12:05 PM
okay fine
ExperimenterUK
Wed Jul 26 2017, 07:51 PM
Please post questions in the forum, the chat box is for chat
msd007
Wed Jul 26 2017, 11:27 AM
i need code if any one have aduc706 interfacing lcd 16*2
msd007
Wed Jul 26 2017, 11:26 AM
pl help me how to write code of interfacing ADuc7026 controlleo lcd pl any one help me hoe to initializend configure the direction
rammichael
Wed Jul 26 2017, 06:04 AM
can you explain what is timer and how to use their modes ...
rammichael
Wed Jul 26 2017, 06:03 AM
ExperimenterUk thank you for your quick reply okay

Downloads

Comments

Pirateak
Thu Aug 17 2017, 02:02 PM
sathishksk71
Wed Aug 16 2017, 04:47 AM
rawat742
Sun Aug 13 2017, 05:49 PM
alparslanbagriyanik
Fri Aug 11 2017, 08:10 AM
Thanhquan
Sat Aug 05 2017, 05:17 PM
NAMRATHA
Thu Aug 03 2017, 08:32 AM
Kgj
Tue Aug 01 2017, 12:41 PM
Ingketech
Sun Jul 30 2017, 01:03 PM

Online

Guests: 56, Members: 0 ...

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

Members: 37878
Newest member: Pirateak
Forum Activity
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:45 AM
LCD SCROLLING MESSAGE PROGRAM CODE AND SIMULATION...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:24 AM
Dear Sir , I am not able to increased value by pre...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:19 AM
Dear Sir, as per your attachment I w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Aug 17 2017, 10:54 PM
Try this. Attachment ...
rawat742 Avatar
Posted By rawat742
Thu Aug 17 2017, 08:24 PM
Dear Sir , Please help me for stor...
sathishksk71 Avatar
Posted By sathishksk71
Wed Aug 16 2017, 04:53 AM
Hi.. Iam refreshing c language using this useful r...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 14 2017, 10:19 PM
The original 8051 is a primitive device.Over the ...
rawat742 Avatar
Posted By rawat742
Mon Aug 14 2017, 06:52 AM
Dear sir, First of all i want to thanks to you fo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Aug 13 2017, 11:25 PM
Reading page 11 of the data sheet, it is not clear...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Aug 13 2017, 11:11 PM
The basic 8051 has no eeprom and you can't reprogr...