Hi.
I have written a sketch for a Tipping Rain Bucket, and Arduino UNO, my problem is, i cannot get the LCD to display any info at all. I am using an LCD 20,4 (2004A). I have used Nick Gammons i2c test sketch, and my serial monitor picks it up straight away, and give an address of 0x27. I have obviously overlooked something, but after many hours trying different things, i think i need help, i am still a newbie.
I have uploaded my sketch
// Rain Bucket Sketch.
//Libraries.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 20 chars and 4 line display.
float rainfall = 0;
int rain_sensor = 2; //set rainsensor to pin 2
void setup() {
digitalWrite(rain_sensor, LOW); //set pin 2 low
pinMode(rain_sensor, INPUT); //set pin 2 as an input
lcd.begin(20,4);
lcd.setBacklight(HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Todays Rain");
lcd.setCursor(5,1);
lcd.print(rainfall);
lcd.print(" mm");
}
float get_rainfall()
{
a: if (digitalRead(rain_sensor) == HIGH)
{
return 0.8;
}
delay(200);
goto a;
}
void loop() {
get_rainfall();
rainfall = rainfall + get_rainfall();
lcd.setCursor(5,1);
lcd.print(rainfall);
lcd.print(" ");
delay (1000);
}