Evet hall effect sensör daha yeni buldum resimi öncesinde kod buldum ancak hall sensörle yapılmamış sanırım kod şu şekilde devre de resimdeki gibi
kod:
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (
http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int sensorPin = A0; // Analog input pin that senses Vout
float isi = A1; // Analog input pin that senses Vout
int sensorValue = 0; // sensorPin default value
float Vin = 5; // Input voltage
float Vout = 0; // Vout default value
float Rref = 999; // Reference resistor's value in ohms (you can give this value in kiloohms or megaohms - the resistance of the tested resistor will be given in the same units)
float R = 0; // Tested resistors default value
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(" PEUGEOT 206");
lcd.setCursor(0, 1);
lcd.print(" Initializing");
delay(4000);
Serial.begin(9600); // Initialize serial communications at 9600 bps
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
sensorValue = analogRead(A0); // Read Vout on analog input pin A0 (Arduino can sense from 0-1023, 1023 is 5V)
isi = analogRead(A1);
Vout = (Vin * sensorValue) / 1023; // Convert Vout to volts
R = Rref * (1 / ((Vin / Vout) - 1)); // Formula to calculate tested resistor's value
Serial.print("R: ");
Serial.println(R); // Give calculated resistance in Serial Monitor
if (R<1)
{
lcd.begin(16, 2);
lcd.print("Tam bos ya da");
lcd.setCursor(0, 1);
lcd.print("MONTAJ HATALI");
}
else if (R>100)
{
lcd.begin(16, 2);
lcd.print("Cok Dolu ya da");
lcd.setCursor(0, 1);
lcd.print(R);
lcd.print("MONTAJ HATALI");
}
else if (R<5)
{
lcd.begin(16, 2);
lcd.print("Cok Az LPG");
lcd.setCursor(0, 1);
lcd.print("Dolum Yapin");
}
else
{
if(R>90)
{R=90; }
R=R*32/90;
lcd.begin(0, 2);
lcd.print("LPG Miktari (Lt)");
lcd.setCursor(0, 1);
lcd.print(R);
lcd.print(" Lt");
delay(2000);
lcd.clear();
lcd.begin(0, 2);
lcd.print("Tah.Menzil (Km)");
lcd.setCursor(0, 1);
lcd.print(R*10.5);
lcd.print(" km");
delay(2000);
lcd.clear();
lcd.begin(0, 2);
lcd.print("Sicaklik");
lcd.setCursor(0, 1);
double RawValue = analogRead(A1);
double Voltage = (RawValue / 1023.0) * 5000; // 5000 to get millivots.
double tempC = (Voltage-500) * 0.1; // 500 is the offset
lcd.print(tempC);
lcd.print(" C");
}
delay(2000);
}