LTlib LaurTec Library  4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
main.c
Go to the documentation of this file.
1 #include <xc.h>
2 
3 #include "LTlib.h"
4 
5 #include "module_IO.h"
6 #include "module_IO.c"
7 
8 //******************************************************************************
9 //The software reads PORTB where you have 4 buttons on RB4-RB7 (BT1-BT4).
10 //The button that gets pressed is shown on PORTD where you need to connects
11 // 4 LEDs from RD0 to RD3.
12 //******************************************************************************
13 
14 int main(void) {
15 
16  unsigned char data;
17 
20 
22 
23  while(1){
24  //It shifts 4 positions to get BT1 associated with LED1 on PORD bit 0
25  data = IO_read_port(IO_PORTB);
26  IO_write_port(IO_PORTD,(~data >> 4) & 0x0F);
27  }
28 }