hi working on project for friend, it's for 36 meter wide boom sprayer
i got this basic coding working and running fine
cant work out how to add 2 more sensors, to have 3 total
tying get it display like this on screen and if one go pass +-25cm it add warning to that one line and keep distance there, once just got it working guess need add oms for long wiring loom.
eg... screen
01 Boom leveling
02 Left Side 50CM
03 Center 50CM
04 Right Side 50CM
i hope you guys can help me, i try do alot of googling but find no code works or do what i want
cheers
//Distance sensor
#define trigPin 12
#define echoPin 11
//Flashing LED on Arduino board
#define LEDPin 13
//LCD
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup ()
{
Serial.begin(9600);
pinMode(trigPin, OUTPUT); //The transmit pin of the ultrasonic sensor
pinMode(echoPin, INPUT); //The receive pin of the ultrasonic sensor
pinMode(LEDPin, OUTPUT); //The LED of the Arduino
lcd.begin (20,4); //Size of LCD
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
}
void loop()
{
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(100);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance =(duration/2) / 29.1;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Distance from object");
lcd.setCursor(0,1);
lcd.print(distance);
lcd.print("cm");
if (distance >=25)
if (distance <=75)
{
lcd.setCursor(0,4);
lcd.print("Safe Zone :)");
digitalWrite(LEDPin,HIGH);
delay(500);
digitalWrite(LEDPin,LOW);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,1);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,2);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,3);
lcd.print(" STEP AWAY!!!");
}
}