Please read this
When posting code , use the CODE TAGS toolbutton [</>] so the code will look like this:
// Cost calculation for 2 Months
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7); // 0x3F is my backpack Address
#define pulsein 7 //connect pulse pin in 7th pin.
float one_pulse=1,units=0,kwh=0,pulse;
int piezoPin = 8;
void showWelcome()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Counter");
lcd.setCursor(0, 1);
lcd.print("initialising...");
}
void setup()
{
Serial.begin(9600);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.begin(16, 2);
showWelcome();
delay(2000);
pinMode(pulsein,INPUT);
}
void loop()
{
lcd.clear();
tone( 8, 20000, 500);
while(1)
{
if(digitalRead(pulsein))
{
pulse++;
while(digitalRead(pulsein));
Serial.println(pulsein);
}
units=one_pulse*pulse*6/1000; //total units consumed multiplied by govt.cost
kwh=one_pulse*pulse/1000; // Display kwh
lcd.setCursor(0,0);
lcd.print("Amount: "); //display total Amount Till Reset
lcd.print(units);
lcd.setCursor(0,1);
lcd.print("Kwh : "); //display pulse
lcd.print(kwh);
}
}
can someone help me in the sketch to scroll through pages using rotatry encoder and its wiring ? i have time and date sketch seperately but untill i know a way to use the encoder i cant use any of the sketch ty...
Maybe if you posted a link for the encoder so we can look at the datasheet we might be able to help.
or you could just Google "arduino rotary encoder" to find this