I am building a wireless fireworks display system that will trigger my fireworks in different sequences. I currently have 5 buttons on the TX side and 5 leds on the RX side to simulate the igniter. This allows me to see how to sequence will play out for testing.
materials used:
2 x uno
2 X 24l01 wireless tranceivers.RX&TX
5 x leds RX
5 x resistors.RX
5 x buttons on the RX
LIbraries:
ezButton.h
The system is supposed to allow the user to select 1 of 5 buttons or triggers on the TX side. Once that trigger or button is pressed the RX should activate a firing sequence for out put. If I press trigger one trigger 1 on the RX side should activate that firing sequence. right now no matter what trigger you press only the sequence assigned to trigger 1 will initiate.
the issue that I am having is when I press all of the other buttons they only trigger the sequence assigned to trigger instead of the sequence assigned to that button.
no matter what button is pressed with receiver is getting a message to initiate button 1s, sequnce. I was hoping some one could help me with this issue.
I will enclose my code so you are able to see how I have things set up and please feel free to point out any thing you see that would be causing this problem.
THIS IS THE TX
#include <SPI.h>
#include "RF24.h"
#include <ezButton.h>
byte addresses[] [6] = {"0"};
a
RF24 radio(7,8);
ezButton trigger1 (2);
ezButton trigger2 (3);
ezButton trigger3 (4);
ezButton trigger4 (5);
ezButton trigger5 (6);
void setup() {
Serial.begin(9600);
radio.begin();
radio.setChannel(115);
radio.setPALevel(RF24_PA_MIN);
radio.openWritingPipe (0x8675309abcll);
radio.stopListening();
delay(500);
trigger1.setDebounceTime(10);
trigger2.setDebounceTime(10);
trigger3.setDebounceTime(10);
trigger4.setDebounceTime(10);
trigger5.setDebounceTime(10);
}
void loop() {
trigger1.loop();
trigger2.loop();
trigger3.loop();
trigger4.loop();
trigger5.loop();
int trigState1 = trigger1.getState();
int trigState2 = trigger2.getState();
int trigState3 = trigger3.getState();
int trigState4 = trigger4.getState();
int trigState5 = trigger5.getState();
char text []= ("Connected");
radio.write(&text, sizeof(text));
//Series 1
if (trigger1.isReleased()){
Serial.print("trigger1 igniter 1 ");
Serial.println(trigState1);
radio.write(&trigState1, sizeof(trigState1));
}
if (trigger2.isReleased()){
Serial.print("trigger2 igniter 2 ");
Serial.println(trigState2);
radio.write(&trigState2, sizeof(trigState2));
}
if(trigger3.isReleased()){
Serial.print("trigger3 igniter 3 ");
Serial.println(trigState3);
radio.write(&trigState3, sizeof(trigState3));
}
if(trigger4.isReleased()){
Serial.print("trigger4 igniter 4 ");
Serial.println(trigState4);
radio.write(&trigState4, sizeof(trigState4));
}
if(trigger5.isReleased()){
Serial.print("trigger5 igniter 5");
Serial.println(trigState5);
radio.write(&trigState4, sizeof(trigState4));
}
delay(10);
}
THIS IS THE RX
#include <SPI.h>
#include "RF24.h"
#include <ezButton.h>
byte addresses[] [6] = {"0"};
RF24 radio(7,8);
int trigState1;
int trigState2;
int trigState3;
int trigState4;
int trigState5;
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int ledarray[6] {2, 3, 4, 5, 6};
void setup() {
Serial.begin(9600);
radio.begin();
radio.setChannel(115);
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe (0, 0x8675309abcll);
radio.startListening();
delay(500);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
void loop() {
char text [32];"";
radio.read(&text, sizeof(text));
Serial.println(text);
radio.read(&trigState1, sizeof(trigState1));
if(trigState1 == 1){
Serial.print("trigger1");
Serial.println(trigState1);
for(int i = 0; i < 6; i++){
digitalWrite(ledarray[i], HIGH);
delay(100);
for(int i = 0; i < 6; i++);
digitalWrite(ledarray[i], LOW);
}
}
radio.read(&trigState2, sizeof(trigState1));
if(trigState2 == 1){
Serial.print("trigger2");
Serial.println(trigState2);
digitalWrite(led2, HIGH);
delay(500);
digitalWrite(led2, LOW);
}
radio.read(&trigState3, sizeof(trigState3));
if(trigState3 == 1){
Serial.print("trigger3");
Serial.println(trigState3);
digitalWrite(led3, HIGH);
delay(500);
digitalWrite(led3, LOW);
}
radio.read(&trigState4, sizeof(trigState4));
if(trigState4 == 1){
Serial.print("trigger4");
Serial.println(trigState4);
digitalWrite(led4, HIGH);
delay(500);
digitalWrite(led4, LOW);
}
radio.read(&trigState5, sizeof(trigState5));
if(trigState5 == 1){
Serial.print("trigger5");
Serial.println(trigState5);
digitalWrite(led5, HIGH);
delay(500);
digitalWrite(led5, LOW);
}
delay(10);
}