Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Joystick-Controlled LED Matrix Display

View and Edit Project In Cirkit DesignerImage of Arduino Joystick-Controlled LED Matrix Display

Circuit Documentation

Summary

This circuit consists of an Analog Joystick, a MAX7219 8x8 LED Matrix, and an Arduino UNO. The joystick is used to control the position of an LED on the matrix display. The Arduino UNO reads the joystick's position and button press, then updates the LED matrix accordingly.

Component List

Analog Joystick

MAX7219 8x8 LED Matrix

Arduino UNO

Wiring Details

Analog Joystick

MAX7219 8x8 LED Matrix

Arduino UNO

Code Documentation

Arduino UNO Code

#include <LedControl.h>

#define CLK_PIN  13
#define DATA_PIN 11
#define CS_PIN   10

#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN  2

LedControl lc = LedControl(DATA_PIN, CLK_PIN, CS_PIN, 1);

int x = 0;
int y = 0;

void setup() {
  lc.shutdown(0, false);       // Wake up displays
  lc.setIntensity(0, 8);       // Set brightness level (0 is min, 15 is max)
  lc.clearDisplay(0);          // Clear display register

  pinMode(VERT_PIN, INPUT);
  pinMode(HORZ_PIN, INPUT);
  pinMode(SEL_PIN, INPUT_PULLUP);
}

void loop() {
  int horz = analogRead(HORZ_PIN);
  int vert = analogRead(VERT_PIN);
  if (vert < 300) {
    y = min(y + 1, 7);
  }
  if (vert > 700) {
    y = max(y - 1, 0);
  }
  if (horz > 700) {
    x = min(x + 1, 7);
  }
  if (horz < 300) {
    x = max(x - 1, 0);
  }
  if (digitalRead(SEL_PIN) == LOW) {
    lc.clearDisplay(0);
  }
  lc.setLed(0, y, x, true);
  delay(100);
}

This code initializes the LED matrix and joystick, reads the joystick's position, and updates the LED matrix to reflect the joystick's position. The select button on the joystick clears the display when pressed.