79 lines
1.7 KiB
Plaintext
79 lines
1.7 KiB
Plaintext
' ########### start ###########
|
|
' avr:tiny13
|
|
' ########### end ###########
|
|
'
|
|
' ******************************************************************
|
|
' A program to show the temperature level
|
|
' 2025-10-09 (c) Paolo Iocco
|
|
' ******************************************************************
|
|
'
|
|
' Circuit diagram
|
|
' ---------------
|
|
' ATtiny 13/45/85 Pin map
|
|
' +--\/--+
|
|
' +5V>--/Reset---|1° 8|---Vcc--<+5V
|
|
' -|2 7|-
|
|
' PTH>--ADC2-PB4-|3 6|---PB1--> LED R
|
|
' GND>-----GND---|4 5|---PB0--> LED G
|
|
' +------+
|
|
'
|
|
' -------------------------------------------------------------
|
|
' 9.6MHz:
|
|
' LFuse: 0x7A; HFuse: 0x1F;
|
|
' AVRDude: avrdude -B 10 -c USBasp -p attiny13 -U lfuse:w:0x7a:m -U hfuse:w:0x1f:m
|
|
'
|
|
' ******************************************************************
|
|
|
|
' Chip model
|
|
#chip tiny13, 9.6
|
|
#define ledR PORTB.0
|
|
#define ledG PORTB.1
|
|
#define ledB PORTB.3
|
|
#define PTH PORTB.4
|
|
|
|
#define S0 107
|
|
#define S1 108
|
|
#define S2 134
|
|
#define S3 159
|
|
|
|
dir ledG out
|
|
dir ledR out
|
|
dir ledB out
|
|
|
|
'Startup routine
|
|
Startup:
|
|
SET ledG OFF
|
|
SET ledR OFF
|
|
set ledB OFF
|
|
|
|
'Main routine
|
|
Loop:
|
|
'Read temperature
|
|
'temp=ReadAD(ADC2)
|
|
temp=ReadAD(PTH)
|
|
|
|
if temp < S1 then
|
|
set ledB ON
|
|
SET ledG OFF
|
|
SET ledR OFF
|
|
end if
|
|
if (temp > S1) and (temp <S2) then
|
|
set ledB OFF
|
|
SET ledG ON
|
|
SET ledR OFF
|
|
end if
|
|
if (temp > S2) and (temp <S3) then
|
|
set ledB OFF
|
|
SET ledG ON
|
|
SET ledR ON
|
|
end if
|
|
if temp > S3 then
|
|
set ledB OFF
|
|
SET ledG OFF
|
|
SET ledR ON
|
|
end if
|
|
|
|
Wait 100 ms
|
|
'Jump back to the start of the program
|
|
goto Loop
|