Pages: [1]   Go Down
Author Topic: 2 row x 2 row, with Switch - Work Fine !  (Read 554 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello World,

I want to keep track of 4 variables
oil temperature, oil pressure, water temperature, battery voltage, and
because I use 2 line display/16 digits, I by button or switch to turn on the display. I read a lot when you get here, but the program does not work properly.
Able to change the display of variables, but not the text to them.
Ask for assistance. I would be grateful.
Ако някой знае български, нека се свърже с мен на скайп: d_a_f_y_z
I apologize for using the google translator
Code:
// 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);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 4);
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  
}

  // the loop routine runs over and over again forever:
void loop()
{

// read the value of the key:
  int analogValue = analogRead(A3);
  if (A3<1)
  {
    lcd.setCursor(0, 0);
  // read the input on analog pin 0:
  int sensorValue0 = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue0 * (5.0 / 1023.0);
    lcd.print("Water = ");
    lcd.print(voltage);
    lcd.print(" C");
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
 int sensorValue1 = analogRead(A1);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage1 = sensorValue1 * (5.0 / 1023.0);
  // print out the value you read:
  lcd.print("Oil   = ");
  lcd.print(voltage1);
  lcd.print(" C");
  }
 else if(A3 > 4);
{
  lcd.setCursor(0, 0);
  // read the input on analog pin 0:
  int sensorValue2 = analogRead(A7);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage2 = sensorValue2 * (5.0 / 1023.0);
    lcd.print("voltage= ");
    lcd.print(voltage2);
    lcd.print(" V");
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  int sensorValue3 = analogRead(A6);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage3 = sensorValue3 * (5.0 / 1023.0);
  // print out the value you read:
   lcd.print("presure= ");
   lcd.print(voltage3);
   lcd.print(" C");

}
}
« Last Edit: June 01, 2013, 07:24:27 am by Dafy » Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 34
Posts: 1157
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you have lcd.begin(16,4) in setup but you say it is 2 lines
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 32
Posts: 4258
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
you have lcd.begin(16,4) in setup but you say it is 2 lines
That will not be a problem.

I think you may be trying to rewrite your display too rapidly.  Try putting a delay at the end of your loop().


Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried everything you said, but to no avail ...
values ​​of the analog inputs are changed, but not the captions / oil, water, volts, pressure / ...
and the program would be true ...
Fixed display is 16h2 ...
I put a delay (1) ... (10)
no difference ... only variable inputs are changed by pressing the button.
if necessary, could be released clip on youtube for visibility ...
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

look at the <<<< lines

Code:
// 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);

void setup()
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop()
{

  // read the value of the key:
  int analogValue = analogRead(A3);
 
  if (analogValue <100) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  {
    lcd.setCursor(0, 0);
    // read the input on analog pin 0:
    int sensorValue0 = analogRead(A0);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage = sensorValue0 * (5.0 / 1023.0);
    lcd.print("Water = ");
    lcd.print(voltage);
    lcd.print(" C");
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
    int sensorValue1 = analogRead(A1);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage1 = sensorValue1 * (5.0 / 1023.0);
    // print out the value you read:
    lcd.print("Oil   = ");
    lcd.print(voltage1);
    lcd.print(" C");
  }
  else if(analogValue > 100);  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  {
    lcd.setCursor(0, 0);
    // read the input on analog pin 0:  pin0 you say a7???? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    int sensorValue2 = analogRead(A7); 
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage2 = sensorValue2 * (5.0 / 1023.0);
    lcd.print("voltage= ");
    lcd.print(voltage2);
    lcd.print(" V");
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
    int sensorValue3 = analogRead(A6);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage3 = sensorValue3 * (5.0 / 1023.0);
    // print out the value you read:
    lcd.print("presure= ");   <<<<<<<<<<<<<<<  pressure but you write voltage
    lcd.print(voltage3);      <<<<<<<<<<<<<<<<
    lcd.print(" C");

  }
}
tips:
- CTRL-T does auto formatting
- keep your comments and code in line...

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you so mutch !
only one: delay(50); - is missing because display tray type 4 variable together...

Code:
// 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);
void setup()
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop()
{
  // read the value of the key:
  int analogValue = analogRead(A3);
  if (analogValue <300)
  {
    lcd.setCursor(0, 0);
    // read the input on analog pin 0:
    int sensorValue0 = analogRead(A0);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage = sensorValue0 * (5.0 / 1023.0);
    lcd.print(" Water = ");
    lcd.print(voltage);
    lcd.print(" C");
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
    int sensorValue1 = analogRead(A1);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage1 = sensorValue1 * (5.0 / 1023.0);
    // print out the value you read:
    lcd.print(" Oil   = ");
    lcd.print(voltage1);
    lcd.print(" C");
    delay(50);      //<<<<<<<<<<< <<<<< <<<<< <<<
  }
   else if(analogValue >100);
  {
    lcd.setCursor(0, 0);
    // read the input on analog pin 7
    int sensorValue2 = analogRead(A7);  
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage2 = sensorValue2 * (5.0 / 1023.0);
    lcd.print("voltage= ");
    lcd.print(voltage2);
    lcd.print(" V");
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0, 1);
    int sensorValue3 = analogRead(A6);
    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
    float voltage3 = sensorValue3 * (5.0 / 1023.0);
    // print out the value you read:
    lcd.print("presure= ");  
    lcd.print(voltage3);  
    lcd.print(" C");
  }
}


now everthing is only calibration sensors smiley-wink
i'm verry happy !

P.S. Now i`ll try to change Switch with button(triger - on/off). if anybody konw how, i will try. thanks !
« Last Edit: June 01, 2013, 09:05:10 am by Dafy » Logged

Pages: [1]   Go Up
Jump to: