#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#include <Keypad.h>
const byte rowsCount = 4;
const byte columsCount = 4;
//Vcc - Vcc
//Gnd - Gnd
//Din - Mosi (Pin 11)
//Cs - SS (Pin 10)
//Clk - Sck (Pin 13)
const int pinCS = 10;
const int numberOfHorizontalDisplays = 9;
const int numberOfVerticalDisplays = 1;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String tape = "www.luisllamas.es"; //text
const int wait = 100; // In milliseconds
const int spacer = 1;
const int width = 5 + spacer; // The font width is 5 pixels
char keys[rowsCount][columsCount] = {
{ '1','2','3', 'A' },
{ '4','5','6', 'B' },
{ '7','8','9', 'C' },
{ '*','0','#', 'D' }
};
const byte rowPins[rowsCount] = {3, 2, 9, 8 };
const byte columnPins[columsCount] = { 7, 6, 5, 4 };
Keypad keypad = Keypad(makeKeymap(keys), rowPins, columnPins, rowsCount, columsCount);
void setup() {
Serial.begin(9600);
matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
// Adjust to your own needs
matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
matrix.setPosition(4, 4, 0); // And the last display is at <3, 0>
matrix.setPosition(5, 5, 0); // And the last display is at <3, 0>
matrix.setPosition(6, 6, 0); // And the last display is at <3, 0>
matrix.setPosition(7, 7, 0); // And the last display is at <3, 0>
matrix.setPosition(8, 8, 0); // And the last display is at <3, 0>
matrix.setPosition(9, 9, 0); // And the last display is at <3, 0>
matrix.setRotation(0, 1); // Display is position upside down
matrix.setRotation(1, 1); // Display is position upside down
matrix.setRotation(2, 1); // Display is position upside down
matrix.setRotation(3, 1); // Display is position upside down
matrix.setRotation(4, 1); // Display is position upside down
matrix.setRotation(5, 1); // Display is position upside down
matrix.setRotation(6, 1); // Display is position upside down
matrix.setRotation(7, 1); // Display is position upside down
matrix.setRotation(8, 1); // Display is position upside down
matrix.setRotation(9, 1); // Display is position upside down
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
matrix.fillScreen(LOW);
matrix.drawChar(1, 1, key, HIGH, LOW, 1);
matrix.write(); // Send bitmap to display
delay(wait);
}
Comments