void SS_BT_RMClick() {
//
remote_mod=1;
 UART1_Write_Text("Remote");
DrawScreen(&RemoteMode);

}
Example #2
0
void Proceso(void){
 // Lectura del Voutput del sensor LM35
 // Mostrando Voutput y su conversion a °C
 char val[15];
 float volts;
 float grados;
 char centigrados[15];
 
 adc_value = ADC1_Get_Sample(10);
 grados = adc_value/cuentas;
 FloatToStr(grados,centigrados);
 UART1_Write_Text(centigrados);
 UART1_Write(13);
 UART1_Write(10);
 Lcd_Out(1, 1, centigrados);
 Lcd_Out(1, 8, "\xDFc");
 
 volts = adc_value;
 FloatToStr(volts,val);
 Lcd_Out(2, 15, "V");
 Lcd_Out(2, 1, val);
 delay(0xFFFFF);
 Lcd_Cmd(_LCD_CLEAR);
 
if (UART1_Data_Ready()) {     // If data is received
 uart_rd = UART1_Read();     // read the received data
 if (uart_rd == '1'){
  LAMPARA = ~LAMPARA;
 }
 else if (uart_rd == '2')
 {
  VENTILADOR = ~VENTILADOR;
 }
}
}
Example #3
0
void SetNewNumber(void)
{
    char i;
    char PressedKey;
    for(i = 0; i < 8; i++)
    {
#ifdef DEBUG
        UART1_Write_Text_Constant("Waiting for press");
        UART1_Write(13); //Carriage return (new line)
#endif
        do
        {
            PressedKey = GetKeyPad();
        } while (PressedKey == 0); // Wait for press
        MobileNumber[i] = PressedKey;
        Buzzer_Beep(1);
#ifdef DEBUG
        UART1_Write(MobileNumber[i]);
        UART1_Write_Text_Constant(" pressed. ");
        UART1_Write(i+48);
        UART1_Write('=');
        UART1_Write(MobileNumber[i]);
        UART1_Write_Text_Constant(" - Waiting for release");
        UART1_Write(13); //Carriage return (new line)
#endif
        while(GetKeyPad() != 0); // Wait for release
    }
    MobileNumber[8] = 0;

#ifdef DEBUG
    UART1_Write_Text(MobileNumber);
#endif
}
void sendThroughUARTtoProcessing(void) {

     IntToStr(AccX, data_);
     UART1_Write_Text(data_);
     UART1_Write(0x0A);
     IntToStr(AccY, data_);
     UART1_Write_Text(data_);
     UART1_Write(0x0A);
     IntToStr(AccZ, data_);
     UART1_Write_Text(data_);
     UART1_Write(0x0A);

     IntToStr(Xmag, data_);
     UART1_Write_Text(data_);
     UART1_Write(0x0A);
     IntToStr(Ymag, data_);
     UART1_Write_Text(data_);
     UART1_Write(0x0A);

     return;
}
/* MAIN
 ******************************************************************************/
void main()
{
    system_init();
    mcp2542_init();
    mcp2542_delimiter_set( "\r\n" );

    while( 1 )
    {
        if( Button( &GPIO_PORT_24_31, 4, 100, 1 ) )
        {
            mcp2542_send( write_buffer );
            UART1_Write_Text( "\r\n< SENT >\r\n" );
        }

        if( mcp2542_rdy() )
        {
            mcp2542_read( read_buffer );
            UART1_Write_Text( "\r\n< RECEIVED >\r\n" );
            UART1_Write_Text( read_buffer );
        }
    }
}
/* FUNCTIONS
 ******************************************************************************/
