' One push Horn & Hazard Switch ' Programed by Mar-neko program HAZHORN dim bHazard as byte dim bHorn as byte dim bCnt as byte dim wHazInt as word dim wHornInt as word dim wDelay as word ' Wait Timer ' Function delay_ms(word) cause Error with Not Literal sub procedure DelayTime (dim wDelayTime as word) while wdelaytime > 1 delay_ms(1) wDelaytime = wDelaytime - 1 wend end sub main: CMCON = %00000111 ' No Use Comparetor TRISIO = %00111100 ' GP5,4,3,2 in Input GP1,0 is Output ANSEL = %01001100 ' Fosc/4 , ANS3(pin3),ANS2(pin5) is Analog Port GPIO = %00000000 ' All I/O is Off loop1: bHorn = 0 bHazard = 0 bCnt = 0 wDelay = 0 while true if GPIO.5 = 0 then ' push hazerd bHazard = inc(bHazard) 'bHazard = 1 end if while GPIO.5 = 0 wend if GPIO.3 = 0 Then ' push horn bHorn = inc(bHorn) 'bHorn = 2 end if while GPIO.3 = 0 wend delay_ms(10) if (bHazard > 0) Or (bHorn > 0) Then bCnt = inc(bCnt) if bCnt >= 80 Then bCnt = 0 goto loop2 end if end if wend loop2: Delay_ms(20) wHazInt = ADC_Read(3) Delay_ms(20) wHornint = ADC_Read(2) Delay_ms(20) if (bHazard > 0) Then wDelay = 0 wDelay = wHazInt * 4 GPIO = %00000010 DelayTime(wDelay) GPIO = %00000000 end if if (bHorn > 0) Then for bCnt = 1 to bHorn wDelay = 0 wDelay = wHornInt GPIO = %00000001 DelayTime(wDelay) wDelay = 0 wDelay = wHornInt * 2 GPIO = %00000000 DelayTime(wDelay) next bCnt end if goto main end.