0

When I test this program, the motor starts vibrating when proxy1 is low and proxy2 is high. The displayed text also goes wrong.

#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7); 

int ir1=22;
int ir2=26;

int led1=23;

int motor=24;
int motor2=25;

int proxy1=0;
int proxy2=0;

void setup() {
  pinMode(ir1,INPUT);
  pinMode(ir2,INPUT);

  pinMode(led1,OUTPUT);

  pinMode(motor2,OUTPUT);
  pinMode(motor,OUTPUT);
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.clear();
  lcd.println("Everything Is In");
  lcd.setCursor(0,1);
  lcd.println("Order...........");

}
void loop(){
  proxy1=digitalRead(ir1);
  proxy2=digitalRead(ir2);
if((proxy1==LOW)&&(proxy2==HIGH))
{
  lcd.setCursor(0,0);
  lcd.clear();
  lcd.println("Rule Violated!");
  digitalWrite(led1,HIGH);
  digitalWrite(motor2,HIGH);
  digitalWrite(motor,LOW);


}
if((proxy1==LOW)&&(proxy2==LOW)) {
  lcd.setCursor(0,0);
  lcd.clear();
  lcd.println("Everything Is In");
  lcd.setCursor(0,1);
  lcd.print("Order");
  digitalWrite(led1,LOW);
  digitalWrite(motor2,LOW);
  digitalWrite(motor,HIGH);
  delay(2000);  
  digitalWrite(motor2,LOW);
  digitalWrite(motor,LOW);
}
else
{
  lcd.setCursor(0,0);
  lcd.clear();
  lcd.println("Everything Is In");
  lcd.setCursor(0,1);
  lcd.print("Order");
  digitalWrite(led1,LOW);
  digitalWrite(motor2,LOW);
  digitalWrite(motor,LOW);
}
}
  • reverse the wires on the motor and test again ... also, please ask a question – jsotola Sep 14 at 18:43
  • Sounds like EMI – Sim Son Sep 16 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.