Computers, Development Boards & Shields
Educational & Robotics Kits
Electronic Sensors
Motors & Controllers
Communication & Display
Electronic Components
Soldering & Lab Tools

Virtuabotix 1P DPAD Pin-out & Getting Started Guide

The Virtuabotix 1P DPAD was designed to take advantage of the ability to split a voltage into multiple different levels and have those levels output from specific buttons. This allows several buttons to be added to a project using only one analog input. This particular version uses 3 resistor arrays to output Ground, 1/4th Vdd, 2/4ths Vdd, and 3/4ths Vdd from each button without taking very much space or very many components. Much higher granularity is possible with higher resolution Analog to Digital (ADC) ports, and with more resistors.

This board was design to be plug and play on the Versalino Control board, and can very easily be wired to and used on any platform with Analog ports.

1P-DPAD-LAYOUT_IMG

Layout:

As described above the Virtuabotix 1P DPAD uses 3 quad resistor arrays to allow the use of any value of resistor to produce the same results (the current draw being the only variance).

The Left button has the 3/4th’s Vdd ratio, the up has the 2/4th’s Vdd ratio, and the right button is 1/4th Vdd while the down arrow is connected to ground.

This board was designed to be very simple and as small as possible while remaining usable for most applications.

Is was designed to be plug and play with either side of the Versalino Control board, and to be easily implemented in any device that has access to at least one Analog port.

Pin-Out:

Connect the Ground pin to the Ground of your system, the middle pin (Vdd) to the 5V of your system, and the Vout to any analog pin and use the output to control your next project using only one input pin!

Below is how to connect to the Arduino Uno/Duemilanove/Mega etc. for the code included in this guide. This device can be similarly connected to just about any device with an analog port.

Virtuabotix 1P DPAD connected to Arduino Uno zoomed in

 

Below is how you can connect the Virtuabotix 1P DPAD to the Versalino BUS.

Virtuabotix 1P DPAD connected to Versalino Uno zoomed in

Below are a couple of other photos, including how the Versalino Control connects to the Virtuabotix 1P DPAD just in case you are having any trouble getting things connected properly.

Virtuabotix 1P DPAD connected to Versalino Uno zoomed out Virtuabotix 1P DPAD connected to Versalino Uno through Versalino Control Virtuabotix 1P DPAD connected to Arduino Uno zoomed out

Code:

Though it is possible to use the example after this one for this particular button array without modification I wanted to provide everyone with a simple example and explanation of how you code detect and code your own push button program (which I hope will help you if you are trying to get this working on a different platform, or if you are playing with making your own similar style array).

/****************************************************

Button/Analog Value viewer

by Joseph Dattilo (https://www.virtuabotix.com/)

Licensed GPL - http://www.gnu.org/licenses/gpl.html

****************************************************/

int myAnalogPin = A0;

//assign this to the analog port you have your buttons/input connected to.

void setup()

{

Serial.begin(9600);//start serial port for data

pinMode(myAnalogPin, INPUT);//we are reading in this example

digitalWrite(myAnalogPin, HIGH);//Turning on pullup resistor

//if your input is floating it will hang at 1023 instead of changing randomly.

}

void loop()

{

delay(1000);//1 second between readings.

Serial.print("The input reads: ");

Serial.println(analogRead(myAnalogPin));

//this displays the value of the input.

}//loop forever and ever, and ever, and then do it again.

If you plug the Gnd (ground) pin into ground, and the middle pin (Vdd or 5V/3.3V Etc) into 5V on your Arduino, then when you plug the Aout pin (pin furthest from Gnd pin on the 1P DPAD board) to A0 (Analog pin 0 of the Arduino Uno/Mega/Duemilanove etc..) or BUSA.AN0 then the code above should produce results similar to these:

The input reads: 1012

The input reads: 1012

The input reads: 916

The input reads: 619

The input reads: 615

The input reads: 1011

The input reads: 1013

The input reads: 403

The input reads: 396

The input reads: 1004

The input reads: 14

The input reads: 14

The input reads: 1013

The input reads: 1006

The input reads: 807

The input reads: 808

The input reads: 1000

The input reads: 1009

The input reads: 614

The input reads: 974

As you can see when nothing is pressed the output is 1012 or so, but sometimes can be as low as 974, to be safe we will consider anything above 850 as not pressed.

The next value we can see is around 800, but it swings as high as 808 in this case so to be safe we can consider anything less than 850 to be the left button (which corresponds to those readings).  

Now for the up button whose readings hover around 600 to 619, because of the small number of buttons, and the fact that these is a fair amount of resistor to resistor variation we can probably safely call anything less than 700 an up push.

Next we look at the right button values which are around 400. Just like in our last couple examples we want to go ahead and give ourselves some room on the judgement, so we will call anything less than 500 a right button push. Finally we only have one more option and that is our down button which reads about 14. In this case anything less than 200 is probably safe to call a down press.

There we go now that we have decided our ranges for each button we can easily modify the code above to display buttons pressed instead of raw values. In this case we use a cascading if statement that starts with the highest condition (no buttons pressed) and ends with the lowest value (the down button pressed). You could use more complex conditions in different arrangements as well.

/****************************************************
Button pressed viewer
by Joseph Dattilo (https://www.virtuabotix.com/)

Licensed GPL - http://www.gnu.org/licenses/gpl.html
****************************************************/

int my1PDPADPin = A0;
//assign this to the analog port you have your buttons/input connected to.
int myAnalogRead =0;
//this is where we will store our reads so we don't have to read too many times.

void setup()
{
Serial.begin(9600);//start serial port for data
pinMode(my1PDPADPin, INPUT);//we are reading in this example
digitalWrite(my1PDPADPin, HIGH);//Turning on pullup resistor
//if your input is floating it will hang at 1023 instead of changing randomly.
}

void loop()
{
delay(1000);//1 second between readings.
myAnalogRead = analogRead(my1PDPADPin);

if(myAnalogRead > 850)//limit for a non-press
{
Serial.println("No button is pressed.");
}
else if(myAnalogRead > 700)//limit for a left press
{
Serial.println("The Left Button is Pressed.");
}
else if(myAnalogRead > 500)//limit for an up press
{
Serial.println("The Up Button is Pressed.");
}
else if(myAnalogRead > 200)//limit for a right press
{
Serial.println("The Right Button is Pressed.");
}
else//otherwise a down press
{
Serial.println("The Down Button is Pressed.");
}

//this displays the value of the input.
}//loop forever and ever, and ever, and then do it again.

I hope this helps you get started using the Virtuabotix 1P DPAD, and look forward to seeing all of your versions do awesome things! Don’t hesitate to share them, especially if you come up with some code for a different system.

Project ideas:

You can use it for gaming, or for controlling peripherals on a Rover (like the Versalino Rove), you can use it to control a camera pan and tilt, or even a telescope on your roof. The possibilities are numerous and we can’t wait to see what you come up with. Please don’t hesitate to let me know if you have any questions, or want to share something you did with the Virtuabotix 1P DPAD. 

No comments yet.

Leave a Reply