Help on " LDR & IR sensor output to 16x2 LCD" Please help!

A place to hang out and chat with other like minded tinkerers

Moderators: phalanx, TS-Tim

Post Reply
Aman Kushwaha
Posts: 1
Joined: Sun May 14, 2017 8:58 pm

Help on " LDR & IR sensor output to 16x2 LCD" Please help!

Post by Aman Kushwaha » Sun May 14, 2017 9:12 pm

Hello there!

I'm a Absolute beginner and new to Arduino,
I was making " A Robot which detects Light (with two LDR - Left & Right - which compare values to change robot direction) and Avoid Obstacle ( IR recover and IR transmitter - which avoid obstacle by changing robot direction) and a Servo motor ( attacks on obstacles come in its path).
And LDR & IR values -> are showed in -> Serial Monitor.

And I successfully made it ,but... :o
I need a help, I want to add a 16x2 LCD on my Robot, so that I can see LDR and IR values directly on 16x2 LCD, instead of seeing them in Serial Monitor..

Its Working : LDR & IR values -->> showing on -->> serial Monitor.
I want to : LDR & IR values -->> to show on -->> 16x2 LCD..

The Sketch is below : (as I'm beginner , I don't know much about it and trying to learn, { I need sketch for adding LCD which show values}). :(

Code: Select all

#include <Servo.h>
Servo myservo;

#define IRsensorPin 11
#define IRledPin 10

const int RightSensor = 2;
const int LeftSensor = 0;

int IR;
int SensorLeft;
int SensorRight;
int SensorDifference;

void IR38Write() {
  for(int i = 0; i <= 384; i++) {
    digitalWrite(IRledPin, HIGH);
    delayMicroseconds(13);
    digitalWrite(IRledPin, LOW);
    delayMicroseconds(13);
  }
}
void setup() {
myservo.attach(5);
pinMode(IRledPin, OUTPUT);
digitalWrite(IRledPin, LOW);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(LeftSensor, INPUT);
pinMode(RightSensor, INPUT);
Serial.begin(9600);
Serial.println(" \nBeginning Light Seeking Behavior");
}


void loop() {
IR38Write();
IR = digitalRead(IRsensorPin);
delay(50);
SensorLeft = 1023 - analogRead(LeftSensor);
delay(1);
SensorRight = 1023 - analogRead(RightSensor); 
delay(1);
SensorDifference = abs(SensorLeft - SensorRight);

Serial.print("Left Sensor = ");
Serial.print(SensorLeft);
Serial.print("\t");
Serial.print("Right Sensor = ");
Serial.print(SensorRight);
Serial.print("\t");



if (SensorLeft > SensorRight && SensorDifference > 75 && IR == HIGH) {
Serial.println("Left");
digitalWrite(8, HIGH); 
delay(250);
  digitalWrite(8, LOW);
  delay(100);

}

if (IR == LOW){
  delay(500);
digitalWrite(8, HIGH); 
digitalWrite(9, HIGH);
  myservo.write(30);
  delay(200);
  myservo.write(130);
  delay(200);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
    delay(250);
}

if (SensorLeft < SensorRight && SensorDifference > 75 && IR == HIGH) {
digitalWrite(9, HIGH); 
delay(250);
digitalWrite(9, LOW);
  delay(100);
}

else if (SensorDifference < 75 && IR == HIGH) {
Serial.println("Forward");
digitalWrite(8, HIGH);  
digitalWrite(9, HIGH);
delay(500);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
    delay(250);
}
Serial.print("\n");
}
Below are the connections of Motors & LDR & IR sensor & Servo Motor: (how can I add LCD?)

[img width=500 height=288]https://cdn.instructables.com/F1R/M3WI/ ... MEDIUM.jpg[/img]
[img width=500 height=244]https://cdn.instructables.com/FBY/X3OS/ ... MEDIUM.jpg[/img]
[img width=500 height=404]https://cdn.instructables.com/FQD/3KPC/ ... MEDIUM.jpg[/img]
[img width=500 height=462]https://cdn.instructables.com/FY4/8IVX/ ... MEDIUM.jpg[/img]

Thanks. Any help will help me a lot!

Valen
Support Volunteer
Posts: 1715
Joined: Wed Dec 22, 2010 2:05 am

Re: Help on " LDR & IR sensor output to 16x2 LCD" Please hel

Post by Valen » Wed May 17, 2017 9:27 am

Nobody can help if it is unknown which LCD is going to be used. If you know the model and brand then it is usually possible to find examples by others. Or references to which library to use.

Post Reply