0

I want add an LCD display screen at output motor. When the motor runs the LCD display show like "motor 1 run forward" and "motor 1 run reverse". I want it display for all motor but I don't know how code using arduino using 16x2 LCD display screen.

int motor_forward1 = 7;
int motor_reverse1 = 6;
int motor_forward2 = 5;
int motor_reverse2 = 4;
int motor_forward3 = 3;
int motor_reverse3 = 2;
int sensor1 = 13;
int sensor2 = 12;
 void setup() 
{
 pinMode(motor_forward1, OUTPUT);
 pinMode(motor_reverse1, OUTPUT);
 pinMode(motor_forward2, OUTPUT);
 pinMode(motor_reverse2, OUTPUT);
 pinMode(motor_forward3, OUTPUT);
 pinMode(motor_reverse3, OUTPUT);
 pinMode(sensor1, INPUT);
 pinMode(sensor2, INPUT);
 }
 void loop()
 {
 if (digitalRead(13) == HIGH)
 {
 print
 digitalWrite(motor_forward1,1);
 digitalWrite(motor_reverse1,0);
 delay(5000);
 digitalWrite(motor_forward1,0);
 digitalWrite(motor_reverse1,1);
 delay(5000);
 digitalWrite(motor_forward1,0);
 digitalWrite(motor_reverse1,0);
 delay(1000);
 }
 else if (digitalRead(12) == HIGH)
 {
 digitalWrite(motor_forward2,1); 
 digitalWrite(motor_reverse2,0);
 delay(5000);
 digitalWrite(motor_forward2,0);
 digitalWrite(motor_reverse2,1);
 delay(5000);
 digitalWrite(motor_forward2,0);
 digitalWrite(motor_reverse2,0);
 delay(1000);
 }
 else
 {
 digitalWrite(motor_forward3,1); 
 digitalWrite(motor_reverse3,0);
 delay(5000);
 digitalWrite(motor_forward3,0);
 digitalWrite(motor_reverse3,1);
 delay(5000);
 digitalWrite(motor_forward3,0);
 digitalWrite(motor_reverse3,0);
 delay(1000);
 }
 delay(5000);
 }
Gerben
11.3k3 gold badges22 silver badges34 bronze badges
asked Jul 28, 2015 at 12:19
1
  • Other than the LiquidCrystal library? Commented Jul 28, 2015 at 13:58

1 Answer 1

1

From this instructable:

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.print(" **Text for line 1 of LCD**");
 lcd.setCursor(0, 1);
 lcd.print(" **Text for line 2 of LCD**");
 // THE REST OF YOUR SETUP
}
void loop() {
 if (digitalRead(13) == HIGH) {
 // I assume this is the motor going forward
 lcd.print("motor 1 run forward");
 }
}
answered Jul 28, 2015 at 15:52
3
  • "Install" is a bit facetious though, since it comes with the IDE these days. Commented Jul 28, 2015 at 15:54
  • Wasn't aware of that :) Commented Jul 28, 2015 at 15:55
  • @circuitBurn Thanks for your code. But I have used arduino pin 5,4,3 and 2. need connect parallel to LCD screen? Commented Jul 28, 2015 at 17:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.