#include <SPI.h>
#include <Adafruit_GFX.h>
#include <MD_MAX72xx.h>
//#include <StopWatch_RT.h>
#include <SimpleTimer.h>
int matrix_x;
int matrix_y;
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
const int Vert =A1; //analog
const int Hori =A0; //analog
const int Sele =A2; // digital
void setup()
{
pinMode(Sele, INPUT);
digitalWrite(Sele, HIGH);
Serial.begin(115200);
mx.begin();
}
int vertical, horizontal, select;
void loop()
{
vertical = analogRead(Vert);
horizontal = analogRead(Hori);
select = digitalRead(Sele);
/*
Serial.print("vertical: ");
Serial.print(vertical,DEC);
Serial.print(" horizontal: ");
Serial.print(horizontal,DEC);
Serial.print(" select: ");
if(select == HIGH)
Serial.println("not pressed");
else
Serial.println("PRESSED!");
*/
matrix_y = map(vertical, 5, 1018, 0, 31); // Maps values in the range
// 0 to 1023 to the range
// 7 to 0
matrix_x = map(horizontal, 1018, 5, 0, 7); // Maps values in the range
// 0 to 1023 to the range
// 0 to 7
mx.clear();
//display new x and y values
Serial.print("x: ");
Serial.println(matrix_x);
Serial.print("y: ");
Serial.println(matrix_y);
mx.setPoint(matrix_x,matrix_y,true);
mx.update();
delay(10);
}