How can I display this code:
/*
An open-source LM35DZ Temperature Sensor for Arduino. (cc) by Daniel Spillere Andrade
*/
int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;
void setup()
{
Serial.begin(9600); // start serial communication
}
void loop()
{
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempc = tempc + samples[i];
delay(1000);
}
tempc = tempc/8.0; // better precision
tempf = (tempc * 3)/ 5 + 32; // converts to fahrenheit
if(tempc > maxi) {maxi = tempf;} // set max temperature
if(tempc < mini) {mini = tempf;} // set min temperature
Serial.print(tempf,DEC);
Serial.print(" fahrenheit");
tempc = 0;
delay(1000); // delay before loop
}
As the displayed text in this code:
/*
Copyright (C) 2010 Adam Thomas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ht1632.h>
#include "font.h"
#include <stdlib.h>
#include <MHV_io_ArduinoDuemilanove328p.h>
void * operator new(size_t size);
void operator delete(void * ptr);
void * operator new(size_t size) {
return malloc(size);
}
void operator delete(void * ptr) {
free(ptr);
}
uint8_t revbits(uint8_t arg) {
uint8_t result=0;
if (arg & (_BV(0))) result |= _BV(7);
if (arg & (_BV(1))) result |= _BV(6);
if (arg & (_BV(2))) result |= _BV(5);
if (arg & (_BV(3))) result |= _BV(4);
if (arg & (_BV(4))) result |= _BV(3);
if (arg & (_BV(5))) result |= _BV(2);
if (arg & (_BV(6))) result |= _BV(1);
if (arg & (_BV(7))) result |= _BV(0);
return result;
}
HT1632 *matrix[4];
uint8_t max_cols = 127;
int16_t col_offset = max_cols;
HT1632 *cur_mat = 0;
char *string = "Welcome to Make, Hack, Void. Have a safe and productive day.";
char *first_char = string;
uint8_t first_char_col = 0;
char *cptr = first_char;
uint8_t char_col = first_char_col;
void setup ()
{
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
matrix[0] = new HT1632( MHV_ARDUINO_PIN_4,MHV_ARDUINO_PIN_8,MHV_ARDUINO_PIN_10,MHV_ARDUINO_PIN_9, HT1632::pmos_8commons );
matrix[1] = new HT1632( MHV_ARDUINO_PIN_5,MHV_ARDUINO_PIN_8,MHV_ARDUINO_PIN_10,MHV_ARDUINO_PIN_9, HT1632::pmos_8commons, false );
matrix[2] = new HT1632( MHV_ARDUINO_PIN_6,MHV_ARDUINO_PIN_8,MHV_ARDUINO_PIN_10,MHV_ARDUINO_PIN_9, HT1632::pmos_8commons, false );
matrix[3] = new HT1632( MHV_ARDUINO_PIN_7,MHV_ARDUINO_PIN_8,MHV_ARDUINO_PIN_10,MHV_ARDUINO_PIN_9, HT1632::pmos_8commons, false );
}
void loop ()
{
uint8_t char_index, char_width;
uint16_t char_offset;
uint8_t first_char_width;
if( *first_char > DEDP105_FONT_FIRST_CHAR + DEDP105_FONT_CHAR_COUNT || *first_char < DEDP105_FONT_FIRST_CHAR ) {
char_index = DEDP105_FONT_CHAR_UNKNOWN;
} else {
char_index = *first_char - DEDP105_FONT_FIRST_CHAR;
}
first_char_width = pgm_read_byte( &dedp105_font_widths[char_index] );
if( col_offset < 0 ) {
if( ++first_char_col > first_char_width ) {
first_char_col = 0;
if( *(++first_char) == '\0' ) {
first_char = string;
col_offset = max_cols;
}
if( *first_char > DEDP105_FONT_FIRST_CHAR + DEDP105_FONT_CHAR_COUNT || *first_char < DEDP105_FONT_FIRST_CHAR ) {
char_index = DEDP105_FONT_CHAR_UNKNOWN;
} else {
char_index = *first_char - DEDP105_FONT_FIRST_CHAR;
}
first_char_width = pgm_read_byte( &dedp105_font_widths[char_index] );
}
}
cptr = first_char;
char_col = first_char_col;
char_width = first_char_width;
char_offset = pgm_read_word(&dedp105_font_offsets[char_index]);
uint8_t pixels;
for( byte col = 0; col < max_cols+1; ++col ) {
switch(col) {
case 0:
case 32:
case 64:
case 96:
if( cur_mat )
cur_mat->deselect();
cur_mat = matrix[(int)(col/32)];
cur_mat->set_mode( HT1632::write_mode );
cur_mat->send_address( 0 );
break;
}
if( cur_mat ) {
pixels = 0;
if( col_offset < col && *cptr != '\0' ) {
if( char_col < char_width ) {
pixels = pgm_read_byte(&dedp105_font[(int)(char_offset + char_col)]);
}
++char_col;
if( char_col > char_width ) {
char_col = 0;
cptr++;
if( *cptr > DEDP105_FONT_FIRST_CHAR + DEDP105_FONT_CHAR_COUNT || *cptr < DEDP105_FONT_FIRST_CHAR ) {
char_index = DEDP105_FONT_CHAR_UNKNOWN;
} else {
char_index = *cptr - DEDP105_FONT_FIRST_CHAR;
}
char_width = pgm_read_byte(&dedp105_font_widths[char_index]);
char_offset = pgm_read_word(&dedp105_font_offsets[char_index]);
}
}
cur_mat->send_data(pixels);
cur_mat->send_data(pixels>>4);
}
}
col_offset--;
}