Files
SyncHome/trunk/workspace/gcb/tiny13-Temperature.gcb
2025-10-26 17:38:55 +00:00

89 lines
1.8 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
dim t1 as byte
dim t2 as byte
dim t3 as byte
dim temp as word
'Startup routine
Startup:
SET ledG OFF
SET ledR OFF
set ledB OFF
t1=100
t2=100
t3=100
'Main routine
Do
'Read temperature
t1=t2
t2=t3
t3=ReadAD(PTH)
temp=average(t3, t2)
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 1000 ms
'Jump back to the start of the program
Loop