2 Button Box

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!

Moderator: phalanx

Post Reply
PedroCruz
Posts: 2
Joined: Sat Aug 19, 2017 6:02 am

2 Button Box

Post by PedroCruz » Sat Aug 19, 2017 6:08 am

Hi everyone!
im building a usb box with 2x buttons and Sparkfun Micro Pro. One button sends SPACE bar to computer, and other button sends ESC.
i coppied the code from Sparkfun Website but the code as one key code written only...
can anyone help write the code to include the 2 buttons? maybe we could write it to use pin 10 for key ESC.
the code im using is:

#include <Keyboard.h>
int buttonPin = 9; // Set a button to any pin

void setup()
{
pinMode(buttonPin, INPUT); // Set the button as an input
digitalWrite(buttonPin, HIGH); // Pull the button high
}

void loop()
{
if (digitalRead(buttonPin) == 0) // if the button goes low
{
Keyboard.write(' '); // send a ' ' to the computer via Keyboard HID
delay(1000); // delay so there aren't a kajillion z's
}
}

As you already noticed i have no clue how this language work :(
Any help is highly appreciated!
Thanks!

PedroCruz
Posts: 2
Joined: Sat Aug 19, 2017 6:02 am

Re: 2 Button Box

Post by PedroCruz » Mon Aug 21, 2017 8:08 am

Never mind guys, this was sorted out even before the post was approved by moderator :)

Post Reply