Thanks you for all the reaplys, I will analyse all of them...in the mean time, if anyone have more options, please post.!!
Thanks
Thanks you for all the reaplys, I will analyse all of them...in the mean time, if anyone have more options, please post.!!
Thanks
Hi Again;
I made this code, however is not working like i wont, only sometimes, can somebody tell me why;
ThanksCode:'********************************************************************* ' INCLUDE's e FUSES ' ==================================================================== DEFINE OSC 4 ' CONFIGURAÇÃO DAS INTERRUPÇÕES ' ==================================================================== ' VARIÁVEIS ' ==================================================================== VAR1 var byte VAR2 var byte I var byte var1=0 var2=0 ' REGISTOS PINOUT 1 = IN; 0 = OUT ' ==================================================================== '76543210 TRISA = %00000001 TRISB = %00000000 TRISC = %10000000 TRISD = %00000000 TRISE = %00000000 ADCON1 = 7 ' NOMES PINOUT ' ==================================================================== LED1 VAR PORTC.0 LED2 var PORTD.0 Botao var PORTA.0 ' DEFINIÇÕES ' ==================================================================== DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB DEFINE LCD_DBIT 0 ' PORTB starting address DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB DEFINE LCD_RSBIT 4 ' LCD RS bit address DEFINE LCD_EREG PORTB ' LCD E bit on PORTB DEFINE LCD_EBIT 5 ' LCD E bit address DEFINE LCD_BITS 4 ' LCD in 4-bit mode DEFINE LCD_LINES 2 ' LCD has 2 rows DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us DEFINE LCD_DATAUS 50 ' Set data delay time in us ' INICIO PROGRAMA ' ==================================================================== low led1 low lED2 LCDOUT $fe, 1 lcdout " Teste Botoes " lcdout $FE,$C0," Por Hugo Oliveira " Main: if botao = 1 then 'Button presse pause 80 'debounce for 80ms If Botao = 0 then BotaoClick 'Button Unpressed -> Only Click else if Botao = 1 then 'Button Still pressed for i = 1 to 6 pause 486 If Botao = 0 then Main 'Test if was unpressed in the mean while next If Botao = 1 then BotaoClickHold 'IF Still pressed after 3s -> Click&Hold endif endif GOTO MAIN ' SUB-ROTINAS ' ==================================================================== BotaoClick: if var1 = 0 then high led1 var1 = 1 pause 500 else low led1 var1 = 0 pause 500 endif Goto Main BotaoClickHold: if var2 = 0 then high led2 var2 = 1 pause 500 else low led2 var2 = 0 pause 500 endif Goto Main END
Hi, Hugo
I do not see those two actions in your program ...Code:While Button pressed Wait a bit Increment a counter WEND ... Is Counter limit reached ?
Alain
PS for Administrators ... There is a bug with high size characters: suppress the blank lines inserted after " wait a bit " and it will appear ...
Last edited by Acetronics2; - 18th August 2010 at 10:17.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi, thanks Acetronics;
Hi made thsi way, and its working, however later, i will make more tests.
Thanks Again.Code:' INCLUDE's e FUSES ' ==================================================================== DEFINE OSC 4 ' CONFIGURAÇÃO DAS INTERRUPÇÕES ' ==================================================================== ' VARIÁVEIS ' ==================================================================== VAR1 var byte VAR2 var byte I var byte counter var byte ' REGISTOS PINOUT 1 = IN; 0 = OUT ' ==================================================================== '76543210 TRISA = %00000001 TRISB = %00000000 TRISC = %10000000 TRISD = %00000000 TRISE = %00000000 ADCON1 = 7 ' NOMES PINOUT ' ==================================================================== LED1 VAR PORTC.0 LED2 var PORTD.0 Botao var PORTA.0 ' DEFINIÇÕES ' ==================================================================== DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB DEFINE LCD_DBIT 0 ' PORTB starting address DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB DEFINE LCD_RSBIT 4 ' LCD RS bit address DEFINE LCD_EREG PORTB ' LCD E bit on PORTB DEFINE LCD_EBIT 5 ' LCD E bit address DEFINE LCD_BITS 4 ' LCD in 4-bit mode DEFINE LCD_LINES 2 ' LCD has 2 rows DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us DEFINE LCD_DATAUS 50 ' Set data delay time in us ' INICIO PROGRAMA ' ==================================================================== low led1 low lED2 LCDOUT $fe, 1 lcdout " Teste Botoes " lcdout $FE,$C0," Por Hugo Oliveira " Main: while botao = 1 pause 100 counter = counter + 1 Wend if counter >= 30 then BotaoClickHold if counter>0 and counter<=5 then BotaoClick counter=0 GOTO MAIN ' SUB-ROTINAS ' ==================================================================== BotaoClick: counter = 0 if var1 = 0 then high led1 var1 = 1 pause 500 else low led1 var1 = 0 pause 500 endif Goto Main BotaoClickHold: counter = 0 if var2 = 0 then high led2 var2 = 1 pause 500 else low led2 var2 = 0 pause 500 endif Goto Main END
Hi;
It's Working just like the way i want, just made this change in the Main loop, from the code above;
Thanks Again.Code:' INCLUDE's e FUSES ' ==================================================================== DEFINE OSC 4 ' CONFIGURAÇÃO DAS INTERRUPÇÕES ' ==================================================================== ' VARIÁVEIS ' ==================================================================== VAR1 var byte VAR2 var byte I var byte counter var byte ' REGISTOS PINOUT 1 = IN; 0 = OUT ' ==================================================================== '76543210 TRISA = %00000001 TRISB = %00000000 TRISC = %10000000 TRISD = %00000000 TRISE = %00000000 ADCON1 = 7 ' NOMES PINOUT ' ==================================================================== LED1 VAR PORTC.0 LED2 var PORTD.0 Botao var PORTA.0 ' DEFINIÇÕES ' ==================================================================== DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB DEFINE LCD_DBIT 0 ' PORTB starting address DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB DEFINE LCD_RSBIT 4 ' LCD RS bit address DEFINE LCD_EREG PORTB ' LCD E bit on PORTB DEFINE LCD_EBIT 5 ' LCD E bit address DEFINE LCD_BITS 4 ' LCD in 4-bit mode DEFINE LCD_LINES 2 ' LCD has 2 rows DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us DEFINE LCD_DATAUS 50 ' Set data delay time in us ' INICIO PROGRAMA ' ==================================================================== low led1 low lED2 LCDOUT $fe, 1 lcdout " Teste Botoes " lcdout $FE,$C0," Por Hugo Oliveira " Main: while botao = 1 pause 100 counter = counter + 1 if counter = 30 then BotaoClickHold Wend if counter>0 and counter<=5 then BotaoClick counter=0 GOTO MAIN ' SUB-ROTINAS ' ==================================================================== BotaoClick: counter = 0 if var1 = 0 then high led1 var1 = 1 pause 500 else low led1 var1 = 0 pause 500 endif Goto Main BotaoClickHold: counter = 0 if var2 = 0 then high led2 var2 = 1 pause 500 else low led2 var2 = 0 pause 500 endif Goto Main END
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks