Jump to content
Sign in to follow this  
slacx

Masalah Dekat Debounce In C

Recommended Posts

Salam semua,

aku sekarang tgh pening kepala camne nak bg switch yg ada kat board STK500 tu utk jd input nombor dan outputnye ke LCD STK502. Dah mcm2 cara aku try tp tak jadi. Aku bole buat switch(input) n increase kan turutan LED(output) but nak increase n decrease kan nombor pastu outputkan nye kt LCD mmg aku xdpat. Korang pahamke ape yg aku terang ni? Kalau tak paham nnt aku terangkan lg..

Btw, ni code untuk ouput LED

int main(void)
{ 
    DDRA = 0x00;   //* All pins as input 
    PORTA=   0x00;   //* no pull-up on pins 

    DDRB = 0xFF;   //* All pins as output 
    PORTB = 0xFF;   //* All leds off (STK500) 

    unsigned char count = 0xFF; 
    char key_pressed = 0; 
    while(1){ 
      if (!(PINA & 0x01) && !key_pressed){ 
         key_pressed = 1; 
         PORTB = count; 
         --count;          
      } 
      else if (PINA & 0x01){ 
         key_pressed = 0; 
      } 
      if (count < 1) count = 0xFF; 
   } 
return 0; 
}

Sesape yg idea cmne nak tuka code ni supaya boleh kluar ke LCD?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...