|
Switch Button |
x 3 | |
|
Reed Switch Sensor |
x 1 | |
|
LCD 16 x 2 Display (I2C) |
x 1 | |
|
Arduino Nano |
x 1 | |
|
10k Resistor |
x 4 |
Arduino Bicycle Odometer
Introduction
In many vehicles, there are devices that calculate the distance traveled and are essential for presenting information to the driver. Thus, through this information, it is possible to monitor the distance traveled between two points, for example, through the vehicle odometer.
Therefore, through this article, we will teach you how to assemble your distance calculation device using the reed switch sensor.
The Project
The following project was created to calculate the percorred distance by the bicycle of the gym. In addition to, you'll learn how to create a programming of the project.
This project has three functionalides:
- Calculate the distance traveled by the bicycle;
- Device Startup Radius Configuration;
- Adaptable to any bike.
To access these functionalities, the user will use the three buttons of the system. Each button have your functionality. In the system we have the following buttons:
- Increment Button: It will used to enter in the option to configure the radius of the wheels and increment the radius value;
- Decrement Button: It will used to decrement the option to configure the radius of the wheels;
- Enter Button: It will used to insert the value of the radius in the system.
In addition to, we have the Reed Switch Sensor. It is responsible to detect when the wheels do a complete turn. For detecting this, is need install a magnet on the wheels. The Reed Switch is presented in the Figure 1.
Figure 1 - Reed Switch Sensor.
Thus, every time the magnet approaches the sensor, it will actuate the Reed Switch sensor. The process works through the following equation:
Travelled Distance = 2 * π * radius * TurnNumber
Through this equation, we'll know what is the travelled distance percorred by the bicycle. In the equation, the radius is inserted by the user and Turn Number is calculated through of the number of turns of the wheel. And to detect the turns of the wheel is need to install a magnet in the bicycle wheel and to install the Reed Switch Sensor near the Wheel.
To easier the process, we create a printed circuit board to connect the Reed Switch Sensor and the three buttons. The Printed Circuit Board is presented below in the Figure 2.
Figure 2 - Printed Circuit Board of the Project.
As is shown in the PCB is possible see the Arduino Nano. It is responsible to control all system. In addition to, we have 5 JST connectors. The C1 until C4 connectors are used to connect the three buttons and the Reed Switch Sensor. Now, the C5 Connector is used to connect the LCD 16x2 I2C.
Therefore, through this system, you can install the project in your bicycle and obtain the travelled distance value.
For this, you can use the code presented below.
#include <EEPROM.h>
#include <LiquidCrystal.h>
/*
Pinos de conex?o dos bot?es e sensor reed switch
8 — Sensor Reed Switch
9 — Decremento
12 — Incremento
11 — Enter
*/
#define MEMORIA 120
#define PosRaio 125
#define ReedSwitch 8
#define BotaoEnterOk 11
#define BotaoIncremento 12
#define BotaoDecremento 9
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
bool sensor = 0, estado_anterior = 0, Incremento = 0, Decremento = 0;
bool IncrementoAnterior = 0, DecrementoAnterior = 0, BotaoEnter = 0, EstadoAnteriorIncremento = 0;
byte cont = 0;
unsigned long int VoltaCompleta = 0;
unsigned long int tempo_atual = 0, ultimo_tempo = 0;
float DistKm = 0;
unsigned int raio = 0;
float Distancia = 0;
void setup()
{
Serial.begin(9600);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(12, INPUT);
lcd.begin(16,2);
//Regiao de codigo para configurar o raio da roda do veiculo
if(EEPROM.read(MEMORIA) != 73)
{
ConfiguraRaio();
EEPROM.write(MEMORIA, 73);
}
lcd.setCursor(3,0);
lcd.print(“Distancia”);
lcd.setCursor(6,1);
lcd.print(Distancia);
lcd.setCursor(14,1);
lcd.print(“km”);
raio = EEPROM.read(PosRaio);
}
void loop()
{
//Regiao de codigo para realizar a leitura dos botoes e sensor do dispositivo
sensor = digitalRead(ReedSwitch);
Decremento = digitalRead(BotaoDecremento);
Incremento = digitalRead(BotaoIncremento);
//Regiao de codigo para acumular a distancia percorrida
if(sensor == 0 && estado_anterior == 1)
{
VoltaCompleta++;
Distancia = (float)(2*3.14*raio*VoltaCompleta)/100000.0;
lcd.setCursor(0,1);
lcd.print(“ “);
lcd.setCursor(6,1);
lcd.print(Distancia);
lcd.setCursor(14,1);
lcd.print(“km”);
estado_anterior = 0;
}
if(sensor == 1 && estado_anterior == 0)
{
estado_anterior = 1;
}
//Regiao de Codigo para Configurar o Raio
if(Incremento == 1 && EstadoAnteriorIncremento == 0)
{
EstadoAnteriorIncremento = 1;
}
if(Incremento == 0 && EstadoAnteriorIncremento == 1)
{
EstadoAnteriorIncremento = 0;
lcd.clear();
ConfiguraRaio();
}
}
void ConfiguraRaio()
{
byte RaioRoda = 0;
//Imprimir mensagem para digitar o raio em cm
lcd.setCursor(0,0);
lcd.print(“Inserir Raio(cm)”);
do
{
lcd.setCursor(6,1);
Incremento = digitalRead(BotaoIncremento);
Decremento = digitalRead(BotaoDecremento);
BotaoEnter = digitalRead(BotaoEnterOk);
if(Incremento == 1 && IncrementoAnterior == 0)
{
RaioRoda = RaioRoda + 1;
IncrementoAnterior = 1;
}
if(Incremento == 0 && IncrementoAnterior == 1)
{
IncrementoAnterior = 0;
}
if(Decremento == 1 && DecrementoAnterior == 0)
{
RaioRoda = RaioRoda — 1;
DecrementoAnterior = 1;
}
if(Decremento == 0 && DecrementoAnterior == 1)
{
DecrementoAnterior = 0;
}
lcd.setCursor(6,1);
lcd.print(RaioRoda);
}while(BotaoEnter == 0);
lcd.clear();
EEPROM.write(PosRaio, RaioRoda);
return;
}
Conclusion
Therefore, case you want your own PCB, you can obtain 10 free units through the discount coupon of the PCBWay. For this, you can access the website, create your account and obtain your own PCB's.
Arduino Bicycle Odometer
*PCBWay community is a shared platform and we are not responsible for any design issues.
- Comments(0)
- Likes(2)
- Marhaunichy Maryan Iosifovich Jun 29,2020
- Eduardo A. Passos Dec 01,2019
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
10design
-
8usability
-
8creativity
-
10content
More by silicioslab
- WS2812B RGB LED Controller with ESP8266 via WiFi IntroductionWS2812b addressable RGB LEDs are devices widely used in lighting projects. They are foun...
- Electronic Board for Cutting Electrical Power to Devices and Machines IntroductionAn energy saving system for cutting electrical energy in machines is a fundamental piece...
- PCB Board Home Automation with ESP8266 IntroductionThe incorporation of the ESP8266 module into home automation represents a significant ad...
- Dedicated Control Board for Mobile Robots with Wheels IntroductionFor a long time we developed several prototypes and teaching kits of mobile robots and w...
- Traffic turn signal for bicycles IntroductionDoes every project with electronic logic need a Microcontroller or Arduino to be develop...
- Mini Arduino with ATTINY85 Do you know the ATTINY85 microcontroller? This article has news and a gift for you. Many people deve...
- Christmas Tree The tree used to signal light of Christmas.
- Activating loads with relay via WiFi with ESP8266 IntroductionDo you want an electronic board for activating loads via WiFi that is safe against surge...
- Hospital Water Tank Monitoring via the Internet IntroductionOne of the elements of great importance for the functioning of hospitals is water. It is...
- ESP32 IoT Development Board with Monitoring Battery System IntroductionToday I want to tell you what one of the biggest problems is in electronic projects invo...
- Control Board for 6 Servomotors based on Arduino for Robotic projects In the last few weeks we started developing this robotic arm. It is made up of 5 servomotors. To fac...
- PCBWay Standalone Arduino IntroductionDo you know how the basic circuit of an Arduino works? Every Arduino has a minimum circu...
- Human Machine Interface based in Arduino with ATMEGA328P Standalone Several commercial and industrial applications require a screen system to present data and receive p...
- Small Low Cost Circuit Deveelopment Board for Prototypes In recent years I have developed numerous prototypes with Arduino. During these creations, something...
- Intruder alert system with SMS In several places, we must monitor the security of spaces and prevent intruders from entering prohib...
- Mini Arduino Laboratory I have worked in teaching laboratories for over 10 years. One of the great difficulties in these spa...
- PCBWay WiFi ESPBoard-01 Can you imagine controlling any device over the internet? Lamps, water pumps for irrigation, gate dr...
- Educational Robot for Children All areas of knowledge such as sciences, human or biological, have their respective importance. With...
-
Open Source Very Large Stick - Freejoy & MMjoy2 breakout board
471 0 0 -
RF Control training board for students based on ESP32 C3
628 0 2 -
Aquarius+ Computer, Standard PCB
837 0 4 -
KINETIC COASTERS with a TWIST! Laser or 3D Print some DIY Magic
586 0 1 -
RPI - 8 IO PLC With ATTiny85 Watch Dog
506 0 1 -
Nintendo Famicom HVC-001 Controller Shells
608 0 1 -
COMMODORE 128 DIAGNOSTIC REV.785260 KEYBOARD DONGLE
561 0 4 -
COMMODORE 128 15KHz DISPLAY ADAPTER (C128 80 COLUMN ADAPTER)
759 1 5 -