You are here

Displaying a Floating Point Number | Cypress

Support & Community

Displaying a Floating Point Number

Last Updated: June 27, 2011

How to display a floating point number on the LCD when using the PSoC C-compiler?


A floating point number can be converted to ascii using the ftoa function and then displayed on an LCD using the LCD_PrString function.  An example code snippet is shown below.

#include "stdlib.h"

#include "string.h"

void main(void)
   float MyFloat;
   int Status;
   char* buf;

   MyFloat = 1.2345;
   buf = ftoa(MyFloat, &Status);

The same approach may be used to convert a float to ascii and send it over UART.  Instead of the LCD_PrString function, UART_PutString function should be used.

Knowledge Base Tags: 

Provide feedback on this article

To protect your privacy, do not include contact information in your feedback.

Browse KB By Product

Browse KB by Type