In practice: I have:
2 arduino uno; 2 radio module nRF24L01, 1 8x8 LED Matrix
i need to make whit 1 arduino and 1 nRF24L01 and 2 buttons a remote control device to command other arduino whith 1 nRF24L01, 1 8x8 LED Matrix. this are the codes i found for this theme:
Transmiter:
// Code 2 : Push Button and LED (Transmitter)
// Library: TMRh20/RF24 (GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices)
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";
const int B1_Pin = 3; // Pushbutton B1
const int B2_Pin = 4; // Pushbutton B2
char txt1[] = "B1", txt2[] = "B2", txt3[] = "00";
void setup() {
Serial.begin(9600);
pinMode(B1_Pin, INPUT);
pinMode(B2_Pin, INPUT);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
};
void loop() {
int B1_State = digitalRead(B1_Pin);
int B2_State = digitalRead(B2_Pin);
if (B1_State == HIGH) {
radio.write(&txt1, sizeof(txt1)); Serial.println(txt1);
} else if (B2_State == HIGH) {
radio.write(&txt2, sizeof(txt2)); Serial.println(txt2);
} else {
radio.write(&txt3, sizeof(txt3)); Serial.println(txt3);
};
delay(100);
};
Reciver:
// Code 2 : Push Button and LED (Receiver)
// Library: TMRh20/RF24 (GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices)
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";
const int LED1_Pin = 6; // Red LED
const int LED2_Pin = 5; // Blue LED
void setup() {
Serial.begin(9600);
pinMode(LED1_Pin, OUTPUT);
pinMode(LED2_Pin, OUTPUT);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
};
void loop() {
if (radio.available()) {
char txt[5] = "";
radio.read(&txt, sizeof(txt));
switch (txt[1]) {
case '1': digitalWrite(LED1_Pin, HIGH); digitalWrite(LED2_Pin, LOW); break;
case '2': digitalWrite(LED1_Pin, LOW); digitalWrite(LED2_Pin, HIGH); break;
default : digitalWrite(LED1_Pin, LOW); digitalWrite(LED2_Pin, LOW); break;
};
Serial.println(txt);
delay(100); };
};
and now I need to insert somewhere the code for the 8x8 Matrix
This code i found is good, IDK how to combine them:
#include <LedControl.h>
// Pin 12 is connected to the DataIn
// Pin 11 is connected to the CLK
// Pin 10 is connected to LOAD
// We have only one MAX7219 (numDevices = 1)
LedControl lc = LedControl(12, 11, 10, 1);
void setup() {
// The MAX72XX is in power-saving mode on startup
lc.shutdown(0, false);
// Set the brightness to a medium value
lc.setIntensity(0, 8);
// Clear the display
lc.clearDisplay(0);
// Display smiley face
displaySmiley();
delay(2000); // Display for 2 seconds
// Clear the display
lc.clearDisplay(0);
// Display sad face
displaySad();
delay(2000); // Display for 2 seconds
}
void loop() {
// The loop is empty because we are displaying each character in setup
}
void displaySmiley() {
byte smiley[8] = {
0b00111100,
0b01000010,
0b10100101,
0b10000001,
0b10100101,
0b10011001,
0b01000010,
0b00111100
};
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, smiley[i]);
}
}
void displaySad() {
byte sad[8] = {
0b00111100,
0b01000010,
0b10100101,
0b10000001,
0b10011001,
0b10100101,
0b01000010,
0b00111100
};
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, sad[i]);
}
}
btw, this is my first post on this forum, if there are mistaken please feedback.(I`m not goot at writing in english)