Relay - Basic functionality
This page contains some basic examples with function documentation on how to use LED matrix board.
Controlling a specific LED
To control a specific LED on matrix, call setPoint() function.
mx.setPoint(0,0,true);
mx.setPoint()
Set the status of a single LED, addressed as a pixel.
Returns value: Returns bool value, false if parameter errors, true otherwise.
Function parameters:
| Type | Name | Description |
|---|---|---|
uint16_t | r | Row coordinate for the point [0..ROW_SIZE-1]. |
uint16_t | c | Column coordinate for the point [0..getColumnCount()-1] |
bool | state | Sets the state of pixel. |
Controlling a specific row or column
To control an entire row or column, call setRow() function for rows or setColumn() function for columns. Using setPoint() function in for-loop also works!
mx.setRow(3,0xff);
mx.setColumn(5,0xff);
mx.setColumn()
Set all LEDs in a specific column to a new state.
Returns value: Returns bool value, false if parameter errors, true otherwise
Function parameters:
| Type | Name | Description |
|---|---|---|
uint8_t | c | Column which is to be set [0..getColumnCount()-1]. |
uint8_value | value | Each bit set to 0xff will light up the corresponding LED. |
mx.setRow()
Set all LEDs in a specific row to a new state.
Returns value: Returns bool value, false if parameter errors, true otherwise
Function parameters:
| Type | Name | Description |
|---|---|---|
uint8_t | c | Row which is to be set [0..getRowCount()-1]. |
uint8_value | value | Each bit set to 0xff will light up the corresponding LED. |
Controlling the intensity of LEDs
To control the status of the specified parameter, for example in this code brightness, call control() function.
for(int8_t i=0;i<MAX_INTENSITY;i++){
delay(500);
mx.control(Led_Matrix::INTENSITY, i);
}
mx.control()
Set the control status of the specified parameter for all devices.
Returns value: none
Function parameters:
| Type | Name | Description |
|---|---|---|
controlRequest_t | mode | One of the defined control requests. |
int | value | Parameter value for one of the control status defined. |
Full example
Try all of the above mentioned functions in this full example:
#include "Led-Matrix-SOLDERED.h"
#include <SPI.h>
#define HARDWARE_TYPE Led_Matrix::PAROLA_HW
#define MAX_DEVICES 1
#define CLK_PIN 18 // or SCK
#define DATA_PIN 23 // or MOSI
#define CS_PIN 4 // or LOAD
Led_Matrix mx = Led_Matrix(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); // SPI hardware interface
void setup() {
mx.begin();
}
void loop() {
mx.setPoint(0,0,true);
mx.setRow(3,0xff);
mx.setColumn(5,0xff);
for(int8_t i=0;i<MAX_INTENSITY;i++){
delay(500);
mx.control(Led_Matrix::INTENSITY, i);
}
}