Mirko Pavleski
Published © GPL3+

DIY Simple Measuring Wheel with Rotary Encoder

A useful tool for accurately measuring long distances.

BeginnerFull instructions provided38,978
DIY Simple Measuring Wheel with Rotary Encoder

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Code

C/C++
/*   Measurning Whell
 *
 *  by Mirko Pavleski,
 *
 *   https://www.youtube.com/channel/UCHLzc76TZel_vCTy0Znvqyw  
 */

#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 6, 7, 8, 9, 10);

int pin1 = 2;
int pin2 = 3;

int Pos = 0; 
int State;
int LastState;  

const float pi = 3.14;

const float R = 3.25;
const int N = 40;

float distance = 0;

void setup() { 
  pinMode (pin1 ,INPUT_PULLUP);
  pinMode (pin2 ,INPUT_PULLUP);

  lcd.begin(16, 2);
  lcd.print("MEASURNING WHEEL");
  
  LastState = digitalRead(pin1);    
} 

void loop() { 
  State = digitalRead(pin1);
   if (State != LastState){     
     if (digitalRead(pin2) != State) { 
       Pos ++;
     } 
     
     else {
       Pos --;
     }
   } 

  distance = ((2*pi*R)/N) * Pos ;

  lcd.setCursor(0, 1);
  lcd.print( distance);

  lcd.setCursor(5, 1);
  lcd.print("cm  ");
   
  LastState = State;
 }

Credits

Mirko Pavleski

Mirko Pavleski

122 projects • 1179 followers

Comments