Selasa, 05 Juni 2012

gser kanan kiri..


utak-utik program ini....


#include <mega8535.h>
#include <delay.h>

#define Key_A PINB.6
#define Key_B PINB.7

// Declare your global variables here

void main(void)
{
// Declare your local variables here
unsigned char LED;
.
.
.
while (1)
    {
      // Place your code here
      while(Key_A==0)   //ketika tombol A di tekan maka:
      {
        if(LED==0b10000000)
        {
            LED=0b00000001;       
        }
       
        else
        {
        LED<<=1;
        PORTC=~LED;       
        delay_ms(100);
        }
     
      }
     
      while(Key_B==0)   //ketika tombol B di tekan maka:
      {
        if(LED==0b00000001)
        {
            LED=0b10000000;       
        }
       
        else
        {
        LED>>=1;
        PORTC=~LED;       
        delay_ms(100);
        }
      }

    }

Tidak ada komentar:

Posting Komentar

Secerca Harapan Didepan Mata