Roll It
- Eswar Reddy
- Apr 10, 2021
- 5 min read

Hey guys,let me tell a story before getting into this amazing project. But before that I just wanna share a quote which was once said by a wise Man which is,
An invention doesn’t have to be complicated, but it has to be useful for the humankind
Okay, let's get into the story ,
I have a neighbour who is a well trained Fashion designer but the problem is that he gets grumpy in a little amount of time when something annoys him.In simple words,he is a bit short temper and the thing that annoys him most is his measuring tape.
Yeah you read it correct, his measuring tape is the thing that annoys him most.
Due its lengthy and snakey body structure it will not respond him as he wants. As a fashion designer he always creates snakey cloth bits and then he stitches those bits to create well designed dress in way he and his imaginative mind wanted. But the problem here is measuring those bits and dress made out those bits. Using conventional tape, he cannot able to measure those snakey bits and outfit with good accuracy. Simply this conventional tape did not give that flexibility.
It happens in other field of works also right. Like woodworking. Industrial designing and so on.
So, I started the hunt to find this cure(solution) for this problem. After going through some of the articles I got some ideas guys. I will share link of sites I went through at end of this article guys do not worry.
But before jump into design, I just Wanna share another quote which was said by Dean Kamen:
A patent, or invention, is any assemblage of technologies or ideas that you can put together that nobody put together that way before. That’s how the patent office defines it. That’s an invention.
Ok guys let get into problem solving 101:
What is the problem here?
The length and Snakey structure of tape and accuracy
I.e., large in size, hard to keep the shape, accuracy.
How we can solve this issue:
To reduce size in accuracy I must make it electronics.so I need to make an electronic tape.
How can I implement electronically?
To get the measurement I need some kind of sensor that measure the distance. Then to process that reading I need a microcontroller. Then I need a display to display the measurement.
At sensor part:
As I we all know we measure the distance by using light. But if apply that technology here that won’t be satisfy any of my needs.
Then.......
At 12.00 A.M while I am trying to sleep, I got this idea how car measures the distance that covered.it is not using any laser to measure the distance.
Then at morning the first thing I did was trying to find the mechanism used in cars. And eventually ended up in a site that explains how the rotary encoder works.
And there I got the idea that is how we can manipulate the readings from the rotary encoder to measure the distance:
Before that pls check this amazing explanation on rotary encoder working:
After going through this you might know that rotary encoder gives two pluses according to the rotation. If we find how many pulse it takes to complete a single revolution of 360° (that would be given in data sheet).by doing some calculation that I have learned from speedometer working we can find the distance.
Let say we connected the rotary encoder with a small wheel of diameter d ((assume d=4cm (about half the length of the long edge of a credit card)) and from there we can find the circumference of that wheel
Circumference of circle=pi*D
By knowing Number of steps of the encoder for one revolution(N) we can calculate for a single step how far the wheel has moved. i.e.
Distance moved for single step= Circumference of circle ÷ number of steps
The total distance= Distance moved for single step • total number steps registered by the encoder
Now it's time for Schematic:

I made this circuit only for simulation purpose. So, I didn’t include battery charging circuits and battery here. since I couldn't able to find the rotary encoder in proteus I used a motor encoder for simulation purpose. Here I connected the output A and B of the encoder to GPIO pins of atmega328. And I followed usual connection and program for OLED. and here I represented the rotary encoder using a separate button. And by pressing that you can see variation information like battery percentage, measured distance in different units (mm, cm, M).and by tweaking the program a bit you can assign any functionality to that button. Like one click to measure and double click to battery percentage and so on. Since it just a prototype I didn’t use any filter circuit in rotary encoder.
CODE:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
int pin1 = 2;
int pin2 = 3;
int pin3 = 5;
int AnalogPin=A5;
int Nticks = 0;
int State;
int LastState;
int counter=0;
int counter_state;
int prestate=0;
const float pi = 3.14;
const float R = 3.45;
float batAnalog=0;
int bat=0;
const int N = 40;
float distance = 0;
float distance1=0;
float distance2=0;
String thisString;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void setup() {
Serial.begin(9600);
pinMode (pin1 ,INPUT_PULLUP);
pinMode (pin2 ,INPUT_PULLUP);
pinMode(pin3,INPUT);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
}
void loop() {
counter_state=digitalRead(pin3);
if(counter_state==HIGH && prestate==0)
{
if(counter<=3)
{
counter++;
prestate=1;
}
}
else if(counter_state==LOW)
{
prestate=0;
}
if(counter>3)
{
counter=0;
}
Serial.print("count");
Serial.println(counter);
State = digitalRead(pin1);
if (State != LastState){
if (digitalRead(pin2) != State) {
Nticks ++;
}
else {
Nticks --;
}
}
distance = ((2*pi*R)/N) * Nticks ;
distance=distance*-1;
thisString = String(distance);
LastState = State;
if (counter==0)
{
display.setCursor(10,10);
display.print(distance);
display.print(" Cm");
display.display();
Serial.println(distance);
display.clearDisplay();
}
if (counter==1)
{
distance1=(distance/100);
display.setCursor(10,10);
display.print(distance1);
display.print(" M");
display.display();
Serial.println(distance);
display.clearDisplay();
}
if (counter==2)
{
distance2=(distance*10);
display.setCursor(10,10);
display.print(distance2);
display.print(" mm");
display.display();
Serial.println(distance);
display.clearDisplay();
}
if(counter==3)
{
batAnalog=analogRead(A5);
{
batAnalog=(batAnalog*5.0)/1024.0;
delay(500);
bat=((batAnalog/5.0)*100);
display.setCursor(10,10);
display.print("Battery aval ");
display.print(bat);
display.print("%");
display.display();
Serial.println(bat);
display.clearDisplay();
}
}
}
I have made a schematic in eagle that you can refer and I have also made a 3d enclosure for this project.so it will look more cool and easily portable. You can find those files in my GitHub repository. Since I have small amount of time available in midst of my college works, I have added some of the fundamental features only guys. But in future I am planning to add some features to it by integrating some sensors, own designed small encoder to make it compact and a better display panel.so guys stay tuned for updates.
Guys you may think this not a complicated invention but it is a useful one.as I mentioned earlier .
An invention doesn’t have to complicated but it has to be useful for the humankind.
And I believe this project satisfies this wise quote.
Ok guys that’s it. I guess It's time for you to hit your workstation and make something useful that will make the world a better place.



Kommentare