void system_init()
{
    GPIO_Digital_Input( &GPIO_PORT_24_31, _GPIO_PINMASK_4 );                    /* Button pin */
    GPIO_Digital_Output( &GPIO_PORT_08_15, _GPIO_PINMASK_1 );                   /* STB pin */
    Delay_ms( 200 );
                                                                                /* DBG UART */
    UART1_Init( 115200 );
    Delay_ms( 200 );
                                                                                /* MODULE UART */
    UART2_Init( 115200 );
    Delay_ms( 200 );

    UART1_Write_Text( "System Initialized\r\n" );
}
Example #7
0
void main() {

  char valor[8];
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  DDRB.B2=1;
  
  while(1){
  val = ADC_Read(3);       // obtener valor Análogo de canal 3
  IntToStr(val, valor);
  for (i = 0; i <7 ; i++ )UART1_Write(valor[i]);
  UART1_Write_Text(" ");
  delay_ms(100);
  }
  }
Example #8
0
void SendSMS(const char message[])   // Send SMS to danish number
{
    GSM_PowerOn();
    LED_On(); // Turn on LED
    GSM_Initialize(0);
    UART1_Write_Text_Constant("AT+CMGF=1");
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(10);
    WaitForRecieveChar(0x0D);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    UART1_Write_Text_Constant("AT+CSCS=");
    UART1_Write(34); // "
    UART1_Write_Text_Constant("GSM");
    UART1_Write(34); // "
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(10);
    WaitForRecieveChar(0x0D);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    // Set mobile number
    UART1_Write_Text_Constant("AT+CMGS=");
    UART1_Write(34); // "
    UART1_Write_Text_Constant("45"); // Country code (Denmark)
    UART1_Write_Text(MobileNumber);
    UART1_Write(34); // "
    UART1_Write(13); //Carriage return (new line)
    Delay_ms(500);
    WaitForRecieveChar(0x0A);

    // Write message
    i = 0;
    while (message[i] != 0)
    {
        UART1_Write(message[i]);
        i++;
    }
    UART1_Write(26); // Substitution (CTRL+Z)
    WaitForRecieveCharAndBlink(0x0A);
    EmptySerialBuffer();
    CancelAlarmOnClick(); // Check if # is held - if true, disable the alarm and buzzer

    Delay_ms(1000); // Give time to send the message
    GSM_PowerOff();
}
void main() {
      configure();

      UART1_Write_Text(ConnectionEstablished);
      setPID();

      //testPIC();

      debugText = "          Starting..  ";
      UART1_Write_Text(debugText);

      delay_ms(1000);
      debugText = "Test Sensors   ";
      UART1_Write_Text(debugText);

      for(count=0; count<1; count++){
            receiveCommand = UART1_Read();
            sendSensorStatus();
            delay_ms(1000);
      }                                                  //while( receiveCommand != 'A' && receiveCommand != 'a' );

      debugText = "Start Line follow..   ";
      UART1_Write_Text(debugText);
      //lineFollowNormal();
      //lineFollow();
      lineFollowPID();
      
      testPIC();
      
      while(1){

      debugText = " Rotate Clockwise ";
      UART1_Write_Text(debugText);
      rotateClockwise(255);
      delay_ms(220);
      stop();

      delay_ms(2000);

      debugText = " Rotate Anti Clockwise ";
      UART1_Write_Text(debugText);
      rotateAntiClockwise(255);
      delay_ms(220);
      stop();

      delay_ms(2000);

      }
}
Example #10
0
void main(void)
{
     char rom_data[7];
     
     //setup UART
     UART1_Init(9600);      //setup UART for 9600bps comm
     UART1_Write_Text("mikroC EEPROM TEST\n");
     
     //write to EEPROM
     EEPROM_Write(0, '1');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     EEPROM_Write(1, '2');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     EEPROM_Write(2, '3');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     //Read from EEPROM
     IntToStr((int)EEPROM_Read(0), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     IntToStr((int)EEPROM_Read(1), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     IntToStr((int)EEPROM_Read(2), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     while(1);
}
Example #11
0
//-----------------------------------------------------------------------
//Name:  - Senior Design Project of Counting the Crowd entering the
//	   Jamaraat area during the Hajj.
//       - PIC16F628a#3 is uesd as a storage unit to store and sent the
//         calculated echo pulses of Ultrasonic sensor to the Arduino
//         Uno R3.
//       - Assuming a room temp of 25 degrees centigrade.
//Autor:   Ahmed Abdulaziz Abualsaud
//Version: v 1.0
//Date:    Dec, 2, 2015
//-----------------------------------------------------------------------
void main()
{
     //Declare teh Global Variable
     int a;       //Variable to store the echo pulses
     int i = 1;   //Counter to know which sensor is selected
     char txt[7]; //Char String is used to send the distance to the Arduino
     char txtD[7];//Char String is used to send the selected sensor to the Arduino

     //Configure all pin as digital by disable the comparators
     CMCON = 0b00000111;

     //Configure the TIMER1 to work beasd on the internal oscilator speed 4MHz
     T1CON = 0b00000000;

     //Configure each digital bins as In/Out ports
     //Pin Name  - 0/1        - Pin Lable    - Pin Number
     TRISA.F0    = 0;//       = exP3         - 17
     TRISA.F1    = 0;//       = stP3         - 18
     TRISA.F4    = 1;//       = done         - 3
     TRISB.F0    = 1;//       = enP3(A1)     - 6
     TRISB.F1    = 1;//       = Read3        - 7
     TRISB.F2    = 0;//       = MX3          - 8
     TRISB.F4    = 1;//       = C            - 10
     TRISB.F5    = 1;//       = D            - 11


     UART1_Init(9600);// Initialize UART module at 9600 bps
     Delay_ms(50);    // Wait for UART module to stabilize

     while (1)
     {
           //Clear the TIMER1 registers
           TMR1H = 0;
           TMR1L = 0;
           PORTA.F0 = 0;               //Disable exP3 signal
           PORTA.F1 = 0;               //Disable stP3 signal

           while(!PORTB.F1);           //Wait the echo (Read3 signal) to become 1
           T1CON.F0 = 1;               //Enable the TIMER1
           while(PORTB.F1);
           T1CON.F0 = 0;

           a = (TMR1L | (TMR1H << 8)) / 29.1 / 2;
           IntToStr(a,txt);
           Ltrim(txt);
           IntToStr(i,txtD);
           Ltrim(txtD);

           //Wait the control Signal from Arduino to start sending the data
           while(PORTB.F5 != 1 && PORTB.F4 != 0);//D&C
           while(PORTB.F0 == 0);       //Wait for enP3 signal comming from Arduino
           
           PORTA.F1 = 1;               //Enable stP3 signal

           // Start sending data via UART
           UART1_Write_Text("GG3_");
           UART1_Write_Text(txtD);
           UART1_Write_Text(": ");
           UART1_Write_Text(txt);
           UART1_Write_Text(" cm");
           UART1_Write_Text("!");
           UART1_Write(13);            //The Carriage Return

           PORTA.F0 = 1;               //Enable the exP3 signal

           ++i;                        //Increment the sensor iterator
           if (i == 5){i = 1;}         //Reset the sensor iterator
           while(PORTA.F4 == 0);       //Wait for the done signal coming from Arduino
     }//End while loop
}//End void main
Example #12
0
void main() {
  int i,j;

  UART1_Init(57600);              
  Delay_ms(100);                  

  UART1_Write_Text("Start\n");
  UART1_Write(13);
  UART1_Write(10);
  timer_setup();
  UART1_Write_Text("timer started");
  UART1_Write(13);
  UART1_Write(10);

for( i = STOP; i > state_e; state_e++ )  // every state is being executed 1000 times except GRAPHICS, it is done 10 times
  {
    for( j = 0; j < 10000; j++ )
    {
      switch( state_e )
      {
        case DHRYSTONE:
          dhrystone_benchmark();    // after executing, record the time passed
          record_time();
          reset_time();
        break;
        case FFT:
          fft_benchmark();
          record_time();
          reset_time();
          break;
        case WHETSTONE:
          whetstone_benchmark();
          record_time();
          reset_time();
          timer_setup();
        break;
        case GRAPHICS:
        {  uint8_t temp;
          if ( j % 100 == 0)
          {
            for (temp = 0; temp <10; temp++)
            {
              graphics_benchmark();
              record_time();
              reset_time();
             }
          }
         }
        break;
      }
    }
  }

  // print out the time passed

  UART1_Write_Text("Drhystone: ");
  IntToStr(dhrystone_time, txt);
  UART1_Write_Text(txt);
  UART1_Write(13);
  UART1_Write(10);

  UART1_Write_Text("FFT: ");
  IntToStr(fft_time, txt);
  UART1_Write_Text(txt);
  UART1_Write(13);
  UART1_Write(10);

  UART1_Write_Text("whetstone: ");
  IntToStr(whetstone_time, txt);
  UART1_Write_Text(txt);
  UART1_Write(13);
  UART1_Write(10);

  UART1_Write_Text("graphics: ");
  IntToStr(graphics_time, txt);
  UART1_Write_Text(txt);
  UART1_Write(13);
  UART1_Write(10);



}
Example #13
0
void main() {
  unsigned char i,tmp;
  unsigned int tout;

  CMCON=0x07; 
  TRISA=0x30;
  TRISB=0xE7;
  
  PORTA=0;
  PORTB=0;

  lcd_init();

  UART1_Init(9600);

//teste serial
  lcd_cmd(L_CLR);
  lcd_cmd(L_L1);
  lcd_str(codetxt_to_ramtxt("Teste Serial TX"));
  lcd_cmd(L_L2+2);
  lcd_str(codetxt_to_ramtxt("9600 8N1"));

  UART1_Write_Text(codetxt_to_ramtxt("\r\n Picsimlab\r\n Teste Serial TX\r\n"));

  for(i=0;i<4;i++)
  {
    UART1_Write(i+0x30);
    UART1_Write_Text(codetxt_to_ramtxt(" PicsimLab\r\n"));
  }
  delay_ms(1000);

  lcd_cmd(L_CLR);
  lcd_cmd(L_L1);
  lcd_str(codetxt_to_ramtxt("Teste Serial RX"));
  UART1_Write_Text(codetxt_to_ramtxt(" Digite!\r\n"));
  for(i=0;i<32;i++)
  {
    if(!(i%16))
    {
       lcd_cmd(L_L2);
       UART1_Write_Text(codetxt_to_ramtxt("\r\n"));
    }

  tout=0;
  while(!UART1_Data_Ready() && (tout < 2000))
  {
    tout++;
    delay_ms(1);
  }
    
  if (UART1_Data_Ready() == 1) {
   tmp = UART1_Read();
  }
  else
  {
    tmp='-';
  }

    
    lcd_dat(tmp);
    UART1_Write(tmp);
  }
  delay_ms(100);

  lcd_cmd(L_CLR);
  lcd_cmd(L_L1);
  lcd_str(codetxt_to_ramtxt("Teste Teclado TX"));
  UART1_Write_Text(codetxt_to_ramtxt("\r\n Aguarde!\r\n"));
  for(i=0;i<32;i++)
  {
    if(!(i%16))
    {
      lcd_cmd(L_L2);
      UART1_Write_Text(codetxt_to_ramtxt("\r\n"));
    }
    tmp=tc_tecla(2000)+0x30;
    lcd_dat(tmp);
    UART1_Write(tmp);
  }
  delay_ms(100);


//fim teste 
  lcd_cmd(L_CLR);
  lcd_cmd(L_L1+4);
  lcd_str(codetxt_to_ramtxt("Fim"));
  lcd_cmd(L_L2+1);
  lcd_str(codetxt_to_ramtxt("Pressione RST"));

  UART1_Write_Text(codetxt_to_ramtxt("\r\n FIM!\r\n"));

  while(1);


}
void sendThroughUARTtoMSVS(void) {

     IntToStr(AccX, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(AccY, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(AccZ, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(GyrX, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(GyrY, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(GyrZ, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(Tmp, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     
     IntToStr(UT, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     LongWordToStr(UP, data_);
     LTrim(data_);
     UART1_Write_Text(data_);

     IntToStr(Xmag, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(Ymag, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     IntToStr(Zmag, data_);
     UART1_Write_Text(data_);
     UART1_Write(' ');
     
//     UART1_Write(13);//CR
     UART1_Write(31);//US

     return;
}