jepoy12
Junior Member level 3
Im making a remote dtmf switch using a 89s52 uC. using the dtmf 4bit output to switch on the device through relay.
Im using bascom IDE(only know the basic) and heres my program. after burning it, I tried to run the circuit and the result was failure. all relays go high already and I havent press any number keys yet.
Can someone help with my code? I dont know what to do. : (
Im using bascom IDE(only know the basic) and heres my program. after burning it, I tried to run the circuit and the result was failure. all relays go high already and I havent press any number keys yet.
Can someone help with my code? I dont know what to do. : (
Code:
Q1 Alias P1.0 'DTMF input
Q2 Alias P1.1
Q3 Alias P1.2
Q4 Alias P1.3
Relay1 Alias P2.0 'microcontroller output
Relay2 Alias P2.1
Relay3 Alias P2.2
Buzzer Alias P0.0 'buzzer output
Relayled Alias P0.1 'Led output
Const Dur_on = 1000 'buzzer duration and freq.
Const Freq_on = 90
Const Dur_off = 100
Const Freq_off = 90
Do
If Q4 = 0 And Q3 = 0 And Q2 = 0 And Q1 = 1 Then 'if dtmf output is 0001 or key num "1" is pressed
Relay1 = 1 'relay1 switch on
Sound Buzzer , Dur_on , Freq_on
Wait 1
Buzzer = 0
Relayled = 1
Elseif Q4 = 0 And Q3 = 0 And Q2 = 1 And Q1 = 0 Then 'if dtmf output is 0010 or key num "2" is pressed
Relay2 = 1 'relay2 switch on
Sound Buzzer , Dur_on , Freq_on
Wait 1
Buzzer = 0
Relayled = 1
Elseif Q4 = 0 And Q3 = 0 And Q2 = 1 And Q1 = 1 Then
Relay3 = 1
Sound Buzzer , Dur_on , Freq_on
Wait 1
Buzzer = 0
Relayled = 1
Elseif Q4 = 0 And Q3 = 1 And Q2 = 0 And Q1 = 0 Then 'if dtmf output is 0100 or key num "4" is pressed
Relay1 = 0 'relay1 switch off
Sound Buzzer , Dur_off , Freq_off
Wait 1
Buzzer = 0
Relayled = 0
Elseif Q4 = 0 And Q3 = 1 And Q2 = 0 And Q1 = 1 Then 'if dtmf output is 0101 or key num "5" is pressed
Relay2 = 0 'relay2 switch off
Sound Buzzer , Dur_off , Freq_off
Wait 1
Buzzer = 0
Relayled = 0
Elseif Q4 = 0 And Q3 = 1 And Q2 = 1 And Q1 = 1 Then
Relay3 = 0
Sound Buzzer , Dur_off , Freq_off
Wait 1
Buzzer = 0
Relayled = 0
End If
Loop
End
Last edited: