Matrix DOT LED Display 8x32 and joystick

Hello everyone, this code is good but I have doubts about a couple of items that need to be added, namely I use the components Matrix Dot Led display 8x32, joystick and Arduino Nano board. Does anyone have any idea how to do the following: The letter that is set on the display should flash and the letters that are being read should be saved and that every next letter that is chosen should flash. Letters that have already been selected can be dialed again, otherwise they are selected by moving the joystick up and down. Thanks in advance!!

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10

int MAX_SIZE = 100;
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
uint8_t scrollSpeed = 50;
textEffect_t scrollEffect = PA_SCROLL_RIGHT;
textPosition_t scrollAlign = PA_RIGHT;

uint16_t scrollPause = 1000;

int VRx = A0;
int VRy = A1;
int SW = 2;

int xPosition = 0;
int yPosition = 0;
boolean on = true;
boolean on_first = true;
int buttonState = 0;
int mapX = 0;
int mapY = 0;
int n = 0;
int m = 0;
int b = 0;

#define BUF_SIZE 102
char curMessage[BUF_SIZE] = {" HELLO"};
char alphabet[28] = {'<','A','B','C','D','E','F','G','H','I','G','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

void change_char(){

if(mapY > 480){
--n;
}
else{
if(mapY < -480)
++n;
}
if(n>27)
n = 0;
if(n<0)
n = 27;

delay(50);

//
if(mapX > 480){
--m;
}
else{
if(mapX < -480)
++m;
}
delay(50); //

if(m > MAX_SIZE-2)
m = 0;
if(m < 0)
m = MAX_SIZE-2;

if(m != b)
n = 0;

curMessage[m] = alphabet[n];

b = m;//

Serial.println(m);

char toBeDisplayed[MAX_SIZE] = {" "};
for(int i = 0; i < 100; ++i){
int index = 0;
if((m + i) > MAX_SIZE){
// ispocetka
index = MAX_SIZE - (m - i);

}
else{
    index = m + i;
  }
toBeDisplayed[i] = curMessage[index]; 

P.print(toBeDisplayed);
P.setTextBuffer(curMessage);
Serial.println(toBeDisplayed);
Serial.println(curMessage);

void setup()
{

P.begin();
//P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
Serial.begin(9600);
pinMode(VRx, INPUT);
pinMode(VRy, INPUT);
pinMode(SW, INPUT_PULLUP);

pinMode(2, OUTPUT);

}

void loop()
{
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
delay(50);
buttonState = digitalRead(SW);
delay(10);
xPosition = analogRead(VRx);
yPosition = analogRead(VRy);
delay(100);
mapX = map(xPosition, 0, 1023, -512, 512);
mapY = map(yPosition, 0, 1023, -512, 512);

if(buttonState == LOW)
on = !on;

if(on == false){ 
  if(on_first == true){ 
  
    P.setSpeed(50); 
    P.setTextAlignment(PA_LEFT); 
    P.setPause(1000); 
    P.setTextEffect(PA_SCROLL_LEFT, PA_SCROLL_LEFT); 
    on_first = false; 
  }
}

if(on){
Serial.println("Prvo");
change_char();
on_first = true;
}
else{
Serial.println("Drugo");
if (P.displayAnimate())
{
P.displayReset();
}

}
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.