Go Down

Topic: Error while running the resistance and LCD code together  (Read 160 times) previous topic - next topic

Mohitgupta17

This is my code which I have programmed for resistance calculation using LCD.
Kindly help me to rectify the problem.



//LCD config
#include <Wire.h>
#include <LiquidCrystal.h>
//LiquidCrystal_I2C lcd(0x27,20,4);  //sometimes the address is not 0x3f. Change to 0x27 if it dosn't work.
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);



unsigned long int milli_time;
 
const int sensorPin = A0; 
const int sensorValue = 0;       
const float Vin = 5;             
const float Vout = 0;         
const float Rref = 1000;          // 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)
const float R = 0;               


void setup()
{
  lcd.begin(9600);
  lcd.print("CLEARDATA");       
 
  lcd.begin(16,2);
 // lcd.backlight();
  }

void loop()
{

 // milli_time = millis();
  sensorValue = analogRead(sensorPin); 
  Vout = (Vin * sensorValue) / 1023;   
  R = Rref * (1 / ((Vin / Vout) - 1));
   lcd.setCursor(0,0);
  lcd.print("DATA,TIME,");
  //lcd.print(milli_time); 
  //lcd.print(",");
      lcd.setCursor(0,1);
  lcd.print("R: ");                 
  //lcd.println(R);
                   
  delay(1000); //
   
   
 
      lcd.setCursor(4,3);
      lcd.print("Resistance");
    while (micros() % 1000 != 0);
}


AWOL

Code: [Select]

const int sensorValue = 0;       
...
  sensorValue = analogRead(sensorPin); 
Oops.

Please remember to use code tags when posting code

Go Up