Skip to content

Instantly share code, notes, and snippets.

@keita03301995
Created May 25, 2016 08:30
Show Gist options
  • Save keita03301995/0e23425cd4d280fc79ee95d5dfaea71d to your computer and use it in GitHub Desktop.
Save keita03301995/0e23425cd4d280fc79ee95d5dfaea71d to your computer and use it in GitHub Desktop.
/*
** Filename : Ex33.c
** Author : Keita, Kameoka
** Note : 2016.05.16
*/
#include <jeclib.h>
#define SW1 (0x01)
#define SW2 (0x02)
#define SW3 (0x04)
#define SW4 (0x08)
#define ALL_SW (SW1|SW2|SW3|SW4)
#define LED1 (0x10)
#define LED2 (0x20)
#define LED3 (0x40)
#define LED4 (0x80)
#define ALL_LED (LED1|LED2|LED3|LED4)
#define SW_PORT PORTA
#define LED_PORT PORTB
void main(void)
{
unsigned char mem,sw_state;
ADCON1 = 0x07;
TRISA |= ALL_SW;
TRISB &= ~ALL_LED;
LED_PORT &= ~ALL_LED;
while(1){
if ( (sw_state = (~SW_PORT & ALL_SW)) != 0x00 ){
mem = LED_PORT;
LED_PORT &= ~ALL_LED;
LED_PORT |= ~SW_PORT << 4 ^ mem;
delay_ms(5);
while(~SW_PORT == sw_state ) {
; /* Do Nothing */
}
delay_ms(5);
}
}
}
/* End Of File */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment