dual 7-segment countdown timer code
Hello guys iam a Dentist but have been into electronics as a hobby from the last 12 years
well i am not that good in coding (microcontrollers) so i need help from you Guys and the Admin as i couldnt find any thing on the net
I am building a Dual 7 - segment 20 and 40 seconds countdown timer for the dental composite curing light. here are the features that i needed
1. Dual 7- segment display
2. Countdown timer with 20 and 40 seconds delays
3. Timer should turn on \ off with the same button
4. Two different buttons for 20secs and 40 secs
5. Display should start at 20 then end at 0 same goes for 40 secs
6. Small beep when a button is pressed then after the countdown has elapsed a long beep should be heard
7. one output should go high when the timer statrs and should go low when the countdown ends ( this will drive a 5w blue led)
8. when the switch is pressed while countdown the timer should turnoff
9. when the timer is not running it should go in to sleepmode and blink an LED every 10 secs
Guys i have written a code for the above project but could only achieve the
following
1. switch is pressed then 5w led turns on and after 20secs turns off ( same goes for 40 secs)
2. beeper sounds when a button is pressed and then produces a long beep after the countdown is over
so i need help from the big brains out there to help me finish the project
Guys This Is My Code In Proton Basic
'************************************************* ***************
'* Name : Dr.RAGHUS COMPOSITE TIMER.BAS
'* Author : [DR.RAGHU]
'* Notice : Copyright (APRIL) 2007
'* : All Rights Reserved
'* Date : 4/24/2007
'* Version : 1.0
'* :
'************************************************* ***************
'FOR SW1
'LED (5W LED WILL TURN ON WITH SW1 AND BEEPER WILL BEEP ON FOR 1/3RD SEC
'LED WILL TURN OFF AFTER 20 SECS THEN BUZZER WILL BEEP for 1 SEC
'FOR SW2
'SAME AS ABOVE BUT CYCLE IS FOR 40 SECS AND BUZZER BEEPS 1 SEC AT THE END OF THE CYCLE
'INT XTL, NO OTHER CONFIGERATIONS
Set_Defaults PROTON_4 ' PROTON dev board using a 4MHz crystal
Device 16F628a
Dim BUF1 as Byte ' Working buffer 1 for button command
Dim BUF2 as Byte ' Working buffer 2 for button command
Symbol SW1 = PORTB.4
Symbol SW2 = PORTB.5
Symbol BUZ = PORTa.2 'BUZ = BUZZZER
Symbol LED = PORTA.1 'LED = 5W LUXEON LED
Delayms 500 ' Wait for PICmicro to stabilise
ALL_DIGITAL = True ' Set ports to digital mode
Clear ' Clear buffers
Low PORTa ' ALL LEDs off
TRISB = $F0 ' Set PORTB 0-3 outputs, 4-7 inputs
PORTB_PULLUPS = ON ' Enable PORTB pull-ups
Chk1: Delayms 25
Button SW1,0,40,5,BUF1,0,Chk2' Check Button 1 (Skip to 2 if Not Pressed)
TOGGLE BUZ 'TOGGLE BUZ
TOGGLE LED 'TOGGLE LED
DELAYMS 500 'DELAY 1/2 SEC
LOW BUZ 'TURNOFF BUZ & LED WILL STILL BE ON
DELAYMS 20000 'DELAY 20 SECS FOR LED
TOGGLE BUZ 'TURN ON BUZ AGAIN LED WILL STILL BE ON
DELAYMS 1000 'DELAY FOR 1SEC
LOW LED 'TURNOFF LED
LOW BUZ 'TURNOFF BUZ
Delayms 25
Chk2:
Button SW2,0,40,5,BUF2,0,CHK1 ' Check Button 2 (Skip to 1 if Not Pressed)
TOGGLE BUZ 'TOGGLE BUZ
TOGGLE LED 'TOGGLW LED
DELAYMS 500 'DELAY 1/2 SEC
LOW BUZ 'TURNOFF BUZ & LED WILL STILL BE ON
DELAYMS 40000 'DELAY 20 SECS FOR LED
TOGGLE BUZ 'TURN ON BUZ AGAIN & LED WILL STILL BE ON
DELAYMS 1000 'DELAY FOR 1 SEC
LOW BUZ 'TURNOFF BUZ
LOW LED 'TURNOFF LED2
Delayms 25
Goto Chk1 ' Do it forever
internal weak pullups work as advertised
Quote:
Also I might add that sometimes the internal pull ups can be a bit inadequate. I
base this statement mostly on the published material that I've read. I never use internal pull ups.
interesting ... I love internal pullups and have NEVER had a problem when using them in "clean" environments (e.g., low current / battery powered). If one has a noisy environment (e.g., autos), then of course they may not be strong enough to keep the pins high, BUT neither would an equivalent 25k-100k resistor. In this latter case, the failure of the weak pullups is not the fault of the internal weak pullups but of the designer. Internal pullups work as advertised and I have never seen published material that suggest otherwise. My suggestion is to understand them, use them when they are appropriate, and skip them when they are not.