The Alpha Geek – Geeking Out

Project #26 – Radio Frequency – SparkFun Joystick Shield – Mk09

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFunJoystickShield #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield Kit

The SparkFun Joystick Shield Kit contains all the parts you need to enable your Arduino with a joystick. The shield sits on top of your Arduino and turns it into a simple controller. Five momentary push buttons and a two-axis thumb joystick gives your Arduino functionality on the level of old Nintendo controllers. Soldering is required, but it’s relatively easy and requires minimal tools. We even have a step by step guide.

The momentary push buttons are connected to Arduino digital pins 2-6; when pressed they will pull the pin low. Vertical movement of the joystick will produce a proportional analog voltage on analog pin 0, likewise, horizontal movement of the joystick can be tracked on analog pin 1.

DL2302Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

DLE_UP – Digital 16
DLE_DOWN – Digital 19
DLE_LEFT – Digital 18
DLE_RIGHT – Digital 17
DLE_FIRE – Digital 21
DLE_SPACE – Digital 5
VIN – +3.3V
GND – GND

——

DL2302Mk04p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - SparkFun Joystick Shield - Mk09
26-09
DL2301Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// ESP32 BLE Keyboard - NIMBLE
#define USE_NIMBLE
#include <BleKeyboard.h>

// ESP32 BLE Keyboard
BleKeyboard bleKeyboard;

// Game Controller Buttons
#define DLE_UP 16
#define DLE_DOWN 19
#define DLE_LEFT 18
#define DLE_RIGHT 17
#define DLE_FIRE 21
#define DLE_SPACE 5

// Button
bool keyStates[6] = {false, false, false, false, false, false};
int keyPins[6] = {DLE_UP, DLE_DOWN, DLE_LEFT, DLE_RIGHT, DLE_FIRE, DLE_SPACE};
uint8_t keyCodes[6] = {'w', 'x', 'a', 'd', 'y', ' '};

// Connect Notification Sent
bool connectNotificationSent = false;

// Software Version Information
String sver = "26-09";

void loop() {
  
  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // Counter
  int counter;
  
  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Connect Notification Sent
    if (!connectNotificationSent) {
      
      connectNotificationSent = true;
      
    }

    // Button
    for(counter = 0; counter < 6; counter ++){
      
      handleButton(counter);
      
    }

  }

}

getGames.ino

// Games
// Set Inputs
void setInputs() {
  
  // Make the button line an input
  pinMode(DLE_UP, INPUT_PULLUP);
  pinMode(DLE_DOWN, INPUT_PULLUP);
  pinMode(DLE_LEFT, INPUT_PULLUP);
  pinMode(DLE_RIGHT, INPUT_PULLUP);
  pinMode(DLE_FIRE, INPUT_PULLUP);
  pinMode(DLE_SPACE, INPUT_PULLUP);

}

// Handle Button
void handleButton(int keyIndex){
  
  // Handle the button press
  if (!digitalRead(keyPins[keyIndex])){
    
    // Button pressed
    if (!keyStates[keyIndex]){
      
      // Key not currently pressed
      keyStates[keyIndex] = true;
      bleKeyboard.press(keyCodes[keyIndex]);
      
    }
    
  }
  else {
    
    // Button not pressed
    if (keyStates[keyIndex]){
      
      // Key currently pressed
      keyStates[keyIndex] = false;
      bleKeyboard.release(keyCodes[keyIndex]);
      
    }
  }
  
}

setup.ino

// Setup
void setup()
{

  // Set Inputs
  setInputs();

  // ESP32 BLE Keyboard
  bleKeyboard.begin();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives