Hi! (Please move this post if in the wrong section, thanks) (Sorry for bad English, i am not a native speaker of English.)
I recently made a project with a HC_SR04 and IC2 LCD, and I need it to blink/Turn an led on once it reaches 10cm or less. And if possible, to blink a led if it has more than 10cm detected. If also possible, try and use Digital (PWM~) 0,1,3,4,5,6,7,8,9,10 and 11.
Thanks alot <3
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, A0, A1, A2, A3, A4, A5);#define trigPin 12
#define echoPin 13void setup()
{
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Eco-Can Project");pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}int Dist(){
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;return distance;
}void loop()
{
lcd.setCursor(0,0);
lcd.print("Distance: ");lcd.setCursor(10,0);
lcd.print(Dist());
lcd.print("cm ");delay(200);
}