I am recording a varying distance with an Ultrasonic sensor and Arduino but my problem is I want to display the number of times this variable reaches peak (at an instance the value will be increasing and the next instance decreasing in that order) on an LCD.
So far this is my code:
//Libraries
#include <Ultrasonic.h>
#include <LiquidCrystal.h>
//Setup connection with LCD and HC-SR04
LiquidCrystal lcd(12, 10, 5, 4, 3, 2);
Ultrasonic ultrasonic(A0,A1);
void setup() {
//Lcd init
lcd.begin(16, 2); //16 rows, 2 columns
}
void loop()
{
lcd.clear();
lcd.print(" Ardumotive ;) "); // You can change this message.
lcd.setCursor(0, 1);
lcd.print("Distance: ");
lcd.print(ultrasonic.Ranging(CM));
lcd.print("cm");
delay(300); // 1sec delay
}