final.asm (1290B)
1 start: 2 init: 3 clrf PORTA ; make sure port A output latches are low 4 clrf PORTB 5 bsf STATUS, RP0 ; select memory bank 1 6 7 movlw b'11111111' ; set port A data direction to inputs 8 movwf TRISA 9 movlw b'00000000' ; set port B data direction to outputs 10 movwf TRISB 11 bcf STATUS,RP0 ; select memory bank 0 12 13 ;bsf INTCON, INT0IE 14 ;bsf INTCON, GIE 15 16 rawtemp EQU B6 17 countdown EQU B7 18 19 movlw 5 20 movwf countdown 21 movlw 0 22 23 goto main 24 25 beep: ; a for loop that beeps a buzzer and turns on a led then sets a led on 26 ; if nothing is done 27 28 bcf PORTB, 3 ; turn off the status 29 bsf PORTB, 0 ; put a RED LED on PORTB:0 30 bsf PORTB, 1 ; put a BUZZER on PORTB:1 31 call wait1000ms 32 bcf PORTB, 0 33 bcf PORTB, 1 34 call wait1000ms 35 36 decfsz countdown, F 37 goto beep 38 39 bsf PORTB, 2 ; put an AMBER LED on PORTB:2 40 41 goto main 42 43 main: ; reads the temprature 44 bsf PORTB,3 ; put a GREEN LED for status on PORTB:3 45 46 call readadc1 ; put a THERMISTOR on PORTA:1 47 movf B1, W 48 movwf rawtemp 49 50 call readadc0 ; put a POT on PORTA:0 51 movf B0, W 52 53 subwf rawtemp, w ; subtract the from the threshold value 54 btfss STATUS, 0 ; if higher than desired temp 55 goto beep ; ^ 56 57 clrf STATUS 58 59 goto main 60 61 END ; ends the program