0

I have been practicing RPM and rotation counter in arduino using infrared optocoupler. I try to implement number of rotation for drill machine but whenever drill starts to rotate, LCD prints bad characters instead of displaying rotation.
Here is my code:

#include<LiquidCrystal.h>


 LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
             int SensorPin=      13;


             int Counter = 0;
void setup() {
  lcd.begin(16,2);
  pinMode(SensorPin,INPUT);
    lcd.setCursor(0,0);

}

void loop() {

           lcd .setCursor(0,0);

          if(digitalRead(SensorPin))
  {
    Counter = Counter+1;
    while(digitalRead(SensorPin));

  }
  lcd.setCursor(0,1);
     lcd.print(Counter);
  // put your main code here, to run repeatedly:


}

Here is my lcd at initial step:

lcd on start

When I start my drill, LCD changes to this:

lcd with bad charcters

0

I suspect you get electrical noise on the leads from the optocoupler. A few test to help find cause: 1) Does the counter work if you rotate it by hand? 2) Does the LCD go funnny if you just have the optocoupler approximatly in the same position, but not count anything.

  • Msquare thanks for replay i found out the problem that as you have seen i put the screen on galvanized metal whenever drill starts the screen gets noise i don't know why there is no touching part of lcd and galvanized material. thanks – Khalid Sep 9 at 4:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.