summaryrefslogtreecommitdiff
path: root/electronics/asm/test.asm
blob: 38ca537e8a7579c79f976973c57843ed52e7b78e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
start: 
init: 
	clrf    PORTA          	; make sure port A output latches are low 
	bsf     STATUS,RP0     	; select memory bank 1 
	movlw 	b'11111111'    	; set port A data direction to inputs 
	movwf   TRISA         
	movlw   b'00000000'    	; set port B data direction to outputs 
	movwf   TRISB          
	bcf     STATUS,RP0     	; select memory bank 0 

	bsf	INTCON, INT0IE
	bsf	INTCON, GIE

	rawtemp EQU B6
	countdown EQU B7

	movlw	5	
	movwf	countdown

	movlw 	0

	goto    main 

interrupt:
	clrf    PORTB          	; clear PORTB
	goto 	start		; restarts the program

beep:				; a for loop that beeps a buzzer and turns on a led then sets a led on
				; if nothing is done

	bsf	PORTB, 0	; put a RED LED on PORTB:0
	bsf	PORTB, 1	; put a BUZZER on PORTB:1
	call 	wait1000ms
	bcf	PORTB, 0
	bcf	PORTB, 1
	call	wait1000ms

	decfsz	countdown, F
	goto	beep
	
	bsf	PORTB, 2	; put an AMBER LED on PORTB:2

	goto 	start	
main: 				; reads the temprature
	call 	readadc1 	; put a THERMISTOR on PORTA:1
	movf	B1, W
	movwf	rawtemp
				
	call	readadc0	; put a POT on PORTA:0	
	movf	B0, W

	subwf	rawtemp, w	; subtract the from the threshold value
	btfss	STATUS, 0 	; if higher than desired temp
	goto 	beep		; ^	

	clrf	STATUS

	goto 	main

	END		       	; ends the program