Hands-Free ; Semicolon Foot Button? Helps Code Faster? Play Dino With Foot? Arduino MKR GSM1400 Board | BIG Switch to Add ; in Code With Leg

by Python EveryDay in Circuits > Arduino

865 Views, 4 Favorites, 0 Comments

Hands-Free ; Semicolon Foot Button? Helps Code Faster? Play Dino With Foot? Arduino MKR GSM1400 Board | BIG Switch to Add ; in Code With Leg

Hands-Free ; Semicolon Foot Button? Helps Code Faster? Play Dino With Foot? Arduino MKR GSM1400

This project is about a giant footswitch. With which we can add semicolons anywhere we want and can also play dino with it. That too With Foot.

Supplies

IMG_20220216_192115_HDR.jpg
IMG_20220216_204412_HDR.jpg
  • Arduino MKR GSM 1400
  • Foot Operated Switch

Why Did You Decide to Make It?

I am a python programmer. In python, we don't require adding semicolons at the end of each line. But the robotics projects require Arduino-based c/c++ programming. And in that, the semicolon is mandatory at the end of each line. And I hate Doing it.

So, I used this footswitch, as a big button for semicolon so as to be operated from the leg. I know this microcontroller supports circuit python.

How Does It Work?

This footswitch is interfaced with the computer via Arduino MKR GSM 1400 board. This board has a SAMD21 Cortex®-M0+ 32bit low-power ARM Microcontroller. And it sends the command to the computer to print semicolons, whenever the switch is pressed.

The Footswitch

IMG_20220216_204403_HDR.jpg

This footswitch is just a normal switch. But a bigger & stronger version.

Circuit Schematic & Simulation

circuit 1.JPG

The circuit diagram looks like this. Here the switch is connected to a 1 Kilo ohm resistor in a voltage divider configuration. Their junction gives the output.

Interfacing With Arduino MKR GSM 1400

IMG_20220216_193918_HDR.jpg

The footswitch has a cable with a 3.5-millimeter audio jack at its terminal. So, we will connect two wires to it. One to the outer part. Which will go to the ground. And another to the center of the jack. It will be connected to the junction.

Code to Add Semicolon After Footswitch Pressed

 #include <Keyboard.h>

First of all, we require the keyboard library. It has all the functions to mimic a real keyboard.


In the setup.

Keyboard.begin();

The keyboard-begin begins the keyboard.


In the loop.

if (v == LOW){          // if digital pin 3 is low
    Keyboard.print(";");  //then print ; semicolon
   delay(25);            
 }

We are reading the data at the pin. If the switch is pressed, then the pin will be low. If the pin is low. Then we will print a semicolon.

Playing Chrome Dino With Foot Switch

chrome dino.jpg

This is code for the up arrow key so that we can play chrome dino.

if (v == LOW){          // if digital pin 3 is low
   Keyboard.press(KEY_UP_ARROW); //then press up arrow key
   Keyboard.releaseAll();        // release the pressed key
   delay(25);            
 }

The code & logic for the up arrow key is almost the same. The difference here is. If the switch is pressed. Then board mimics the up arrow key is pressed. But it keeps the key pressed. So, we have to write this function to release all the keys pressed.

The Downside of the Keyboard Library

circuit python.png

The keyboard library has a downside. It supports the newer boards. The Arduino Uno is the most popular board. Does not support the keyboard library. Whereas the newer boards also support circuit python. So, the problem of adding semicolons still remains as it is. If you are using old boards.

Advantage of Project

dog operated footswitch.jpg

But this project has many advantages. It can be used by disabled, to control the computer with the foot. The pets can operate buttons with their paw, to request food or water. Or receive a video call from the owner. we can play games with covid positive friends without fear of infection.

Robotics EveryDay!!!

Video Demonstration

Hands-Free ; Semicolon Foot Button? Helps Code Faster? Play Dino With Foot? Arduino MKR GSM1400

Code for Semicolon & Dino Footswitch

//code for ; semicolon from foot
#include <Keyboard.h>

void setup() {
  pinMode(3,INPUT);       //switch connected to digital pin 3
  Keyboard.begin(); 
}

void loop() {
  
  int v = digitalRead(3); // read the state at digital pin 3
  
  if (v == LOW){          // if digital pin 3 is low
    
    Keyboard.print(";");  //then print ; semicolon
    
    delay(25);            
  
  }
}

//Code for chrome dino, up arrow key
#include <Keyboard.h>

void setup() {
  pinMode(3,INPUT);       //switch connected to digital pin 3
  Keyboard.begin(); 
}

void loop() {
  
  int v = digitalRead(3); // read the state at digital pin 3
  
  if (v == LOW){          // if digital pin 3 is low
    
    Keyboard.press(KEY_UP_ARROW); //then press up arrow key
    Keyboard.releaseAll();        // release the pressed key
    
    delay(25);            
  
  }
}


Circuit Schematic for Semicolon Footswitch Playing Dino

Please Ignore the Schematic. It is just for illustration. The connections of the push-button are not correct.