3 Replies Latest reply on Apr 3, 2014 3:43 PM by mahmoud.athab

    interfacing a temperature sensor

    mahmoud.athab

       Hi,

         

      Iam trying to interface a temperature sensor to the CY8CKIT-050. however, there is a problem with the software below.

         

       

         

      #include <project.h>

         

      #include "stdio.h"

         

      int main()

         

      {

         

      float T;

         

      int32 voltcount;

         

      float volt;

         

      char str[16];

         

      LCD_Start();

         

      ADC_Start();

         

      ADC_StartConvert();

         

          for(;;)

         

          {

         

      ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

         

              voltcount=ADC_GetResult16();

         

              volt=ADC_CountsTo_Volts(voltcount);

         

       

         

      T=85.543*(1.8641-volt);

         

       

         

      sprintf(str, "%+1.4f", T);    //pretty sure the problem lies here :)

         

              LCD_Position(0u,0u);

         

              LCD_PrintString(str);

         

          }

         

      }

         

       

         

      the project consists of a LCD and a temperature sensor. the PSOC5 reads the output from the sensor and displays it on the LCD.

         

      I did some debugging, triple checked the connections, checked the LCD and it's working. but I am quite sure that the problem lies in the sprintf function.