2016/06/08

arduino_official_logo__

const int buttonM = 6;

pinMode(buttonM, INPUT);

if (digitalRead(buttonM) == LOW)
{
Keyboard.press(‘m’);
}

else
{
Keyboard.release(‘m’);
}

#include<Keyboard.h>

const int led1 = 5;
const int led2 = 4;
const int buttonX = 3;
const int buttonZ = 2;

void setup() //This executes the next commands only once
{
pinMode(led1, OUTPUT); //Set up the pins 4 and 5 as output.
pinMode(led2, OUTPUT); //
pinMode(buttonX, INPUT); //Set up the pins 2 and 3 as input.
pinMode(buttonZ, INPUT); //

Keyboard.begin(); //This allows control over the keyboard.
}

void loop() //This repeats the next commands as long as the Arduino is powered on.
{
if (digitalRead(buttonX) == LOW) //if the input reads that it is activated,
{
Keyboard.press(‘x’); //press the ‘x’ key.
}

else //Otherwise,
{
Keyboard.release(‘x’); //release the ‘x’ key.
}

if (digitalRead(buttonZ) == LOW) //if the input reads that it is activated,
{
Keyboard.press(‘z’); //press the ‘z’ key.
}

else //Otherwise,
{
Keyboard.release(‘z’); //release the ‘z’ key.
}
}

This is the code for the controller.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s