Go Down

Topic: POV programming and temperature. Please help (Read 584 times) previous topic - next topic


hi, im making a project with POV , what im trying to do is to show trough the LEDs (POV) what a NTC temperature sensor is reading.
The problem is how can i put an integer value(int) to a char. Thanks.
PD. Each program works perfectly independent.

Code: [Select]

// defining the alphabet
#include "alphabet.h"

// define the Arduino LED pins in use
const int LEDpins[] = {1,2,3,4,5,6,7};

// number of LEDs character height and width
int charHeight = sizeof(LEDpins); //sizeof its value from arduino code
int charWidth = 5;

const float voltage = 5.00;       
const float B = 4100;
const float unodivr = 93.0;
const float resistor = 105000;     //Resistor
int sensorPin = A0;                // select the input pin for the potentiometer
int sensorValue = 0;

void setup()
   pinMode(1, OUTPUT);
   pinMode(2, OUTPUT);
   pinMode(3, OUTPUT);
   pinMode(4, OUTPUT);
   pinMode(5, OUTPUT);
   pinMode(6, OUTPUT);
   pinMode(7, OUTPUT);   

void loop()
   // Part 1:  Read the analog port 0 and convert the value to volts. 
   sensorValue = analogRead(sensorPin);//read analog 0
   float v2 = (voltage*float(sensorValue))/1024.0f;    // calculate volts in an awesome world
   // Part 2: Calculate the resistance with the volt value trough the voltage divider ecuation
   float r1a = (voltage*float(resistor))/v2; 
   float r1 =r1a - resistor;
   //Part 3: Calculate the temperature based on the Steinhart-Hart equation based on the B value equation. 
   float K = B/log(r1*unodivr);//Temperature in Kelvin
   int C=K-273;//Temperature in Celsius


//Function for print the letters 
void printLetter(char ch)
{  // make sure the character is within the alphabet bounds (defined by the alphabet.h file)
   // if it's not, make it a blank character
   if (ch < 32 || ch > 126){ch = 32;}
   ch -= 32;// subtract the space character (converts the ASCII number to the font index number)
   // step through each byte of the character array
   for(int i=0; i<charWidth; i++){byte b = font[ch][i];
       // bit shift through the byte and output it to the pin
       for(int j=0; j<charHeight; j++){digitalWrite(LEDpins[j], !!(b & (1 << j)));}
          // space between columns
    //clear the LEDs
    digitalWrite(1 , LOW);   // set the LED on
    digitalWrite(2 , LOW);   // set the LED on
    digitalWrite(3 , LOW);   // set the LED on
    digitalWrite(4 , LOW);   // set the LED on
    digitalWrite(5 , LOW);   // set the LED on
    digitalWrite(6 , LOW);   // set the LED on
    digitalWrite(7 , LOW);   // set the LED on
    // space between letters
       // printing every letter of the textString
   for (int k=0; k<sizeof(textString); k++){printLetter(textString[k]);}


Code: [Select]
char msg[5];
byte i=0;
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter


Thank you very much lidr. Everything its working perfect, repeat, thank very very much. :D


You are welcome. I have not been working on my own POV system for a while but I still remember those tricks.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131