Will_the_Star
Published © GPL3+

Tutorial for Arduino Beginners PART IV

Get to grips with the Joystick Module with the help of our trusty MaxMatrix.

BeginnerFull instructions provided1,002
Tutorial for Arduino Beginners PART IV

Things used in this project

Hardware components

MaxMatrix2719 8x8
×1
Analog joystick (Generic)
×1
Arduino UNO
Arduino UNO
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Computer

Story

Read more

Schematics

Joystick and Matrix

All done!

Code

MaxMatrix with Joystick Module

C/C++
Paste, IDE, Upload
int UD;
int LR ;
int button=4;

#include "LedControl.h" 
LedControl lc=LedControl(10,12,11,0);

void setup() {
  Serial.begin(9600);
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  pinMode(button, INPUT); 
  digitalWrite(button, HIGH); 

}

void loop() {
  UD = analogRead(A1); 
  LR = analogRead(A0);  
  int state=digitalRead(button); 
  )
  char x_translate = map(LR, 0,1023, 0, 7); 
  char y_translate = map(UD, 0,1023, 7, 0);

  Serial.print ("Button=");
  Serial.print(state, DEC);
  Serial.print(", UD = ");
  Serial.print(UD, DEC);
  Serial.print(", LR = ");
  Serial.print(LR, DEC);
  Serial.print(", x = ");
  Serial.print(x_translate, DEC); 
  Serial.print(", y = ");
  Serial.println(y_translate, DEC); 
  
     
    lc.clearDisplay(0);
    lc.setLed(0,x_translate,y_translate,true);  
    if (state==1){
    lc.setLed(0,x_translate,y_translate,true); 
    }
    else {
    lc.setLed(0,x_translate,y_translate,false); 
    }
   
  delay(150); 
}

Credits

Will_the_Star

Will_the_Star

6 projects • 26 followers
I am eleven years old. I have a proven IQ of 154. I am not lying, joking, kidding or trying to mislead you in any other way.

Comments