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.
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 FootswitchThis footswitch is just a normal switch. But a bigger & stronger version.
Circuit Schematic & SimulationThe 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 1400The 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 SwitchThis 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 libraryThe 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 projectBut 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.
Comments