|
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 sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- 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 Silícios Lab silicioslab
- Electronic Enclosure applied for electronic projects IntroductionWhen designing electronics, the enclosure plays a crucial role that is often overlooked....
- IoT Indoor system with ESP32 to monitor Temperature, Humidity, Pressure, and Air Quality IntroductionAir quality, temperature, humidity and pressure are essential elements to ensure healthy...
- 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.
- Electronic Enclosure applied for electronic devices IntroductionWhen designing electronics, the enclosure plays a crucial role that is often overlooked....
- Electronic Enclosure for Programmable Logic Controller The housing developed for programmable logic controllers is a practical and efficient solution for t...
- Payment PCB for machines and services IntroductionIn many commercial establishments, hospitals and other places, there are video game equi...
- Relay High Power Printed Circuit Board IntroductionEfficient management of electrical loads is essential for optimizing performance and saf...
- Weather gadget with clock through ESP8266 IntroductionImagine a device that combines technology with an elegant design, bringing functionality...
- ESP32 MPU6050 Monitor IntroductionVarious industrial equipment is essential for the adequate production of products, parts...
- Digital Speedometer for Bicycles IntroductionCycling, increasingly popular both as a recreational activity and as a means of transpor...
- Arduino-based development board with extra features IntroductionArduino is an excellent tool for anyone who wants to develop prototypes. The board has a...
- How to develop low-energy devices powered by batteries? IntroductionIn recent years, there has been a major advance in the area of embedded systems through ...
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
67 1 1 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
66 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
90 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
467 0 7 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
138 0 2 -