// Include Libraries
#include "Arduino.h"
#include "MaxMatrix.h"
// Pin Definitions
#define LEDMATRIX_PIN_DIN 12
#define LEDMATRIX_PIN_CLK 11
#define LEDMATRIX_PIN_CS 10
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
byte ledMatrixinUse = 1; //Specify how many Max7219 led matrices are chained
int ledMatrixtextScrollingSpeed = 50; //Specify the scrolling speed
char ledMatrixStr[] = "Hello World! "; //Specify the string to be displayed
// object initialization
MaxMatrix ledMatrix(LEDMATRIX_PIN_DIN,LEDMATRIX_PIN_CS,LEDMATRIX_PIN_CLK);
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");
ledMatrix.init(ledMatrixinUse); //Initialize Led Matrices
ledMatrix.setIntensity(5); //LED Intensity 0-15
}
byte heart[][8]={
0,0,0,0,0,0,0,0,
0,0,1,0,0,1,0,0,
0,1,0,1,1,0,1,0,
0,1,0,0,0,0,1,0,
0,1,0,0,0,0,1,0,
0,0,1,0,0,1,0,0,
0,0,0,1,1,0,0,0,
0,0,0,0,0,0,0,0
};
byte heartbig[][8]={
0,1,1,0,0,1,1,0,
1,0,0,1,1,0,0,1,
1,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,1,
0,1,0,0,0,0,1,0,
0,0,1,0,0,1,0,0,
0,0,0,1,1,0,0,0
};
void setSymbol(byte arr[8][8])
{
for(byte i = 0; i < 8; i++)
{
for(byte j = 0; j < 8; j++)
{
ledMatrix.setDot(i, j, arr[i][j]);
}
}
}
int x = 0;
int y = 0;
int maxX = 7;
int maxY = 7;
void loop()
{
/*
ledMatrix.setDot(3,3, true);
delay(500);
ledMatrix.clear();
delay(500);*/
setSymbol(heart);
delay(1000);
setSymbol(heartbig);
delay(1000);
/*int horz = analogRead(HORZ_PIN);
int vert = analogRead(VERT_PIN);
if (vert < 300) {
y = min(y + 1, maxY);
}
if (vert > 700) {
y = max(y - 1, 0);
}
if (horz > 700) {
x = min(x + 1, maxX);
}
if (horz < 300) {
x = max(x - 1, 0);
}
if (digitalRead(SEL_PIN) == LOW) {
ledMatrix.clear();
}
ledMatrix.setDot(x, y, true);
delay(100);*/
}