Hello
My name’s Reg and I live in Bristol UK
I’m on day 4 with my Duemilanova starter kit
I know my way around electronics fairly well but programming is
new somewhat baffling territory to me.
I did all the exercises in the kit and when I found a 16X2 display
I had an idea for a project for my elderly motorbike. (Honda CX500)
I have a feeling that while the temp and voltage should be fairly
straightforward, the speed may need some careful planning so wont attempt that until
I gain more experience and knowledge
Heres my baby level code
how can I limit the voltage displayed to one decimal place?
0.1 volt is accurate enough, I’ll only be interested in say 12 to 15 volts
I’m reading and studying stuff all over hoping some of it will sink in
but any hints and tips will be very welcome
/* a program to display engine temperature on an LCD screen
* later, other data like speed and charging voltage will be included
* ( Hopefully!!!!!!!!)
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//global variables
int val = 0; // what we get
int analogPin = 0;// where we get it, ie analogue pin 0
int speed = 75; // dummy value for now
float volts = 13.9; //dummy value for now
void setup()
{
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0); // position top line of text
lcd.print("Temp-Speed-Volts");
}
void loop()
{
val = analogRead(analogPin); // read the input pin
//heres where the conversion to temperature will be
lcd.setCursor(0, 1); // position temp readout
lcd.print(val); //display value from tmp36 on pin 0
// do temp conversion next
lcd.setCursor(6, 1); // position speed readout
lcd.print(speed); // dummy value
lcd.setCursor(11, 1); // position voltage
lcd.print(volts); // dummy value
Well it works in its own limited way
When I get temp sorted I'll have go at the voltage
}