$regfile = "attiny26.dat" $crystal = 4000000 '$sim $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space Dim Lsec0 As Long , Lsec1 As Long , Lsec2 As Long , Ltmp As Long , Lmin As Long Dim Startcooktimer As Byte , Presstime As Long , J As Byte Dim Idletime As Long Config Lcdpin = Pin , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0 , E = Porta.6 , Rs = Porta.7 Config Portb = Input Initlcd Cls Cursor Off 'Locate 1 , 1 : Lcd "Cooking" 'Locate 2 , 2 : Lcd "Timer" 'Waitms 1000 Lsec0 = 120 Main: Startcooktimer = 0 Gosub Initcooktimer Do ' SW 6 : Start/Stop/Reset If Pinb.6 = 1 Then Waitms 20 If Pinb.6 = 1 And Lsec0 > 0 Then Waitms 200 If Pinb.6 = 0 Then Startcooktimer = 1 Exit Do End If Waitms 400 If Pinb.6 = 0 Then Startcooktimer = 1 Exit Do End If Waitms 400 ' Reset If Pinb.6 = 1 Then Lsec0 = 0 Gosub Initcooktimer Waitms 500 End If End If End If ' SW 5 : +30 sec If Pinb.5 = 1 Then Waitms 20 If Pinb.5 = 1 Then Lsec0 = Lsec0 + 30 If Lsec0 >= 60000 Then Lsec0 = 0 End If Gosub Initcooktimer Waitms 400 End If 'Idletime = 0 End If Loop Until Startcooktimer = 1 'run timer Do Decr Lsec1 Gosub Displaycooktimer For J = 1 To 20 If Pinb.6 = 1 Then Waitms 20 If Pinb.6 = 1 Then Do Loop Until Pinb.6 = 0 Startcooktimer = 0 Gosub Initcooktimer End If End If Waitms 50 Next J If Lsec1 <= 0 Then Gosub Playsound Exit Do End If Loop Until Startcooktimer = 0 Goto Main Playsound: Sound Portb.4 , 80 , 500 Waitms 100 Sound Portb.4 , 80 , 600 Waitms 100 Sound Portb.4 , 80 , 700 Waitms 500 If Pinb.6 = 1 Then Waitms 20 If Pinb.6 = 1then Do Loop Until Pinb.6 = 0 Return End If End If If Pinb.5 = 1 Then Waitms 20 If Pinb.5 = 1 Then Do Loop Until Pinb.5 = 0 Return End If End If Goto Playsound Return Initcooktimer: Lsec1 = Lsec0 Gosub Displaycooktimer Return Displaycooktimer: Cls Lmin = Lsec1 / 60 Ltmp = Lmin * 60 Lsec2 = Lsec1 - Ltmp Locate 1 , 1 : Lcd Lmin Locate 1 , 3 : Lcd ":" Locate 1 , 5 : Lcd Lsec2 If Startcooktimer = 1 Then Locate 2 , 1 : Lcd "Start" Else Locate 2 , 1 : Lcd "Stop " End If Return
'Arduino/AVR > 3. AVR 프로젝트' 카테고리의 다른 글
attiny26으로 요리용 타이머 만들기(Cooking Timer) (7) | 2009.10.08 |
---|---|
ATTiny26을 이용한 어린이용 반짝이 운동화 만들기 (20) | 2009.08.11 |
ATTiny26 Switch, LED 예제 (0) | 2009.06.22 |
-
ㅎㅎ 나무나 아크릴등으로 간단하게 케이스를 주면 더 예쁠 것 같은데요.
그런데 점점 실용화 되어가네요. 작동은 잘 되나요? 저도 요새 강력한 알람이 필요해요..ㅎㅎ