Last three lines of my post Malcolm...
Mel,
I've used your example but still can't make the LED go high
The LCD displays 21 as the value for AlarmH1Code:AlarmH1=(RTCHour>>4) AlarmH1=(AlarmH1&$03)*10 AlarmH1=AlarmH1+(RTCHour&$0F) alarmhour = 21 LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":" LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," " LCDOut $FE, $D4,"value = ", # AlarmH1 if AlarmH1 = alarmhour then PORTD.7=1 endif
what am I doing wrong ???
You've set TRIS for PORTD.7 for Output?
You've checked that anything else that share that pin is switched off (eg any Analogue or other devices).
You've connected your LED the correct way around (with a current limiting Resistor) and it works?
Personally I like to use HIGH and LOW... eg...
HIGH PortD.7
eg
If AlarmH1=AlarmHour then
HIGH PortD.7
else
LOW PortD.7
endif
LOL - the LED just went out as the clock turned to 22:00 hrs
The best bit is I've learned more about datasheets through this thread, and some of the pitfalls of my poor coding
Thank you for your patience Mel - I do appreciate it
If HIGH / LOW works, but PORTD.7 = 1 DOESN'T work, that sounds like a sure sign that you don't have your pin correctly set as an output.
Using HIGH or LOW automatically sets the pin as an output first before it sets it high or low
Check your TRIS settings again. PORTD.7 = 1 SHOULD work if the port is set up right....
steve
Thanks Steve... I had the TRISO for port D set so no Idea !
One last thing (for tonight)
I added a section for minutes too and could get the LED to come on at say 22:34 and go out at 22:35.
So I added a a few more variables to try and set a time range but whilst it compiles it no longer lights the LED.Code:AlarmH1=(RTCHour>>4) AlarmH1=(AlarmH1&$03)*10 AlarmH1=AlarmH1+(RTCHour&$0F) AlarmM1=(RTCMin>>4) AlarmM1=(AlarmM1&$03)*10 AlarmM1=AlarmM1+(RTCMin&$0F) AlarmHour1 = 22 Alarmmin1 = 34 LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":" LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," " LCDOut $FE, $D4,"value = ", # alarmh1, #alarmhour1 If AlarmH1 = AlarmHour1 and AlarmM1 = alarmmin1 then HIGH PortD.7 else LOW PortD.7 endif
Any ideas ?Code:AlarmH1=(RTCHour>>4) AlarmH1=(AlarmH1&$03)*10 AlarmH1=AlarmH1+(RTCHour&$0F) AlarmM1=(RTCMin>>4) AlarmM1=(AlarmM1&$03)*10 AlarmM1=AlarmM1+(RTCMin&$0F) AlarmHour1 = 22 Alarmmin1 = 53 alarmhour2 = 22 Alarmmin2 = 55 LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F,":" LCDOut #(RTCSec>>4)&$0F,#RTCSec&$0F," " LCDOut $FE, $D4,"value = ", # alarmh1, #alarmhour1 If AlarmH1 >= AlarmHour1 and AlarmH1 <= alarmhour2 and AlarmM1=>alarmmin1 and alarmM1<= alarmmin2 then HIGH PortD.7 else LOW PortD.7 endif
Hi Malcolm,
I'm wondering if you missed the link I showed in post 11.
I really think that's what you're looking for.
<br>
DT
If I use the LCD to check, I get 21 for both values of AlarmH1 and alarmhour, so the two do match... and I've tried PortB.5 just in case port D wasn't set for output (well it's been along day !)
Code:LCDOut $FE, $D4,"value = ", # alarmh1, #alarmhour
Bookmarks