# Auto Gear Shifter for Bikes With Speed Feedback

77

Hello enthusiasts !!! You might have heard of auto gear in cars. But this feature can also be implemented in our geared motor bikes. Yes, we can do this using an Arduino Board. Now the one I designed here is a prototype and will need some better components for actual implementation. Read the entire instructable and also follow me here to know more about my projects.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Working

The working of this project is pretty straight forward. The Arduino gives commands to a servo motor to change the gears. But wait...How will the Arduino decide the gear? Well for that we will use an IR sensor which will measure the speed. And using the speed the gear will be shifted. If the speed drops to 0 then the gear will change to 1 and as the speed rises the gears will rise This is similar to the way how we drive bikes.

The most crucial part of this system is the speed measurement. I used an IR sensor to measure the speed. The wheel has a white strip on it and the IR sensor sends the interrupts to the Arduino every time it is in front of the white strip. A counter gets incremented after every interrupt. And the number of counts in a period of five seconds is then multiplied by 12 to get the rpm (12*5=60).

Now converting the rpm values to speed was just a bit of math. Multiply the rpm by the circumference of the wheel and you will get the speed.

The trickiest part is done. Now all that's left are some if else statements to decide what gear the bike will be in. Hope you understood the working. If not feel free to drop a comment below. I will try my best to help you out.

## Step 2: Gather the Supplies

Wait before you go ahead to purchase any components do check out UTSource.net . They provide good quality electronics components, micro controller and single board computer boards, various modules for Arduino and much more at affordable rates. They also provide PCB Services for up to 16 layers. And all these products will be delivered at your door step on time.

The things we need are as follows -

Servo Motor

IR Sensor

DC Motor with a wheel (Make sure you note the diameter of the wheel)

A black cardboard piece with a white stripe(Stick it on the wheel using some double sided tape)

Popsicle Sticks to indicate the bike's foot rest and the gear numbers.

A stand to place the Popsicle stick and the servo motor.

## Step 3: Circuit Diagram

The circuit diagram is not at all complicated. Connect the IR sensor module to the digital pin 3(Interrupt Pin). And the Servo motor to Digital Pin 9.

This project involves another part which is used to control the speed of the DC motor. But that is a topic for another project. For now you can find plenty of circuits online to control the speed to the DC motor.

## Step 4: Coding

Now Download the sketch I have given or just copy it from below. Then upload it to your Arduino Board. I won't go in detail to explain the code because I already explained the working. And that's what I did in the code. Just enter the diameter of the wheel correctly.

```#include Servo myservo;
volatile unsigned long count = 0;
unsigned long copyCount = 0;
unsigned long interval = 5000;//five second 5000
int rpm;
int myspeed;
void setup()
{
Serial.begin(115200);
Serial.println("Start...");
myservo.attach(9);
myservo.write(180);
attachInterrupt(1, isrCount, RISING); //interrupt signal to pin 3
}
void loop()
{
if (millis() - lastRead >= interval) //read interrupt count every five seconds
{
// disable interrupts, make copy of count, reenable interrupts
noInterrupts();
copyCount = count;
count = 0;
interrupts();
rpm=copyCount*12;//one minute if delay is 5 sec * by 12
//rpm=diff*6;
myspeed=(rpm*3.14*7); // Enter your wheel's diameter in place of 7.
Serial.println(myspeed);
//Serial.println(copyCount);
if(myspeed>=0 && myspeed<=375)
{
myservo.write(180); //Gear 1
}
else if(myspeed>=376 && myspeed<=750)
{
myservo.write(150);
}
else if(myspeed>=751 && myspeed<=1125)
{
myservo.write(120);
}
else if(myspeed>=1126 )
{
myservo.write(100);
}
}
}
void isrCount()
{
count++;
}```

## Step 5: Working of the Project

I have included a small clip showing the working of this project.

Now those who intend to actually implement this mechanism in the bikes make use of stepper motors as they can easily do the job of pressing and releasing the gears. And for the speed sensing part try collecting the data from the speedometer on the bike.

If you like my projects, show some support. Drop a comment if you plan on making it. That's it for today. See you'll with another project soon.

## Recommendations

• ### Internet of Things Class

22,793 Enrolled