SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By PedroCruz
#195890
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!
By PedroCruz
#195911
Never mind guys, this was sorted out even before the post was approved by moderator :)