Simple question about "Sound" command
Hi !
I made one thermostat, with PIC16F628A and LCD display, for using as thermo-regulator. All works fine, but ... I want to have an audible "mark" when temperature is bigger/smaller than setting.
I wrote this :
Code:
If Temperature > Temp_Up then ' Above Target temperature
PORTA.2=0 ' Deactivate Warm output
PORTA.3=1 ' Activate Cold Output
SOUND PortA.7, [107,50]
EndIf
But in this way the buzzer sound WHILE Temperature > Temp_Up :( ... How can be setting to sound just 5 seconds, for example ?
Thanks in advance !
Re: Simple question about "Sound" command
I'm thinking this must be in a larger loop structure to keep returning to the routine.
How about this as an idea only:
Code:
If Temperature > Temp_Up then ' Above Target temperature
PORTA.2=0 ' Deactivate Warm output
PORTA.3=1 ' Activate Cold Output
SOUND PortA.7, [107,50]
temp_up = temp_up +5 'or 10 or whatever
endif 'as long as reset elsewhere
Re: Simple question about "Sound" command
You need a flag to remember that you've already sounded the alarm.
Code:
AlarmDone VAR BIT
IF Temperature > TempUp THEN
PortA.2 = 0
PortA.3 = 1
IF AlarmDone = 0 THEN ' Only activate alarm if not already activated.
SOUND PortA.7, [107, 50]
AlarmDone = 1 ' Alarm has been activated.
ENDIF
ELSE
AlarmDone = 0 ' Temperature is not over the limit, rearm the alarm.
ENDIF
Re: Simple question about "Sound" command
Thanks for reply !
The second variant work verry fine. THANK YOU, Mr.Henrik ! As usual, You're a Great Gentleman !