#include "C:\Program Files\PICC\Examples\blimp bot\transmitter.h"
//tx out to linx chip
//pushbuttons on rb1 - rb6 normally high
//led on rb7
/*
stop  - c, g, k
go forward - a, e
go backward - b, f
go up - j
go down - i
turn right - b, e
turn left - a, f
*/
#define  b0    PIN_B0   //stop
#define  b1    PIN_B1   //up
#define  b2    PIN_B2   //down
#define  b3    PIN_B3   //left
#define  b4    PIN_B4   //right 
#define  b5    PIN_B5   //forward
#define  b6    PIN_B6   //backward
#define  LED1  PIN_C5
#define  LED2  PIN_C4

int cmd=0;

#int_rda
void serial_isr() {
   cmd=getc();
   putc(cmd);
}

void main() {
   int bval;
   set_tris_c(0b10000000); //if want serial port, rc7 = rx
   set_tris_b(0b11111111); //

   enable_interrupts(global);
   enable_interrupts(int_rda);
   output_high(LED1);
   output_high(LED2);
   printf("hi\n\r");
   delay_ms(1000);
   output_low(LED2);

   while (TRUE){
      if (!input(b0)){
         output_high(LED2);
         putc('c');
         delay_ms(500);
         putc('g');
         delay_ms(500);
         putc('k');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b1)){
         output_high(LED2);
         putc('j');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b2)){
         output_high(LED2);
         putc('i');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b3)){
         output_high(LED2);
         putc('a');
         delay_ms(500);
         putc('f');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b4)){
         output_high(LED2);
         putc('b');
         delay_ms(500);
         putc('e');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b5)){
         output_high(LED2);
         putc('a');
         delay_ms(500);
         putc('e');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }
      else if (!input(b6)){
         output_high(LED2);
         putc('b');
         delay_ms(500);
         putc('f');
         delay_ms(500);
         putc('z');
         output_low(LED2);
      }


   }

}
