TINKER PiEDESIGN IN INDIA

Joystick Brick

Kit Bricks · SKU TP-K28

Two-axis thumb joystick with a push button.

₹299

Pre-order

Works with TinkerPie V1 · Arduino C++ with the TinkerPieBricks library · Delivery across India: ₹100, 3–7 days · 7-day replacement for damaged or defective kits

About this kit

Two-axis thumb joystick with a push button. The Joystick Brick is a carrier for the KY-023 module from common 37-in-1 sensor kits: plug the module into the socket and connect one cable to a TinkerPie SENSOR port. A small CH32V003 processor on the brick does the timing work, so your program simply reads the result over I2C.

Features

Specifications

Kit moduleKY-023 Joystick (module 28 of the 37-in-1 sensor kit)
SocketKIT JOYSTICK: 2.54 mm female, GND +5V VRx VRy SW
Size48 x 32 mm, M3 holes on the 8 mm grid
Connectors2 x JST-PH 4-pin TP-BUS (IN / OUT)
InterfaceI2C 0x2C-0x2D (2 on one bus)
Power3.3 V (joystick pots are ratiometric)
BrainWCH CH32V003
Arduino classtpb::KitJoystick

How to use it with TinkerPie

  1. Plug the KY-023 module into the 2.54 mm socket on the top edge. Match the pin names: the brick says G + X Y SW, the module has the same letters.
  2. Connect BUS IN to any TinkerPie SENSOR 1-4 port with a 4-pin JST-PH cable (the same cable as the other sensors).
  3. More bricks? Plug the next one into BUS OUT. Two bricks of the same type need different addresses: bridge ADDR +1, +2 or +4 on the back (0x2C-0x2D; the first is 0x2C).
  4. Install the TinkerPie and TinkerPieBricks Arduino libraries, open the quick-start sketch below, choose the board ESP32S3 Dev Module and upload.

Libraries: TinkerPie and TinkerPieBricks (Arduino IDE: Sketch → Include Library → Add .ZIP Library). Full guide: getting started with TinkerPie Bricks.

Quick start

Upload this, open the Serial Monitor at 115200 baud and watch the TinkerPie matrix.

Quick-start sketch (Arduino C++)
// Joystick Brick (TP-K28): quick start
// Reads the brick and shows the value on the TinkerPie matrix and in the Serial Monitor (115200 baud).
#include <TinkerPie.h>
#include <TinkerPieBricks.h>
using namespace tinkerpie;

tpb::KitJoystick j;

void setup() {
  Serial.begin(115200);
  tinkerpie::begin();            // also starts the SENSOR ports (I2C bus Wire1)
  if (!j.begin()) Serial.println("Joystick Brick not found at 0x2C: check the cable to SENSOR 1-4");
}

void loop() {
  int x = j.x(), y = j.y();           // -512 .. +511, 0 = centre
  basic::clearScreen();
  led::plot(map(x, -512, 511, 0, 5), map(y, -512, 511, 0, 4), j.pressed() ? Colors::Red : Colors::Green);
  basic::pause(50);
}

Project: Joystick robot driver

Push the joystick to drive a two-wheel robot: forward, backward and turning. Press the stick for a horn.

Joystick robot driver (Arduino C++)
// Joystick robot driver: Joystick Brick (TP-K28)
// Push the joystick to drive a two-wheel robot: forward, backward and turning. Press the stick for a horn.
#include <TinkerPie.h>
#include <TinkerPieBricks.h>
using namespace tinkerpie;

tpb::KitJoystick j;

void setup() {
  Serial.begin(115200);
  tinkerpie::begin();            // also starts the SENSOR ports (I2C bus Wire1)
  if (!j.begin()) Serial.println("Joystick Brick not found at 0x2C: check the cable to SENSOR 1-4");
  j.calibrate();                    // the current position is the centre
}

void loop() {
  int fwd = -j.y() * 100 / 512, turn = j.x() * 100 / 512;   // stick up = forward (flip the sign if yours is the other way)
  motors::tank(constrain(fwd + turn, -100, 100), constrain(fwd - turn, -100, 100));
  if (j.pressed()) music::playTone(440, 100);
  basic::pause(30);
}

More TinkerPie Bricks

DS18B20 Temperature Brick (TP-K01)DS18B20 Temperature BrickTP-K01 · Environment · KY-001Waterproof-grade digital thermometer chip, read in C over I2C.₹299Pre-orderShock Switch Brick (TP-K02)Shock Switch BrickTP-K02 · Motion · KY-002Detects knocks and vibration with a spring switch.₹299Pre-orderHall Magnetic Sensor Brick (TP-K03)Hall Magnetic Sensor BrickTP-K03 · Magnetic · KY-003Senses a magnet near the A3144 hall switch.₹299Pre-orderButton Switch Brick (TP-K04)Button Switch BrickTP-K04 · Input · KY-004A tactile push button on the bus.₹299Pre-order

See all 53 TinkerPie Bricks