Arduino PS2 Game Joystick Module

Harga Rp. 72.500 (cek dahulu untuk ketersediaan stock)
harga diluar ongkos kirim

Isi Paket
1 modul PS2 Game Joystick Arduino Compatible



Product Description
  • Arduino standard 3 pins
  • 2.54 standard pins

The joystick is a double direction 10K potentiometer, the resistor value is changing when joystick direction changes. This module use 5V power supply, reading value around 2.5V at the raw condition, value will increase when the arrow go down till maxium 5V; the value will decrease when the arrow go other direction till 0V.

Documentation
See the schematic .

 
Demo Code

/*********************************************************************
**  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.                          **
**  http://elecfreaks.taobao.com                                    **
*********************************************************************/
 
 
 
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);
}

Popular posts from this blog

EM4100 125Khz RFID Card Read Module

Flow Sensor - model SBS-HZ 21 WA

Paket Display LCD 16x2 Character dan 1602 IIC Converter Board