[PIC] multi-language communication system

Status
Not open for further replies.

swtbbert

Newbie level 5
Joined
Nov 24, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
11
Activity points
54
Hi to you all,
I designed a wireless language translator to be used in frights, please some1 can check on my project and help me where i am wrong.

transmitter code
Code:
/* Main.c file generated by New Project wizard
 *
 * Created:   Mon Feb 10 2014
 * Processor: PIC16F877A
 * Compiler:  HI-TECH C for PIC10/12/16
 */

#include <htc.h>

#use delay(clock = 20000000)

#use  rs232  (baud = 9600, xmit=PIN_B0,rcv=PIN_B1,stream=WIRELESS) // WIRELESS communication


unsigned long x_coord, y_coord;   

void send_data(char sdata[])
{
    fputs(sdata,WIRELESS);    
}


unsigned long GetX()
{
   unsigned long result;   
   set_adc_channel(0);
   output_low(PIN_A2);
   output_high(PIN_A3);   
   result = read_adc();
   return result;   
}

unsigned long GetY()
{
   unsigned long result;   
   set_adc_channel(1);
   output_low(PIN_A3);
   output_high(PIN_A2);
   result = read_adc();
   return result;   
}

void main()
{
   char text[25];
  
   output_high(PIN_C4);
   delay_ms(1000);
   output_low(PIN_C4);
   delay_ms(1000);
   output_high(PIN_C4);
   delay_ms(1000);
   output_low(PIN_C4);
  
  
    while(1)
    {
    
      x_coord = GetX();      //get X- coordinates of touched location on to variable x_coord
     
      y_coord = GetY();   //Get the Y-coordingates of touched location

     
     
      if((x_coord > 25) && (x_coord < 85) && (y_coord > 25) && (y_coord < 125))
      {
         sprintf(text,"1");
         send_data(text);
         output_high(PIN_C4);
      }
      else if((x_coord > 25) && (x_coord < 85) && (y_coord > 150) && (y_coord < 240))
      {
         sprintf(text,"2");
         send_data(text);
         output_high(PIN_C4);
      }
     
      else if((x_coord > 90) && (x_coord < 140) && (y_coord > 25) && (y_coord < 125))
      {
         sprintf(text,"3");
         send_data(text);
         output_high(PIN_C4);
      }
      else if((x_coord > 90) && (x_coord < 140) && (y_coord > 150) && (y_coord < 240))
      {
         sprintf(text,"4");
         send_data(text);
         output_high(PIN_C4);
      }
      else if((x_coord > 145) && (x_coord < 190) && (y_coord > 25) && (y_coord < 125))
      { 
         sprintf(text,"5");
         send_data(text);
         output_high(PIN_C4);
      }
      else if((x_coord > 145) && (x_coord < 190) && (y_coord > 150) && (y_coord < 240))
      {
         sprintf(text,"6");
         send_data(text);
         output_high(PIN_C4);
      }
      else if((x_coord > 195) && (x_coord < 250) && (y_coord > 25) && (y_coord < 125))
      {
         output_high(PIN_C3); //LED Lamp ON
      
      }
      else if((x_coord > 195) && (x_coord < 250) && (y_coord > 150) && (y_coord < 240))
      {
         output_low(PIN_C3);  //LED Lamp OFF
      }     
      delay_ms(100);
      output_low(PIN_C4);  
    }
}

receiver code

Code:
/* Main.c file generated by New Project wizard
 *
 * Created:   Mon Feb 10 2014
 * Processor: PIC16F877A
 * Compiler:  HI-TECH C for PIC10/12/16
 */

#include <htc.h>

#use delay(clock=20000000) //crystal oscillator

#use  rs232  (baud = 9600, xmit=PIN_B1,rcv=PIN_B0,stream=WIRELESS) // WIRELESS communication

#include <nokiaGLCD.c> //For Nokia Graphical LCD

void main()
{
   char text[25]; //For capturing the text
   char ch;

  
   //Following code is for Health Check (microcontroller)
   output_high(PIN_C4);  //LED ON
   delay_ms(1000);
   output_low(PIN_C4);   //LED OFF
   delay_ms(1000);
   output_high(PIN_C4);  //LED ON
   delay_ms(1000);
   output_low(PIN_C4);   //LED OFF
  
   nokia_init();  //Initialise Nokia GLCD

   //Nokia LCD got 6 row and 21 columns
  
   nokia_clear_screen();  //Clear the screen contents
   
   nokia_gotoxy(2,1);  //Go to row number-1 and column number 2
   
   sprintf(text," TOUCH SCREEN");  //this copies the text "TOUCH SCREEN" into the variable text.
   
   printf(nokia_printchar,"%s",text); //Print the text on to LCD
   
   delay_ms(1000);  //wait for 1000 milli seconds
  
   nokia_gotoxy(2,3);  //third row second column
   sprintf(text,"  AIR LINES");  //copies the text into text variable
   printf(nokia_printchar,"%s",text);
   delay_ms(500);
     
   nokia_gotoxy(2,5);  //Fifth row and second column
   sprintf(text,"  ASSISTANT");
   printf(nokia_printchar,"%s",text);
   delay_ms(2000);
  
  
   nokia_clear_screen(); //clear LCD contents
   nokia_gotoxy(3,3);
   sprintf(text,"*** READY ***");
   printf(nokia_printchar,"%s",text);
   delay_ms(1000);
  
         
   while(1) //Infinite loop starts here
   {        
      
         if(!input(PIN_A0))  //If the clear button pressed, then clear the requests on LCD
         {
            output_high(PIN_C3); 
            delay_ms(500); //Long Beep
            output_low(PIN_C3);   
           
            nokia_clear_screen();
            nokia_gotoxy(4,1);
            printf(nokia_printchar,"     NO");
            nokia_gotoxy(4,3);
            printf(nokia_printchar,"   PENDING");
            nokia_gotoxy(4,5);
            printf(nokia_printchar,"  REQUESTS");
            output_low(PIN_C4);
         }
      
      
       ch = fgetc(WIRELESS);  //get character
       
       nokia_clear_screen(); // clear Nokia screen LCD
      
       nokia_gotoxy(1,1);
       printf(nokia_printchar," SEAT NO: A9");
       output_high(PIN_C4); //LED ON
       switch(ch)   //switch to the block based on character received.
       {
         case '1':
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"    WATER");
                  break;
                 
         case '2':                 
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"     FOOD");
                  break;
                 
         case '3':                 
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"   MEDICINE");
                  break;
                 
         case '4':                 
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"   BED SHEET");
                  break;
         case '5':                 
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"    SNACKS");
                  break;
         case '6':                 
                  nokia_gotoxy(4,3);
                  printf(nokia_printchar,"  REQUESTING");
                  nokia_gotoxy(4,5);
                  printf(nokia_printchar,"   MAGAZINE");
                  break;
       } //end of switch statement       
   }
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…