Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to set a alarm for my real tiime clock?

Status
Not open for further replies.
Better yet, do this. Keep the buzzer on RA4. Type "buzzer=1;" in the main() function directly below "led_yellow=0;". So it looks like this:
Code:
...
led_white=0;					//led white off
led_yellow=0;					//led yellow off
buzzer=1;
...
If that makes the green LED turn on, then it's a software problem. If it doesn't turn on, it's a hardware problem.
 
Yep, seems like it's broken. Try using another pin on PORTA, since you already have all the pins of PORTA setup as digital output. Better yet, put in a new PIC if you have one.
 
Ok Rusttree.I will try it later.Thanks for your help.Will update my progress after I try.Thanks for the helps Rusttree.:)
 
Last edited:
Just to save you some grief, look in the data sheet. I think you are using a 16F877A chip?
from the data sheet:

RA4/T0CKI/C1OUT
RA4
T0CKI
C1OUT

Digital I/O – Open-drain when configured as output.
Timer0 external clock input.
Comparator 1 output.
 
Just to save you some grief, look in the data sheet. I think you are using a 16F877A chip?
from the data sheet:

RA4/T0CKI/C1OUT
RA4
T0CKI
C1OUT

Digital I/O – Open-drain when configured as output.
Timer0 external clock input.
Comparator 1 output.
Ya.I'm using pic16f877a.Ok.I got what you mean.Thanks.
 
Rusttree,now my alarm can activate already.I change the pin to RC5. I have found that when the alarm time is reached, the buzzer is ringing continuously and won't stop. So can I know how to write the code for a push button to stop the alarm?Hope to see you reply soon.Thanks.:)
 
I'm glad you got the buzzer working. Thanks, BeeBop, for pointing out the open-drain note.

I'm more than willing to continue helping you develop your project, but you do need to at least attempt to figure things out on your own first. Using buttons with microcontrollers is very common. Spend a few minutes on Google and see what you can come up with. I bet there are tutorials specifically for interfacing buttons to a PIC. Then post here specific questions or concepts you need help with.
 
I have tried to do just now.I'm using a sensor as a switch,it is a infrared sensor,it can also call as motion sensor.This sensor I used is pretty easy,I just need to set the motion=1; or motion=0; will do.But it is not stable.And I don't know the way I write is it wrong or not.
Can you correct me?I have written it at "Read RTC funtion" there.Thanks.
 

Attachments

  • alarm.c
    15.1 KB · Views: 140
So your infrared sensor has a digital output? Not analog?

Two things:
1. You have a typo on the line "else if (motion=0)". That comparison needs the double-equal sign, not single.

2. Think about that if-statement:
Code:
if ((clkmin==alarmMin) && (clkhrs==alarmHrs) && (buffer==0))
When your hand is near the motion sensor, buffer will be 1, which turns off the buzzer. But as soon as you move your hand away, buffer goes back to 0. The minutes and hours will still be equal for a whole 60 seconds. So the buzzer will turn right back on again. You don't want the buzzer to ever turn back on again, so you want buffer to stay equal to 1 even after you move your hand away. How would you prevent buffer from equaling zero again?
 
Rusttree,the motion sensor I'm using is like passive infrared sensor.The sensor got 3 wires and two of the wires is connected to 5V and ground and another is just goes to the PIC.So now I would like the sensor to turn off the buzzer once the motion sensor==1,can I know where to put it?Thanks a lot Rusttree.
 
Looks like it's a digital sensor. Just to be sure, plug it in and put your multimeter on the signal line. As you move your hand near it, the voltage on the signal line should jump from 0V to VDD. If it displays any voltages between the two, it's an analog sensor.

Assuming it's digital, go back to my post #52 above. You've almost got the code correct. You just need to change one part.
 
Ok.So the part I need to change is prevent the buffer from equaling zero again and else if (motion==0)?Can I know where to put the code then that's right?Is it the way I put?At "Read RTC function" there?
 
Rusttree,the sensor I'm using is analog sensor after I tested it with the multimeter So the coding I wrote is inccorect? Can I know the part I need to change is what?Besides,where to put the coding?I put it at "Read RTC function" there,I'm afraid that maybe it will affect the alarm.Just now I have make the correction for "else if (motion==0)".After I try it,I found that when the alarm is activated,when my hand is near to the sensor the buzzer stops to ring but when my hand is away from the sensor the buzzer rings again.Can I know how to make the correction for the code?Thanks.:)
 
Last edited:
The range of voltage is in between 0V to 4V.The voltage shown on multimeter is 3 point something and almost 4V.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top