#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
// DEFINIRANJE NA BOITE
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int matrixW = 8; //dolzina na matrica
int matrixH = 8; //sirina na matrica
#define PIN 6 // //pino na koj sme povrzani
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(matrixW, matrixH, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
uint16_t textColor = matrix.Color(255, 0, 0); // boja na matricata
const uint16_t drawingColors[] = { GREEN, BLUE, CYAN, WHITE, RED};
// 3 boi za pravoagolnicite
#define arr_len( x ) ( sizeof( x ) / sizeof( *x ) )
int pixelPerChar = 6; // Width of Standard Font Characters is 8X6 Pixels
int x = matrix.width(); // dolzina na display
int pass = 0; // Counter
int i = 0; // Counter
int sensor=A0;
float V;
float Vread;
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(255); //postavuvanje na osvetlenost
matrix.setTextColor(textColor); // boja na textot
pinMode(sensor, INPUT);
}
void loop() {
Vread=analogRead(sensor);
V=(5.0/1023.0)*Vread;
String vrednost = "vrednosta e :" + String (V,1); //konvertiranje vo CHAR vrednost
writeText(vrednost); //pretstavuvanje na vrednosta
}
/* -------------------- funkcija za pisuvanje text -------------------- */
void writeText(String msg) {
int msgSize = (msg.length() * pixelPerChar) + (2 * pixelPerChar); // Calculate message length
int scrollingMax = (msgSize) + matrix.width(); // Adjust displacement for message length
x = matrix.width(); // Reset cursor position and start text string at new position on the far right
while (true) {
matrix.setTextColor(textColor); // Set the text color
matrix.fillScreen(0); // Blank the entire screen
matrix.setCursor(x, 0); // Set starting point for text string
matrix.print(msg); // Set the message string
// Scroll text from right to left by moving the cursor position
if (--x < -scrollingMax) {
// Adjust for message length
// Decrement x by one and compare new value of x to -scrollingMax;
// This animates (moves) the text by one pixel to the left
x = matrix.width(); // After scrolling by scrollingMax pixels, reset cursor position and start string at new position on the far right
break; // Exit the loop after one complete scroll
}
matrix.show(); // Display the text/image
delay(200); // Speed of scrolling or frame rate
}
}