my button doesn't work

Status
Not open for further replies.

watzmann

New Member
Hi All,

Please help me with this program , the LCD works well but the problem is when i press the button PortE is not inverted.


here is my code

Code:
program third

' Declarations section
dim GLCD_DataPort as byte at PORTD

dim GLCD_CS1 as sbit at RB0_bit
    GLCD_CS2 as sbit at RB1_bit
    GLCD_RS  as sbit at RB2_bit
    GLCD_RW  as sbit at RB3_bit
    GLCD_EN  as sbit at RB4_bit
    GLCD_RST as sbit at RB5_bit

dim GLCD_CS1_Direction as sbit at TRISB0_bit
    GLCD_CS2_Direction as sbit at TRISB1_bit
    GLCD_RS_Direction  as sbit at TRISB2_bit
    GLCD_RW_Direction  as sbit at TRISB3_bit
    GLCD_EN_Direction  as sbit at TRISB4_bit
    GLCD_RST_Direction as sbit at TRISB5_bit
' End Glcd module connections
dim counter as byte
    someText as char[18]
    dim i as word
           ADCON1 = 7 ' All pins digital

CMCON = 7 ' All comparator Off

        TRISC=%11111111
        TRISE=%000000
        PORTE=000000


main:
 Glcd_Init()
  Glcd_Fill(0x00)                                     ' Clear Glcd

    Glcd_Set_Font(@Font_Glcd_Character8x7, 8, 7, 32)    ' Choose font "Character8x7"
    Glcd_Write_Text("Hello World", 0, 0, 2)
    
    if Button(PORTC, 2, 0, 1) then  portE=NOT (PORTE)
    end if
end.
[Code]
 
If this is microchip, like i think it is, you should put this on forum.microchip.com under the pic24 graphics section. I never could get the graphics stuff to work right aside from the demo's.
 
I don't recognise this basic..... The function button() has four parameters... I'm guessing portc pin 2 ? and the last one... is it a debounce time?

If you let us know the compiler I can look into it for you.


Ok I have discovered its mikroBasic....
Code:
button(
  PORT,   ' Port (obviously)
  PIN,     ' port pin
  MSEC,   ' time in active state ( make this at least 1 ms)
  ACTIVE STATE,   'either on or off
   )
 
Last edited:
And you discovered the problem too maybe?

MSEC, ' time in active state ( make this at least 1 ms)

as the OP has 0 mS.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…