Cycling on Google Maps - Arduino 32u4

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:

Great stuff, I never knew about this platform and I quite like cycling.
Would it be OK for me to promote this on my website?

Yes, sure. It is based on project: Bike Across the Country While in Your Basement - Hackster.io

Interesting.

Is the included picture an image of a beached cyclist using a distraction device while on the road.?

Personally I would just a use a map device with GPS.
that way there is no need for interaction or additional equipment.
But I may have missed a key point

I think part of the joy of cycling is in the loosing all the distractions of life.

Hiddenvision:
Personally I would just a use a map device with GPS.
that way there is no need for interaction or additional equipment.
But I may have missed a key point

I think part of the joy of cycling is in the loosing all the distractions of life.

I Think the key idea is if you're working out at home in a stationary bike to have a monitor in front of you simulating the experience of going through different places. A bit like Virtual Reality.

casemod:
I Think the key idea is if you're working out at home in a stationary bike to have a monitor in front of you simulating the experience of going through different places. A bit like Virtual Reality.

Ahh, right, totally get it now.
Guess I should have clicked on the link in the first post.

Oddly My mate Pat asked me to look at doing similar back in early 2000's.
Internet Mapping has vastly improved since then.
there would be a big demand from Gyms if you had a slick system.

If you hosted a web page with googlemaps you could then use a wifi connection to push your cycle info to the server and have that manipulate your position.

That way it is easy to have some preset routes that you can follow along to.

A simple ESP8266 with the magnetic sensor could then be a pretty "wireless" and "portable" solution.

Best of luck,

Update...
Maybe good project for quarantine, get it on title page... Good project about how spent time during COVID-19? :slight_smile:
Attach photos with your hardware implementations of your projects.
Have you used your own bicycle or some type of indoor-bike?