added hardware specifications
This commit is contained in:
parent
f0009a67cc
commit
be7b2568a0
BIN
hardware/meeting-clock.fzz
Normal file
BIN
hardware/meeting-clock.fzz
Normal file
Binary file not shown.
91
hardware/tests/BT_Serial/BT_Serial.ino
Normal file
91
hardware/tests/BT_Serial/BT_Serial.ino
Normal file
@ -0,0 +1,91 @@
|
||||
// SerialIn_SerialOut_004
|
||||
//
|
||||
// Uses hardware serial to talk to the host computer and Software
|
||||
// Serial for communication with the bluetooth module
|
||||
//
|
||||
// What ever is entered in the serial monitor is sent to the connected
|
||||
// device
|
||||
// Anything received from the connected device is copied to the serial
|
||||
// monitor
|
||||
//
|
||||
// Pins
|
||||
// BT VCC to Arduino 5V out.
|
||||
// BT GND to GND
|
||||
// Arduino D8 (SS RX) - BT TX no need voltage divider
|
||||
// Arduino D9 (SS TX) - BT RX through a voltage divider (5v to 3.3v)
|
||||
//
|
||||
// Setup procedure
|
||||
/*
|
||||
* AT
|
||||
* AT+ORGL
|
||||
* // restart
|
||||
* AT
|
||||
* AT+NAME=Meeting Clock
|
||||
* AT+NAME?
|
||||
* AT+PSWD="1812"
|
||||
* AT+PSWD?
|
||||
* AT+UART=9600,1,0
|
||||
* AT+UART?
|
||||
*/
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
SoftwareSerial BTserial(5, 4); // RX, TX
|
||||
#define STATE_PIN 3
|
||||
|
||||
char c = ' ';
|
||||
boolean NL = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
Serial.print("Sketch: "); Serial.println(__FILE__);
|
||||
Serial.print("Uploaded: "); Serial.println(__DATE__);
|
||||
Serial.println(" ");
|
||||
|
||||
BTserial.begin(38400); // for at mode
|
||||
//BTserial.begin(9600); // for echo mode
|
||||
Serial.println("BTserial started at 9600");
|
||||
Serial.println(" ");
|
||||
|
||||
pinMode(STATE_PIN, INPUT);
|
||||
}
|
||||
|
||||
bool state = false;
|
||||
void loop()
|
||||
{
|
||||
if (digitalRead(STATE_PIN) != state) {
|
||||
state = digitalRead(STATE_PIN);
|
||||
Serial.print("! new BT state: ");
|
||||
if (state) {
|
||||
Serial.println("Connected");
|
||||
} else {
|
||||
Serial.println("Disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
// Read from the Bluetooth module and send to the Arduino Serial
|
||||
// Monitor
|
||||
if (BTserial.available())
|
||||
{
|
||||
c = BTserial.read(); Serial.write(c);
|
||||
}
|
||||
|
||||
|
||||
// Read from the Serial Monitor and send to the Bluetooth module
|
||||
if (Serial.available())
|
||||
{
|
||||
c = Serial.read();
|
||||
BTserial.write(c);
|
||||
|
||||
// Echo the user input to the main window. The ">" character
|
||||
// indicates the user entered text.
|
||||
if (NL) {
|
||||
Serial.print(">");
|
||||
NL = false;
|
||||
}
|
||||
Serial.write(c);
|
||||
if (c == 10) {
|
||||
NL = true;
|
||||
}
|
||||
}
|
||||
}
|
625
hardware/tests/MD_MAX72xx_Test/MD_MAX72xx_Test.ino
Normal file
625
hardware/tests/MD_MAX72xx_Test/MD_MAX72xx_Test.ino
Normal file
@ -0,0 +1,625 @@
|
||||
// Program to exercise the MD_MAX72XX library
|
||||
//
|
||||
// Uses most of the functions in the library
|
||||
#include <MD_MAX72xx.h>
|
||||
//#include <SPI.h>
|
||||
|
||||
// Turn on debug statements to the serial output
|
||||
#define DEBUG 1
|
||||
|
||||
#if DEBUG
|
||||
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
|
||||
#define PRINTS(x) Serial.print(F(x))
|
||||
#define PRINTD(x) Serial.println(x, DEC)
|
||||
|
||||
#else
|
||||
#define PRINT(s, x)
|
||||
#define PRINTS(x)
|
||||
#define PRINTD(x)
|
||||
|
||||
#endif
|
||||
|
||||
// Define the number of devices we have in the chain and the hardware interface
|
||||
// NOTE: These pin numbers will probably not work with your hardware and may
|
||||
// need to be adapted
|
||||
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
|
||||
#define MAX_DEVICES 4
|
||||
|
||||
#define CS_PIN 6 // or SS
|
||||
|
||||
// SPI hardware interface
|
||||
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
|
||||
// Arbitrary pins
|
||||
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
|
||||
|
||||
// We always wait a bit between updates of the display
|
||||
#define DELAYTIME 300 // in milliseconds
|
||||
|
||||
void scrollText(const char *p)
|
||||
{
|
||||
uint8_t charWidth;
|
||||
uint8_t cBuf[8]; // this should be ok for all built-in fonts
|
||||
|
||||
PRINTS("\nScrolling text");
|
||||
mx.clear();
|
||||
|
||||
while (*p != '\0')
|
||||
{
|
||||
charWidth = mx.getChar(*p++, sizeof(cBuf) / sizeof(cBuf[0]), cBuf);
|
||||
|
||||
for (uint8_t i=0; i<=charWidth; i++) // allow space between characters
|
||||
{
|
||||
mx.transform(MD_MAX72XX::TSL);
|
||||
if (i < charWidth)
|
||||
mx.setColumn(0, cBuf[i]);
|
||||
delay(DELAYTIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void zeroPointSet()
|
||||
// Demonstrates the use of setPoint and
|
||||
// show where the zero point is in the display
|
||||
{
|
||||
PRINTS("\nZero point highlight");
|
||||
mx.clear();
|
||||
|
||||
if (MAX_DEVICES > 1)
|
||||
mx.setChar((2*COL_SIZE)-1, '0');
|
||||
|
||||
for (uint8_t i=0; i<ROW_SIZE; i++)
|
||||
{
|
||||
mx.setPoint(i, i, true);
|
||||
mx.setPoint(0, i, true);
|
||||
mx.setPoint(i, 0, true);
|
||||
delay(DELAYTIME);
|
||||
}
|
||||
|
||||
delay(DELAYTIME*3);
|
||||
}
|
||||
|
||||
void rows()
|
||||
// Demonstrates the use of setRow()
|
||||
{
|
||||
PRINTS("\nRows 0->7");
|
||||
mx.clear();
|
||||
|
||||
for (uint8_t row=0; row<ROW_SIZE; row++)
|
||||
{
|
||||
mx.setRow(row, 0xff);
|
||||
delay(2*DELAYTIME);
|
||||
mx.setRow(row, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
void checkboard()
|
||||
// nested rectangles spanning the entire display
|
||||
{
|
||||
uint8_t chkCols[][2] = { { 0x55, 0xaa }, { 0x33, 0xcc }, { 0x0f, 0xf0 }, { 0xff, 0x00 } };
|
||||
|
||||
PRINTS("\nCheckboard");
|
||||
mx.clear();
|
||||
|
||||
for (uint8_t pattern = 0; pattern < sizeof(chkCols)/sizeof(chkCols[0]); pattern++)
|
||||
{
|
||||
uint8_t col = 0;
|
||||
uint8_t idx = 0;
|
||||
uint8_t rep = 1 << pattern;
|
||||
|
||||
while (col < mx.getColumnCount())
|
||||
{
|
||||
for (uint8_t r = 0; r < rep; r++)
|
||||
mx.setColumn(col++, chkCols[pattern][idx]); // use odd/even column masks
|
||||
idx++;
|
||||
if (idx > 1) idx = 0;
|
||||
}
|
||||
|
||||
delay(10 * DELAYTIME);
|
||||
}
|
||||
}
|
||||
|
||||
void columns()
|
||||
// Demonstrates the use of setColumn()
|
||||
{
|
||||
PRINTS("\nCols 0->max");
|
||||
mx.clear();
|
||||
|
||||
for (uint8_t col=0; col<mx.getColumnCount(); col++)
|
||||
{
|
||||
mx.setColumn(col, 0xff);
|
||||
delay(DELAYTIME/MAX_DEVICES);
|
||||
mx.setColumn(col, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
void cross()
|
||||
// Combination of setRow() and setColumn() with user controlled
|
||||
// display updates to ensure concurrent changes.
|
||||
{
|
||||
PRINTS("\nMoving cross");
|
||||
mx.clear();
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
|
||||
|
||||
// diagonally down the display R to L
|
||||
for (uint8_t i=0; i<ROW_SIZE; i++)
|
||||
{
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0xff);
|
||||
mx.setRow(j, i, 0xff);
|
||||
}
|
||||
mx.update();
|
||||
delay(DELAYTIME);
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0x00);
|
||||
mx.setRow(j, i, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
// moving up the display on the R
|
||||
for (int8_t i=ROW_SIZE-1; i>=0; i--)
|
||||
{
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0xff);
|
||||
mx.setRow(j, ROW_SIZE-1, 0xff);
|
||||
}
|
||||
mx.update();
|
||||
delay(DELAYTIME);
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0x00);
|
||||
mx.setRow(j, ROW_SIZE-1, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
// diagonally up the display L to R
|
||||
for (uint8_t i=0; i<ROW_SIZE; i++)
|
||||
{
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0xff);
|
||||
mx.setRow(j, ROW_SIZE-1-i, 0xff);
|
||||
}
|
||||
mx.update();
|
||||
delay(DELAYTIME);
|
||||
for (uint8_t j=0; j<MAX_DEVICES; j++)
|
||||
{
|
||||
mx.setColumn(j, i, 0x00);
|
||||
mx.setRow(j, ROW_SIZE-1-i, 0x00);
|
||||
}
|
||||
}
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
|
||||
}
|
||||
|
||||
void bullseye()
|
||||
// Demonstrate the use of buffer based repeated patterns
|
||||
// across all devices.
|
||||
{
|
||||
PRINTS("\nBullseye");
|
||||
mx.clear();
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
|
||||
|
||||
for (uint8_t n=0; n<3; n++)
|
||||
{
|
||||
byte b = 0xff;
|
||||
int i = 0;
|
||||
|
||||
while (b != 0x00)
|
||||
{
|
||||
for (uint8_t j=0; j<MAX_DEVICES+1; j++)
|
||||
{
|
||||
mx.setRow(j, i, b);
|
||||
mx.setColumn(j, i, b);
|
||||
mx.setRow(j, ROW_SIZE-1-i, b);
|
||||
mx.setColumn(j, COL_SIZE-1-i, b);
|
||||
}
|
||||
mx.update();
|
||||
delay(3*DELAYTIME);
|
||||
for (uint8_t j=0; j<MAX_DEVICES+1; j++)
|
||||
{
|
||||
mx.setRow(j, i, 0);
|
||||
mx.setColumn(j, i, 0);
|
||||
mx.setRow(j, ROW_SIZE-1-i, 0);
|
||||
mx.setColumn(j, COL_SIZE-1-i, 0);
|
||||
}
|
||||
|
||||
bitClear(b, i);
|
||||
bitClear(b, 7-i);
|
||||
i++;
|
||||
}
|
||||
|
||||
while (b != 0xff)
|
||||
{
|
||||
for (uint8_t j=0; j<MAX_DEVICES+1; j++)
|
||||
{
|
||||
mx.setRow(j, i, b);
|
||||
mx.setColumn(j, i, b);
|
||||
mx.setRow(j, ROW_SIZE-1-i, b);
|
||||
mx.setColumn(j, COL_SIZE-1-i, b);
|
||||
}
|
||||
mx.update();
|
||||
delay(3*DELAYTIME);
|
||||
for (uint8_t j=0; j<MAX_DEVICES+1; j++)
|
||||
{
|
||||
mx.setRow(j, i, 0);
|
||||
mx.setColumn(j, i, 0);
|
||||
mx.setRow(j, ROW_SIZE-1-i, 0);
|
||||
mx.setColumn(j, COL_SIZE-1-i, 0);
|
||||
}
|
||||
|
||||
i--;
|
||||
bitSet(b, i);
|
||||
bitSet(b, 7-i);
|
||||
}
|
||||
}
|
||||
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
|
||||
}
|
||||
|
||||
void stripe()
|
||||
// Demonstrates animation of a diagonal stripe moving across the display
|
||||
// with points plotted outside the display region ignored.
|
||||
{
|
||||
const uint16_t maxCol = MAX_DEVICES*ROW_SIZE;
|
||||
const uint8_t stripeWidth = 10;
|
||||
|
||||
PRINTS("\nEach individually by row then col");
|
||||
mx.clear();
|
||||
|
||||
for (uint16_t col=0; col<maxCol + ROW_SIZE + stripeWidth; col++)
|
||||
{
|
||||
for (uint8_t row=0; row < ROW_SIZE; row++)
|
||||
{
|
||||
mx.setPoint(row, col-row, true);
|
||||
mx.setPoint(row, col-row - stripeWidth, false);
|
||||
}
|
||||
delay(DELAYTIME);
|
||||
}
|
||||
}
|
||||
|
||||
void spiral()
|
||||
// setPoint() used to draw a spiral across the whole display
|
||||
{
|
||||
PRINTS("\nSpiral in");
|
||||
int rmin = 0, rmax = ROW_SIZE-1;
|
||||
int cmin = 0, cmax = (COL_SIZE*MAX_DEVICES)-1;
|
||||
|
||||
mx.clear();
|
||||
while ((rmax > rmin) && (cmax > cmin))
|
||||
{
|
||||
// do row
|
||||
for (int i=cmin; i<=cmax; i++)
|
||||
{
|
||||
mx.setPoint(rmin, i, true);
|
||||
delay(DELAYTIME/MAX_DEVICES);
|
||||
}
|
||||
rmin++;
|
||||
|
||||
// do column
|
||||
for (uint8_t i=rmin; i<=rmax; i++)
|
||||
{
|
||||
mx.setPoint(i, cmax, true);
|
||||
delay(DELAYTIME/MAX_DEVICES);
|
||||
}
|
||||
cmax--;
|
||||
|
||||
// do row
|
||||
for (int i=cmax; i>=cmin; i--)
|
||||
{
|
||||
mx.setPoint(rmax, i, true);
|
||||
delay(DELAYTIME/MAX_DEVICES);
|
||||
}
|
||||
rmax--;
|
||||
|
||||
// do column
|
||||
for (uint8_t i=rmax; i>=rmin; i--)
|
||||
{
|
||||
mx.setPoint(i, cmin, true);
|
||||
delay(DELAYTIME/MAX_DEVICES);
|
||||
}
|
||||
cmin++;
|
||||
}
|
||||
}
|
||||
|
||||
void bounce()
|
||||
// Animation of a bouncing ball
|
||||
{
|
||||
const int minC = 0;
|
||||
const int maxC = mx.getColumnCount()-1;
|
||||
const int minR = 0;
|
||||
const int maxR = ROW_SIZE-1;
|
||||
|
||||
int nCounter = 0;
|
||||
|
||||
int r = 0, c = 2;
|
||||
int8_t dR = 1, dC = 1; // delta row and column
|
||||
|
||||
PRINTS("\nBouncing ball");
|
||||
mx.clear();
|
||||
|
||||
while (nCounter++ < 200)
|
||||
{
|
||||
mx.setPoint(r, c, false);
|
||||
r += dR;
|
||||
c += dC;
|
||||
mx.setPoint(r, c, true);
|
||||
delay(DELAYTIME/2);
|
||||
|
||||
if ((r == minR) || (r == maxR))
|
||||
dR = -dR;
|
||||
if ((c == minC) || (c == maxC))
|
||||
dC = -dC;
|
||||
}
|
||||
}
|
||||
|
||||
void intensity()
|
||||
// Demonstrates the control of display intensity (brightness) across
|
||||
// the full range.
|
||||
{
|
||||
uint8_t row;
|
||||
|
||||
PRINTS("\nVary intensity ");
|
||||
|
||||
mx.clear();
|
||||
|
||||
// Grow and get brighter
|
||||
row = 0;
|
||||
for (int8_t i=0; i<=MAX_INTENSITY; i++)
|
||||
{
|
||||
mx.control(MD_MAX72XX::INTENSITY, i);
|
||||
if (i%2 == 0)
|
||||
mx.setRow(row++, 0xff);
|
||||
delay(DELAYTIME*3);
|
||||
}
|
||||
|
||||
mx.control(MD_MAX72XX::INTENSITY, 8);
|
||||
}
|
||||
|
||||
void blinking()
|
||||
// Uses the test function of the MAX72xx to blink the display on and off.
|
||||
{
|
||||
int nDelay = 1000;
|
||||
|
||||
PRINTS("\nBlinking");
|
||||
mx.clear();
|
||||
|
||||
while (nDelay > 0)
|
||||
{
|
||||
mx.control(MD_MAX72XX::TEST, MD_MAX72XX::ON);
|
||||
delay(nDelay);
|
||||
mx.control(MD_MAX72XX::TEST, MD_MAX72XX::OFF);
|
||||
delay(nDelay);
|
||||
|
||||
nDelay -= DELAYTIME;
|
||||
}
|
||||
}
|
||||
|
||||
void scanLimit(void)
|
||||
// Uses scan limit function to restrict the number of rows displayed.
|
||||
{
|
||||
PRINTS("\nScan Limit");
|
||||
mx.clear();
|
||||
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
|
||||
for (uint8_t row=0; row<ROW_SIZE; row++)
|
||||
mx.setRow(row, 0xff);
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
|
||||
|
||||
for (int8_t s=MAX_SCANLIMIT; s>=0; s--)
|
||||
{
|
||||
mx.control(MD_MAX72XX::SCANLIMIT, s);
|
||||
delay(DELAYTIME*5);
|
||||
}
|
||||
mx.control(MD_MAX72XX::SCANLIMIT, MAX_SCANLIMIT);
|
||||
}
|
||||
|
||||
void transformation1()
|
||||
// Demonstrates the use of transform() to move bitmaps on the display
|
||||
// In this case a user defined bitmap is created and animated.
|
||||
{
|
||||
uint8_t arrow[COL_SIZE] =
|
||||
{
|
||||
0b00001000,
|
||||
0b00011100,
|
||||
0b00111110,
|
||||
0b01111111,
|
||||
0b00011100,
|
||||
0b00011100,
|
||||
0b00111110,
|
||||
0b00000000
|
||||
};
|
||||
|
||||
MD_MAX72XX::transformType_t t[] =
|
||||
{
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TFLR,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TRC,
|
||||
MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD,
|
||||
MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD,
|
||||
MD_MAX72XX::TFUD,
|
||||
MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU,
|
||||
MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU,
|
||||
MD_MAX72XX::TINV,
|
||||
MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC,
|
||||
MD_MAX72XX::TINV
|
||||
};
|
||||
|
||||
PRINTS("\nTransformation1");
|
||||
mx.clear();
|
||||
|
||||
// use the arrow bitmap
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
|
||||
for (uint8_t j=0; j<mx.getDeviceCount(); j++)
|
||||
mx.setBuffer(((j+1)*COL_SIZE)-1, COL_SIZE, arrow);
|
||||
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
|
||||
delay(DELAYTIME);
|
||||
|
||||
// run through the transformations
|
||||
mx.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::ON);
|
||||
for (uint8_t i=0; i<(sizeof(t)/sizeof(t[0])); i++)
|
||||
{
|
||||
mx.transform(t[i]);
|
||||
delay(DELAYTIME*4);
|
||||
}
|
||||
mx.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::OFF);
|
||||
}
|
||||
|
||||
void transformation2()
|
||||
// Demonstrates the use of transform() to move bitmaps on the display
|
||||
// In this case font characters are loaded into the display for animation.
|
||||
{
|
||||
MD_MAX72XX::transformType_t t[] =
|
||||
{
|
||||
MD_MAX72XX::TINV,
|
||||
MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC,
|
||||
MD_MAX72XX::TINV,
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
|
||||
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
|
||||
MD_MAX72XX::TSD, MD_MAX72XX::TSU, MD_MAX72XX::TSD, MD_MAX72XX::TSU,
|
||||
MD_MAX72XX::TFLR, MD_MAX72XX::TFLR, MD_MAX72XX::TFUD, MD_MAX72XX::TFUD
|
||||
};
|
||||
|
||||
PRINTS("\nTransformation2");
|
||||
mx.clear();
|
||||
mx.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::OFF);
|
||||
|
||||
// draw something that will show changes
|
||||
for (uint8_t j=0; j<mx.getDeviceCount(); j++)
|
||||
{
|
||||
mx.setChar(((j+1)*COL_SIZE)-1, '0'+j);
|
||||
}
|
||||
delay(DELAYTIME*5);
|
||||
|
||||
// run thru transformations
|
||||
for (uint8_t i=0; i<(sizeof(t)/sizeof(t[0])); i++)
|
||||
{
|
||||
mx.transform(t[i]);
|
||||
delay(DELAYTIME*3);
|
||||
}
|
||||
}
|
||||
|
||||
void wrapText()
|
||||
// Display text and animate scrolling using auto wraparound of the buffer
|
||||
{
|
||||
PRINTS("\nwrapText");
|
||||
mx.clear();
|
||||
mx.wraparound(MD_MAX72XX::ON);
|
||||
|
||||
// draw something that will show changes
|
||||
for (uint16_t j=0; j<mx.getDeviceCount(); j++)
|
||||
{
|
||||
mx.setChar(((j+1)*COL_SIZE)-1, (j&1 ? 'M' : 'W'));
|
||||
}
|
||||
delay(DELAYTIME*5);
|
||||
|
||||
// run thru transformations
|
||||
for (uint16_t i=0; i<3*COL_SIZE*MAX_DEVICES; i++)
|
||||
{
|
||||
mx.transform(MD_MAX72XX::TSL);
|
||||
delay(DELAYTIME/2);
|
||||
}
|
||||
for (uint16_t i=0; i<3*COL_SIZE*MAX_DEVICES; i++)
|
||||
{
|
||||
mx.transform(MD_MAX72XX::TSR);
|
||||
delay(DELAYTIME/2);
|
||||
}
|
||||
for (uint8_t i=0; i<ROW_SIZE; i++)
|
||||
{
|
||||
mx.transform(MD_MAX72XX::TSU);
|
||||
delay(DELAYTIME*2);
|
||||
}
|
||||
for (uint8_t i=0; i<ROW_SIZE; i++)
|
||||
{
|
||||
mx.transform(MD_MAX72XX::TSD);
|
||||
delay(DELAYTIME*2);
|
||||
}
|
||||
|
||||
mx.wraparound(MD_MAX72XX::OFF);
|
||||
}
|
||||
|
||||
void showCharset(void)
|
||||
// Run through display of the the entire font characters set
|
||||
{
|
||||
mx.clear();
|
||||
mx.update(MD_MAX72XX::OFF);
|
||||
|
||||
for (uint16_t i=0; i<256; i++)
|
||||
{
|
||||
mx.clear(0);
|
||||
mx.setChar(COL_SIZE-1, i);
|
||||
|
||||
if (MAX_DEVICES >= 3)
|
||||
{
|
||||
char hex[3];
|
||||
|
||||
sprintf(hex, "%02X", i);
|
||||
|
||||
mx.clear(1);
|
||||
mx.setChar((2*COL_SIZE)-1,hex[1]);
|
||||
mx.clear(2);
|
||||
mx.setChar((3*COL_SIZE)-1,hex[0]);
|
||||
}
|
||||
|
||||
mx.update();
|
||||
delay(DELAYTIME*2);
|
||||
}
|
||||
mx.update(MD_MAX72XX::ON);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
mx.begin();
|
||||
|
||||
#if DEBUG
|
||||
Serial.begin(57600);
|
||||
#endif
|
||||
PRINTS("\n[MD_MAX72XX Test & Demo]");
|
||||
// scrollText("MD_MAX72xx Test ");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
#if 1
|
||||
scrollText("Graphics");
|
||||
zeroPointSet();
|
||||
rows();
|
||||
columns();
|
||||
cross();
|
||||
stripe();
|
||||
checkboard();
|
||||
bullseye();
|
||||
bounce();
|
||||
spiral();
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
scrollText("Control");
|
||||
intensity();
|
||||
scanLimit();
|
||||
blinking();
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
scrollText("Transform");
|
||||
transformation1();
|
||||
transformation2();
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
scrollText("Charset");
|
||||
wrapText();
|
||||
showCharset();
|
||||
#endif
|
||||
}
|
40
hardware/tests/dht22/dht22.ino
Normal file
40
hardware/tests/dht22/dht22.ino
Normal file
@ -0,0 +1,40 @@
|
||||
/* How to use the DHT-22 sensor with Arduino uno
|
||||
Temperature and humidity sensor
|
||||
*/
|
||||
|
||||
//Libraries
|
||||
#include <DHT.h>
|
||||
|
||||
//Constants
|
||||
#define DHTPIN 2 // what pin we're connected to
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302)
|
||||
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
|
||||
|
||||
|
||||
//Variables
|
||||
int chk;
|
||||
float hum; //Stores humidity value
|
||||
float temp; //Stores temperature value
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2000);
|
||||
//Read data and store it to variables hum and temp
|
||||
hum = dht.readHumidity();
|
||||
temp= dht.readTemperature();
|
||||
//Print temp and humidity values to serial monitor
|
||||
Serial.print("Humidity: ");
|
||||
Serial.print(hum);
|
||||
Serial.print(" %, Temp: ");
|
||||
Serial.print(temp);
|
||||
Serial.println(" Celsius");
|
||||
delay(10000); //Delay 2 sec.
|
||||
}
|
||||
|
||||
|
86
hardware/tests/rtc_ds3231/rtc_ds3231.ino
Normal file
86
hardware/tests/rtc_ds3231/rtc_ds3231.ino
Normal file
@ -0,0 +1,86 @@
|
||||
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
|
||||
#include "RTClib.h"
|
||||
|
||||
RTC_DS3231 rtc;
|
||||
|
||||
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
|
||||
|
||||
void setup () {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifndef ESP8266
|
||||
while (!Serial); // wait for serial port to connect. Needed for native USB
|
||||
#endif
|
||||
|
||||
if (! rtc.begin()) {
|
||||
Serial.println("Couldn't find RTC");
|
||||
Serial.flush();
|
||||
abort();
|
||||
}
|
||||
|
||||
if (rtc.lostPower()) {
|
||||
Serial.println("RTC lost power, let's set the time!");
|
||||
// When time needs to be set on a new device, or after a power loss, the
|
||||
// following line sets the RTC to the date & time this sketch was compiled
|
||||
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
|
||||
// This line sets the RTC with an explicit date & time, for example to set
|
||||
// January 21, 2014 at 3am you would call:
|
||||
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
|
||||
}
|
||||
|
||||
// When time needs to be re-set on a previously configured device, the
|
||||
// following line sets the RTC to the date & time this sketch was compiled
|
||||
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
|
||||
// This line sets the RTC with an explicit date & time, for example to set
|
||||
// January 21, 2014 at 3am you would call:
|
||||
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
|
||||
}
|
||||
|
||||
void loop () {
|
||||
DateTime now = rtc.now();
|
||||
|
||||
Serial.print(now.year(), DEC);
|
||||
Serial.print('/');
|
||||
Serial.print(now.month(), DEC);
|
||||
Serial.print('/');
|
||||
Serial.print(now.day(), DEC);
|
||||
Serial.print(" (");
|
||||
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
|
||||
Serial.print(") ");
|
||||
Serial.print(now.hour(), DEC);
|
||||
Serial.print(':');
|
||||
Serial.print(now.minute(), DEC);
|
||||
Serial.print(':');
|
||||
Serial.print(now.second(), DEC);
|
||||
Serial.println();
|
||||
|
||||
Serial.print(" since midnight 1/1/1970 = ");
|
||||
Serial.print(now.unixtime());
|
||||
Serial.print("s = ");
|
||||
Serial.print(now.unixtime() / 86400L);
|
||||
Serial.println("d");
|
||||
|
||||
// calculate a date which is 7 days and 30 seconds into the future
|
||||
DateTime future (now + TimeSpan(7,12,30,6));
|
||||
|
||||
Serial.print(" now + 7d + 30s: ");
|
||||
Serial.print(future.year(), DEC);
|
||||
Serial.print('/');
|
||||
Serial.print(future.month(), DEC);
|
||||
Serial.print('/');
|
||||
Serial.print(future.day(), DEC);
|
||||
Serial.print(' ');
|
||||
Serial.print(future.hour(), DEC);
|
||||
Serial.print(':');
|
||||
Serial.print(future.minute(), DEC);
|
||||
Serial.print(':');
|
||||
Serial.print(future.second(), DEC);
|
||||
Serial.println();
|
||||
|
||||
Serial.print("Temperature: ");
|
||||
Serial.print(rtc.getTemperature());
|
||||
Serial.println(" C");
|
||||
|
||||
Serial.println();
|
||||
delay(3000);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user