Joystick breakout module

From Wiki

Jump to: navigation, search

Contents

Introduction

This is a breakout module for Playstation2 analog joystick. Lots of robot projects need joystick. This module provides a affordable solution to that. Simply connect to two analog inputs, the robot is at your commands with X,Y control. It also has a switch that is connected to a digital pin.

Model: BKOUT_MD01

Joystick md1.jpg

Feature

Usage

Hardware Installation

Joystick md03.jpg

Programming

Includes important code snippet. Demo code like :

/*********************************************************************
**  Device: Joystick                                                **
**  File:   EF_Joystick_Test.c                                      **
**								    **
**  Created by ElecFreaks Robi.W /10 June 2011                      **
**                                                                  **
**  Description:                                                    **
**  This file is a sample code for your reference.                  **
**                                                                  **
**  Copyright (C) 2011 ElecFreaks Corp.                     	    **
*********************************************************************/
 
 
 
int FirstShotX , FirstShotY;
 
void setup()
{
  for(int i=0; i<19; i++)
  { 
    pinMode(i, INPUT);
    digitalWrite(i, 1);
  }
 
  Serial.begin(9600); 
  FirstShotX = 0;
  FirstShotY = 0;
 
}
 
void loop(){
 
  int i, someInt, flag = 0;
  for(i=4; i<11; i++)
  {
    someInt = digitalRead(i);
    if(someInt == 0)
    {  
      flag =1;
      break;
    }
   }
   if(flag == 1)
   {    
     switch(i)
     {
       case 4: Serial.println("--------> Button A"); break;
       case 5: Serial.println("--------> Button B"); break;
       case 6: Serial.println("--------> Button C"); break;
       case 7: Serial.println("--------> Button D"); break;
       case 8: Serial.println("--------> Button E"); break;
       case 9: Serial.println("--------> Button F"); break;
       case 10: Serial.println("--------> Button KEY"); break;
       default: break;
     }
     flag=0;
   }
 
   int sensorValue = analogRead(A0);
   if(FirstShotX == 0)
   {  
     FirstShotX = sensorValue;
     Serial.print("FirstShotX = ");
     Serial.println(FirstShotX);
   }
 
   Serial.print("X = ");
   Serial.println(sensorValue - FirstShotX);
 
   sensorValue = analogRead(A1);
   if(FirstShotY == 0)
   {  
     FirstShotY = sensorValue;
     Serial.print("FirstShotY = ");
     Serial.println(FirstShotY);
   }
   Serial.print("Y = ");
   Serial.println(sensorValue - FirstShotY);
 
   delay(200);
}

Example

The projects and application examples.

Bill of Materials (BOM) /parts list

All the components used to produce the product.

FAQ

Please list your question here:

Support

If you have questions or other better design ideas,

Version Tracker

Revision Descriptions Release
v1.0b Initial public release date

Bug Tracker

Bug Tracker is the place you can publish any bugs you think you might have found during use. Please write down what you have to say, your answers will help us improve our

products.

Additional Idea

The Additional Idea is the place to write your project ideas about this product, or other usages you've found. Or you can write them on Projects page.

Resources

How to buy

Click here to buy: http://www.elecfreaks.com/estore/joystick-breakout-module-bkout-md01.html

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are

licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries

Personal tools
Namespaces
Variants
Actions
Navigation
Support
Toolbox