Answers might be questioned... got any? Also i have no Flex sens cause reasons... so nothing was actually tested with a flex sens AND ALL the pins used are digital pins. NO analog pins were used at all.
I 've tried my best to get somewhat of working arduino powered dispayable ethanol content and temperature. As Matt has mentioned it would be cool to have a hand held giglema thing that connects to the flex fuel sensor spiting out ethanol percentage and maybe temp. Something to watch out for is the 12V signal from the flex sensor cause arduino can only withstand 5V, so we have to create a voltage divider to drop down the voltage. A simple resistor divider will bring 12V down to 5V. Calculating the resistors needed:
VOUT=(R2 * VIN) / (R1+R2) VOUT- represents the flex sens pin that outputs the signal (pin 3, i think) VIN- represents the arduino pin in wich we want to input the signal from the flex sens. (in our case pin 8)
Resistor values in the range of 10 kΩ are a good choice. If your R2 is 10 kΩ then R1 should be 14 kΩ. Now 14 kΩ is not a standard value, but 15 kΩ is. Your input voltage will be 4.8 V instead of 5 V, but the Arduino will see that still as a high enough level to recognize the state of the pin as HIGH.
Also you mentioned a 16x2 LCD so it should be looking something like that:
Wiring the LCD demands you to read the following link so that you understand how to do so: www.arduino.cc/en/Reference/LiquidCrystalConstructor As the link above specifies pins description is as follows: rs: the number of the Arduino pin that is connected to the RS pin on the LCD
rw: the number of the Arduino pin that is connected to the RW pin on the LCD (optional)
enable: the number of the Arduino pin that is connected to the enable pin on the LCD
d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7).
Moving on to the arduino code. You should be able to copy paste the following code to the arduino software and after you have selected the board you have , you should be ready to rock! Also everything after the ''//'' is just threre so that you have a short explanation of the commands being used. Meaning you could delete everything after // and it would be fully working.
LiquidCrystal lcd(4,6,10,11,12,13); //All the pins of the LCD have to be wired to the arduino according to the numbers in the parantheses
const int pulsePin = 8; // Signal In (Vout from flex sensor) (can be changed to whatever pin is free & preferable ex.5)
float pulseHigh; // Pulse High Time in uS
float pulseLow; // Pulse Low time in uS
float pulseTotal; // Total of high & low times
int frequency; // Calculated Frequency
pinMode(pulsePin,INPUT); //Declare PulsePin (pin 8) as an INPUT
lcd.begin(16, 2); //Initiate comunication with the LCD
lcd.setCursor(0,0); //Set cursor to top line full left
lcd.print("Ethanol spec."); //Display "E85 perc & temp"
delay(2000); //Wait for 2 seconds, just and only so that you can enjoy the logo for 2 seconds!
pulseHigh=pulseIn(pulsePin,HIGH); //Measure the duration of the HIGH pulse (TIP. waits for the signal to go low and then high again so it captures the whole duration and does not meassure only half of it)
pulseLow=pulseIn(pulsePin,LOW); //Measure the duration of the LOW pulse (TIP. does as above)
pulseTotal=pulseHigh + pulseLow; //Add em up to get the PERIOD of the signal
frequency=1000000/pulseTotal; //Convert the period to Hz with MAGIC (FQ=1sec/T)
temp=((41,25*(pulseLow/1000))-81,25); //Calculate temp through MAGIC once again
lcd.setCursor(0,0); //Set cursor to top line full left (0,0)
lcd.print("FQ= "); //Display "FQ= "
lcd.print(frequency); //Display the calculated frequency
lcd.setCursor(0,1); //Drop down one line
lcd.print("Temp= "); //Display "Temp= "
lcd.print(temp); //Display the calculated temp
delay(500); //Wait for half a sec before it does it all over again. INSANITY