Ah Arduino you absolute little beauty what would I do without you, not have got a 2.1 in my first degree that’s for sure. I love Arduino, I think it’s such a fantastic system to work with especially for prototyping projects. In my time working in clinical engineering for one reason or another I ended up looking at a rubber ducky.
Not this kind!
The kind of rubber ducky which is used for hacking. My little foray into cyber security lead me inevitably to Arduino, as I had decided I wanted to try and make a rubber ducky. During my exploration of rubber ducks I found that Arduino has some rather interesting functionality, in that it can take inputs to the Arduino board and output them to pc as keyboard and mouse actions, there is a caveat with this in that this only works on certain boards I used the Arduino pro micro. You can probably see where I’m going with this, with this functionality we can potentially turn any series of switches dials and thingamabobs into a variety of weird and wonderful computer commands (insert mad engineer laughter here).
While I’m no Tony Stark (I don’t have that kind of finances) I like to think I’m a fairly good engineer. and here is the result. As an aside one of the other things, I really love about Arduino is it has a bunch of example sketches (code) that you can use to help you learn how the functionality works. There’s also a neat little website that’s great for helping design circuits with Arduino Circuit Design App for Makers- circuito.io. Luckily for me over the last couple of weeks a friend has been dipping their toe into the shark infested waters of Arduino and I’ve managed to make a project out of some of their musings. The challenge was this:
The patient needed an HID (human interface device) this is the equipment that enables you to do stuff on the PC so mouse, keyboard, games controllers etc. The HID needed to use one button to scroll down the screen. Pretty simple problem right, well yes if you’ve used Arduino before and know how to wrangle the little (insert choice of expletive here) beast.
What I came up with:
Arduino micro with pull up button this means that when the button is pressed it will pull the sensor pin high giving it a logical 1, when the button is released it goes to ground giving a logical 0 to the pin. The pinouts were vcc -> button, button -> resistor and pin2, resistor to ground. a 1kohm resistor is fine for this application a 10 k would be fine as well anything over a 1k really is ok.
Having designed the hardware its time to bash out some software so here’s the code:
//libraries
#include <Keyboard.h>
//variables
int buttonState1 = 0;
const int buttonPin = 2;
void setup() {
delay(20000);
// open the serial port:
Serial.begin(9600);
Serial.println("started");
//initialize input button
pinMode(buttonPin, INPUT);
// initialize control over the keyboard:
Keyboard.begin();
Serial.println("keyboard on");
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin);
if (buttonState1 == HIGH) {
Serial.println("button 1 pressed");
Keyboard.press(KEY_DOWN_ARROW);
delay(100);
Keyboard.releaseAll();
buttonState1 = LOW;
}
}
There are probably better ways of doing this and someone with a wealth of Arduino knowledge will be able to produce something much better than I have but this has turned into a great little project.
I also tried the same thing with the mouse library attached below. Which kind of shows the great thing about Arduino its very much a flexible system that can be adapted to most problems.
My closing thoughts on this project:
1) I’d love to build a more complex system maybe using one button to scroll up and down using some kind of timer mechanism or something
2) Arduino might seem a bit daunting to start with but there are so many resources out there don’t discard it straight off the bat the plethora of YouTube videos, tutorials and forums should help guide you through.
Happy tinkering
Heimerdinger or “Tinker” from league of legends” https://runeterraccg.com/heimerdinger-vi-control-deck-guide-card-choices-matchups-and-mulligans-explained-in-depth/
0 thoughts on “Arduino Uno – Small Board, Big Solution”