User sets desired TIME but before the timer starts the user changes the desired time BEFORE THE GREEN led IS ENABLED.
After the user inputs the desired TIME, the pic automatically starts timing after 10-15 second delay.
Then use a clock that works differently. The timer on my oven can't be set to 87-seconds. Can yours?You need a GO button. If I enter 2 minutes, I want to know when 2 minutes have elapsed, not 2 minutes + some delay. What if I want 87 seconds? Or an hour?
You have missed something.I've probably completely misunderstood what you've said so feel free to completely ignore the above.
Mike.
Maybe I have but these threads get so confusing. Four pages and you want to ignore everything and send me back to the first post!You have missed something.
Re-read the first line of the OPs first post. It's interesting how much bad advice he is getting - and how many attempts members have made to negotiate is simple specification.
I read the Original post and my question still stands. Care to explain as you obviously understand this better than I?Re-read the first line of the OPs first post. It's interesting how much bad advice he is getting -
disregard post#80 my mistake
going to just add a lighted tactile switch for TIMER START
The user adjusts the set-time and, after 10-seconds of no adjustments, the kitchen timer starts. Exactly like he said it. I don't know how else it can be interpreted.I read the Original post and my question still stands. Care to explain as you obviously understand this better than I?
Mike.
Device = 18F43K22
Clock = 16
// int osc and IO pin libraries
Include "intosc.bas"
#option DIGITALIO_INIT = true // automatically call setalldigital
Include "setdigitalio.bas"
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.2
#option LCD_EN = PORTD.3
Include "LCD.bas"
Include "convert.bas"
Include "utils.bas"
//SWITCHES
Dim SWT_0 As PORTB.0
Dim SWT_1 As PORTB.1
Dim SWT_2 As PORTB.2
Dim SWT_3 As PORTB.3
Dim SWT_4 As PORTB.4
Dim SWT_5 As PORTB.5
Dim SWT_6 As PORTB.6
Dim SWT_7 As PORTB.7
//LEDS
Dim led0 As PORTC.0 //HOURS+
Dim led1 As PORTC.1 //HOURS-
Dim led2 As PORTC.2 //MINIUTES+
Dim led3 As PORTC.3 //MINIUTES-
Dim led4 As PORTC.4 //SECONDS+
Dim led5 As PORTC.5 //SECONDS-
Dim led6 As PORTC.6
Dim led7 As PORTC.7
Dim x As Byte
Dim TIME As Byte
Dim Hrs_p As Byte 'hours plus
Dim Hrs_m As Byte 'hours minius
Dim Min_p As Byte 'miniutes plus
Dim Min_m As Byte 'miniutes minius
Dim Sec_p As Byte 'Seconds plus
Dim Sec_m As Byte 'Seconds minius.
Dim Hours As Byte
Dim Miniutes As Byte
Dim seconds As Byte
//Dim Timeer_value String
// set switch port to inputs and enable pullups
TRISB = $ff // set as inputs
WPUB = $ff // enable pullups on all PORTB pins
INTCON2.bits(7) = 0 // set bit RBPU = 0 turns on pullups
TRISC = 0
TRISA = 0
TRISD = 0
//set beginning values
Hrs_p = 00 'hours plus
Hrs_m = 00 'hours minus
Min_p = 00 'miniutes_plus
Min_m = 00 'miniutes minius
Sec_p = 00 'seconds plus
Sec_m = 00'seconds minius
hours = 0
miniutes = 0
seconds = 0
For x = 0 To 7 //set all portc LED off
PORTC.bits(x) = 0
Next
While (true)
if SWT_0 = 0 then hours = (Hours + 1) end if //add 1 hour
if hours > 12 then hours = 0 end if //12 hour limit
if SWT_1 = 0 then Hours = (hours - 1) end if //subtract hours
if hours > 12 then hours = 0 end if
if swt_3 = 0 then miniutes = (miniutes + 1) end if
if miniutes >= 60 then hours = hours + 1 miniutes = 0 end if //add 1 to hours
if swt_4 = 0 then miniutes = (miniutes - 1) end if
if swt_5 = 0 then seconds = (seconds + 1) end if //add seconds
if seconds = 60 then miniutes = miniutes + 1 seconds = 0 end if
if swt_6 = 0 then seconds = (seconds - 1) end if //subtract seconds
' if seconds < 0 then seconds = 0 end if
WriteAt(1,1,"HRS MIN SEC")
writeat(2,1," ") //redresh display
WriteAt(2,3,DecToStr(hours))
WriteAt(2,7,DecToStr(miniutes))
writeat(2,11,dectostr(seconds))
DelayMS(300)
' If SWT_0 = 0 Then
'LED0 = 1
'For x = 0 To 7
' PORTC.bits(x) = 1
' DelayMS(1000)
' PORTC.bits(x) = 0
'DelayMS(1000)
'Next
Wend
I don't see why that would cause a problem. Yes, not the most efficient way but still should work. Or, am I missing the point?How to show you don't understand basic concepts without saying so.
View attachment 144091
A quick glance shows some problems are edge cases.
For x = 0 To 7 //set all portc LED off
PORTC.bits(x) = 0
Next
PortC = %00000000
PortC = 0
For x = 0 To 7 //set all portc LED off
PORTC.bits(x) = 1
Next
PortC =:%11111111
PortC = 255
PortC = $FF
While 1 = 1
PortC = %10101010
DelayMS(1000)
PortC = %01010101
DelayMS(1000)
Wend
Code:PortC = 256
256 is the decimal number equal to %11111111, so it sets all eight bits to 1.
What about this?
Ouch!! - I take it you meant 255
It's surprising how easy it is to make similar mistakes - simply because a byte has 256 possible values, though one of them is zeroOops. Fixed.
At least I try.
Device = 18F43K22
Clock = 16
// int osc and IO pin libraries
Include "intosc.bas"
#option DIGITALIO_INIT = true // automatically call setalldigital
Include "setdigitalio.bas"
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.2
#option LCD_EN = PORTD.3
Include "LCD.bas"
Include "convert.bas"
Include "utils.bas"
//SWITCHES
Dim SWT_0 As PORTB.0
Dim SWT_1 As PORTB.1
Dim SWT_2 As PORTB.2
Dim SWT_3 As PORTB.3
Dim SWT_4 As PORTB.4
Dim SWT_5 As PORTB.5
Dim SWT_6 As PORTB.6
Dim SWT_7 As PORTB.7
//LEDS
Dim led0 As PORTC.0 //HOURS+
Dim led1 As PORTC.1 //HOURS-
Dim led2 As PORTC.2 //MINIUTES+
Dim led3 As PORTC.3 //MINIUTES-
Dim led4 As PORTC.4 //SECONDS+
Dim led5 As PORTC.5 //SECONDS-
Dim led6 As PORTC.6
Dim led7 As PORTC.7
Dim x As Byte
Dim TIME As Byte
Dim Hours As Byte
Dim Miniutes As Byte
Dim seconds As Byte
//Dim Timeer_value String
sub Debounce()
delayms(50)
end sub
// set switch port to inputs and enable pullups
TRISB = $ff // set as inputs
WPUB = $ff // enable pullups on all PORTB pins
INTCON2.bits(7) = 0 // set bit RBPU = 0 turns on pullups
TRISC = 0
TRISA = 0
TRISD = 0
Hours = 0
Miniutes = 0
seconds = 0
For x = 0 To 7 //set all portc LED off
PORTC.bits(x) = 0
Next
While (true)
If SWT_0 = 0 Then Hours = (Hours + 1) debounce()End If //add 1 hour
If Hours > 12 Then Hours = 0 End If //12 hour limit
If SWT_1 = 0 Then Hours = (Hours - 1) debounce()End If //subtract hours\
If Hours > 12 Then Hours = 0 End If
If SWT_2 = 0 Then Miniutes = (Miniutes + 1) debounce()End If
If Miniutes >= 60 Then Hours = Hours + 1 Miniutes = 0 End If //add 1 to hours
If SWT_3 = 0 Then Miniutes = (Miniutes - 1) debounce()End If
If SWT_4 = 0 Then seconds = (seconds + 1) debounce() End If //add seconds
If seconds >= 60 Then Miniutes = Miniutes + 1 seconds = 0 End If
If SWT_5 = 0 Then seconds = (seconds - 1) debounce()End If //subtract seconds
if seconds < 0 then seconds = 0 end if
WriteAt(1,1,"HRS MIN SEC")
WriteAt(2,1," ") //redresh display
WriteAt(2,3,DecToStr(Hours))
WriteAt(2,7,DecToStr(Miniutes))
WriteAt(2,11,DecToStr(seconds))
DelayMS(300)
Wend
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?