XY-axis Joystick Module (KY-023) [S056]



https://www.youtube.com/watch?v=hFNXbU8lUQo


*GitHub https://github.com/rdiot/rdiot-s056.git



* Specs

The company produces PS2 game joystick axis sensor module consists of using original quality metal PS2 joystick potentiometer system For the (X, Y) a 2-axis analog output and for (Z) 1 digital output channel button.


* Contents

- Connect

GND ----- GND

5V ----- 5V

X-axis ----- A0

Y-axis ----- A1

SW(Swtich) ----- D2


- Key Code


#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

int X = A0; // x

int Y = A1; // y

int S = 2; // SW

 

void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

 

  pinMode(X, INPUT);

  pinMode(Y, INPUT);

  pinMode(S, INPUT);

  digitalWrite(S, HIGH); 

 

  delay(1000);

 

  lcd.clear();

}

 

void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S056:XY-axis Joystick");

 

  int x, y, s; 

  x = analogRead(X);

  y = analogRead(Y);

  s = digitalRead(S);

 

  lcd.setCursor(0,1);

  lcd.print("X=" + (String)x + "   ");

 

  lcd.setCursor(0,2);

  lcd.print("Y=" + (String)y + "   ");

 

  lcd.setCursor(0,3);

  lcd.print("SW=" + (String)s + "  ");

 

  delay(100);

}

'2) Sensor > Joystick' 카테고리의 다른 글

Classic Arcade Joystick Red Ball 4/8 Way [S207]  (0) 2016.09.12
Posted by RDIoT
|

4x5 Matrix Array 20 Keypad [S187]




https://www.youtube.com/watch?v=JNL_hOtghXk


*GitHub https://github.com/rdiot/rdiot-s187.git


* Specs

Panel Size: 75*85mm. 

Length: 18CM. 

Insulation Resistance:100M 100V. 

Withstand Voltage:250V Rms.(50-60Hz lmin) 

Storage Temperature: +15°- +35°. 

Storage Humidity:70-90.


* Contents

byte rowPins[numRows] = {10,9,8,7,6}; 

byte colPins[numCols]= {2,3,4,5};

- Connect

D2 ~ D9

- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

#include <Keypad.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

const byte numRows= 5; //number of rows on the keypad

const byte numCols= 4; //number of columns on the keypad

 

//keymap defines the key pressed according to the row and columns just as appears on the keypad

char keymap[numRows][numCols]= 

{

  {'A','B','#','*'},

  {'1','2','3','U'},

  {'4','5','6','D'},

  {'7','8','9','C'},

  {'L','0','R','E'}

};

 

byte rowPins[numRows] = {10,9,8,7,6}; 

byte colPins[numCols]= {2,3,4,5}; 

 

//initializes an instance of the Keypad class

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

 

String numstr = "";

 

void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

 

  delay(1000);

 

  lcd.clear();

}

 

void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S187:4x5 20 Keypad");

 

 

  char keypressed = myKeypad.getKey();

  if (keypressed != NO_KEY)

  {

   // Serial.print(keypressed);

    lcd.setCursor(0,1);

    lcd.print("keypressed=" + (String)keypressed + "  ");

 

    switch (keypressed)

    {

      case '1':        

           numstr = "1    ";

        break;

      case '2':           

           numstr = "2    ";

        break;  

      case '3':           

           numstr = "3    ";

        break; 

      case '4':           

           numstr = "4    ";

        break; 

      case '5':           

           numstr = "5    ";

        break;                 

      case '6':           

           numstr = "6    ";

        break; 

      case '7':           

           numstr = "7    ";

        break; 

      case '8':           

           numstr = "9    ";

        break; 

      case '0':           

           numstr = "0    ";

        break; 

      case 'A':           

          numstr = "F1   ";

        break; 

      case 'B':           

          numstr = "F2   ";

        break; 

      case 'C':           

          numstr = "ESC  ";

        break; 

      case 'E':           

          numstr = "ENTER";

        break; 

      case 'D':           

          numstr = "DOWN ";

        break; 

      case 'U':           

          numstr = "UP   ";

        break; 

      case 'R':           

          numstr = "RIGHT ";

        break; 

      case 'L':           

          numstr = "LEFT ";

        break; 

      case '*':           

          numstr = "*    ";

        break; 

      case '#':           

          numstr = "#    ";

        break;                                                 

        

      default:          

        break;

    }

 

 

    if(numstr !="")

    {

      lcd.setCursor(0,2);

      lcd.print("numstr=" + (String)numstr + " ");

    }

 

  }

 

}

Posted by RDIoT
|

TTP229 16 Key Capacitive Touch Keypad (TTP229) [S153]




https://www.youtube.com/watch?v=NXZR0p-kX1A


*GitHubhttps://github.com/rdiot/rdiot-s153.git


* Specs

Operating voltage:2.4V~5.5V

Built-in regulator

Stand-by current At 3V, and sleep mode slow sampling rate 8Hz:

=> Typical 2.5uA for 16 input keys

=> Typical 2.0uA for 8 input keys

8 Key or 16 key modes

Separate outputs to 8 keys in 8 key mode

2 wires serial output interface for both 16 key and 8 key mode

Outputs can be set to CMOS/OD/OC with active high/low

2 Wires serial interface can select active high or low by option

Optional Multi-key or single-key

Provides two kinds of sampling rate: slow sampling rate 8Hz and fast sampling rate 64Hz at sleep mode

Optional maximum key-on time about 80sec

Auto calibration at power up (keypad must not be touched for 0.5 seconds after power up)

Auto calibration for changes in environment

 

1.....VCC (2.4 - 5.5V)

2.....GND

3.....SCL (serial clock in)

4.....SDO (serial data out)

5.....OUT 1 (key 1 state)

6.....OUT 2 (key 2 state)

7.....OUT 3 (key 3 state)

8.....OUT 4 (key 4 state)

9.....OUT 5 (key 5 state)

10...OUT 6 (key 6 state)

11...OUT 7 (key 7 state)

12...OUT 8 (key 8 state)


* Contents

- Connect

VCC ----- 5V

GND ----- GND

SCL -----> D2 

SDO -----> D3 


- Key Code

#define pulse 2

#define data 3


int old  = 0;


void setup()

{

  Serial.begin(9600);

  pinMode(pulse, OUTPUT);  

  pinMode(data, INPUT); 

}


void loop()

{

  int Key = getkey();

  

  if (Key!=0&Key!=old)

  {

    Serial.print("PUSH--->");

    Serial.println(Key);


  }

    

  old = Key;

}



byte getkey(void)

{

  byte cnt;

  byte num = 0;

  for(cnt = 1; cnt < 17; cnt++)

  {

    digitalWrite(pulse, LOW); 

    

    if (digitalRead(data) == 0)

      num = cnt; 

    

    digitalWrite(pulse, HIGH);

  }  

  

  return num; 

}

Posted by RDIoT
|