More about project: https://arduino.php5.sk/google-maps-bicyklovanie.php?lang=en
Cycling is a very popular sport. Passionate cyclists ride our paths and paths. But since the weather is not always good, many bike fans would like to cycle from the comfort of home. That is why today I am bringing a way to achieve this with an expanded reality in the form of Google Maps. At the beginning we will go through the necessary hardware resources for the project and in the next step we will discuss their functionality.
Hardware Components:
Arduino (32u4 CPU) Leonardo
Magnetic contact
2x pushbutton
2x 10kohm resistors
To use the system, the user must turn on Google Maps, choose any location in the world, and switch to Street View mode. This guarantees a ready interface for interaction with the bike (Arduino). With regard to bicycle, any type can be used. Classic, road, mountain, exercise bike. Magnetic contact must be fitted to the pedal and the structure.
The main element of the system is the use of the Arduino Leonardo development board, which includes the ATmega32u4 microprocessor. In addition to controlling GPIO pins (like the classic Uno), this type of processor can also control the keyboard and mouse, it is a HID device (Human Interface device). As a result, we have completely different possibilities of use not only for our idea. The magnetic contact is used to record the full pedal rotation of the pedals. A simple counter is implemented programmatically, which is incremented each time the pedals are rotated through 360 °. Optical camera can also be used.
When the counter overflows, a condition is executed and an up arrow character is sent to the computer, which will move the user one step forward on the Google Map. The buttons are used to rotate the view to the sides, they are active until the user holds them. The program implementation uses pullup and pulldown push buttons. With pullup resistors are not required, internal pullup resistors Arduina are turned on. The functionality of both variants is identical.
Cycling can also be enriched by using the VR headset on Google Maps. In addition to Google Maps, Street View also has some other interesting webpages that can be tried out, and are especially interesting guessing pages (you can involve the whole family):
- GeoGuessr
- Earth Picker
Program implementation for pullup resistors:
#include <Keyboard.h>
const int tlacidloVpred = 2;
int tlacidloStav;
int poslednetlacidloStav = HIGH;
unsigned long poslednezakmitCas = 0;
unsigned long zakmitDelay = 50;
int pocitadlo = 0;
const int tlacidloVlavo = 3;
const int tlacidloVpravo = 4;
void setup() {
Keyboard.begin();
Serial.begin(115200);
pinMode(tlacidloVpred, INPUT_PULLUP);
pinMode(tlacidloVlavo, INPUT_PULLUP);
pinMode(tlacidloVpravo, INPUT_PULLUP);
}
void loop() {
int citanie = digitalRead(tlacidloVpred);
while(!digitalRead(tlacidloVlavo)){
Keyboard.press('a');
delay(300);
Keyboard.releaseAll();
}
while(!digitalRead(tlacidloVpravo)){
Keyboard.press('d');
delay(300);
Keyboard.releaseAll();
}
if (citanie != poslednetlacidloStav) {
poslednezakmitCas = millis();
}
if ((millis() - poslednezakmitCas) > zakmitDelay) {
if (citanie != tlacidloStav) {
tlacidloStav = citanie;
if (tlacidloStav == LOW) {
pocitadlo++;
}
}
}
poslednetlacidloStav = citanie;
Serial.println("Hodnota counteru:");
Serial.println(pocitadlo);
if(pocitadlo>=5){
Keyboard.write(218);
pocitadlo = 0;
Serial.println("Pohyb vpred");
}
}
Program implementation for pulldown connection:
#include <Keyboard.h>
const int tlacidloVpred = 2;
int tlacidloStav;
int poslednetlacidloStav = LOW;
unsigned long poslednezakmitCas = 0;
unsigned long zakmitDelay = 50;
int pocitadlo = 0;
const int tlacidloVlavo = 3;
const int tlacidloVpravo = 4;
void setup() {
Keyboard.begin();
Serial.begin(115200);
pinMode(tlacidloVpred, INPUT);
pinMode(tlacidloVlavo, INPUT);
pinMode(tlacidloVpravo, INPUT);
}
void loop() {
int citanie = digitalRead(tlacidloVpred);
while(digitalRead(tlacidloVlavo)){
Keyboard.press('a');
delay(300);
Keyboard.releaseAll();
}
while(digitalRead(tlacidloVpravo)){
Keyboard.press('d');
delay(300);
Keyboard.releaseAll();
}
if (citanie != poslednetlacidloStav) {
poslednezakmitCas = millis();
}
if ((millis() - poslednezakmitCas) > zakmitDelay) {
if (citanie != tlacidloStav) {
tlacidloStav = citanie;
if (tlacidloStav == HIGH) {
pocitadlo++;
}
}
}
poslednetlacidloStav = citanie;
Serial.println("Hodnota counteru:");
Serial.println(pocitadlo);
if(pocitadlo>=5){
Keyboard.write(218);
pocitadlo = 0;
Serial.println("Pohyb vpred");
}
}
Schematics for pullup code: