Hello!
I'm working on an Escape Room puzzle and I got stuck pretty hard. I've been searching for a few hours and didn't find anything helpful so I thought maybe someone can point me in the right direction.
I'm relatively new to arduino (a year or so) and I've learnt a lot from the forum so, thanks!
The part I'm working on right now is supposed to receive 4 inputs from other arduinos in the room (single wire that turns High when another puzzle is solved) and then turn on a few lights (12v LED strips) depending on how many inputs are high.
I'm using an arduino nano, 4 TPIC6b595 shift registers to control the 12v LEDs and a dfplayer module to play sounds. Everything is powered with a 12v power source and I have an LM2596 step down module that lowers the 12v to 5v to power the arduino and the DFPlayer.
Everything is soldered to a custom made pcb. There is also a rs485 chip and a few connectors there, I'm not currently using them but I put them there trying to plan ahead so in the near future I can control the arduinos from another room.
You can find the schematic attached.(semafor.pdf)
I started coding the part that has to do with the TPIC's. It is done and works well, all the lights turn on and off when they should.
But when I was going to add the code for the dfplayer I found out the shift registers stoped working.
I started commenting out parts of the code and I found out the one messing it up is the SoftwareSerial. If I comment out the line where I create a new instance of the SoftwareSerial it works.
This is the line that makes the shift register stop working:
SoftwareSerial mySoftwareSerial(8, 12); // RX, TX
You can find attached the schematic and here goes the full code: (it is not finished, it's just there to test everything works as expected, the "for" in the loop won't be there in production)
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
//SoftwareSerial mySoftwareSerial(8, 12); // RX, TX
//DFRobotDFPlayerMini myDFPlayer;
//declare display driver pins
const int latchPin = 10;
const int clockPin = 9;
const int dataPin = 11;
//Declare input pins
const int inputpins[4] = {A4,A5,A6,A7};
//Declare helper variables and constants
int activeInputs = 0;
int currentFase = 0;
const byte faseDataMap[6][4] =
{// {faseDreta,passEsquerra,passDreta,faseEsquerra}
{0,0,0,0},
{192,0,0,192},
{240,0,0,240},
{252,0,0,252},
{255,0,0,255},
{0,255,255,0}
};
void setup() {
//Start USB Serial Comms
Serial.begin(9600);
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(7,OUTPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);
pinMode(A6,INPUT);
pinMode(A7,INPUT);
//turn drivers ON
digitalWrite(7,LOW);
//turn all leds off
for (int i=3; i>=0; i--)
{
shiftOut(dataPin, clockPin, LSBFIRST, 0);
}
}//END SETUP
//----------------------------------------------
//----------------------------------------------
void loop() {
//checkInputs();
for (int i=0; i<=3; i++)
{
activeInputs = i;
lightEmUp();
delay(2000);
}
lightEmUp();
}//END LOOP
//----------------------------------------------
//----------------------------------------------
void checkInputs()
{
activeInputs = 0;
for (int i=0; i<=3; i++)
{
if (digitalRead(inputpins[i]) == HIGH){
activeInputs++;
}
}
}//END CHECKINPUTS ------------
void lightEmUp()
{
digitalWrite(latchPin, LOW);
//move 'em out
for (int i=3; i>=0; i--)
{
shiftOut(dataPin, clockPin, LSBFIRST, faseDataMap[activeInputs][i]);
}
//return the latch pin high to signal chip that it
//no longer needs to listen for information
digitalWrite(latchPin, HIGH);
}//END LIGHTEMUP ------------
Is there any way for me to use the dfplayer at the same time as the shift registers?
Thanks a lot!
Sorry if my english is not good enough, if something is not clear, please ask and I'll try to explain that part better.
semafor.pdf (51.5 KB)