As you have discovered, the Uno R4 does not support SoftwareSerial because it doesn't need to
so shall i remove SoftwareSerial from the code?
Yes
Just use pins 0 and 1 and Serial1 within the sketch instead of the SoftwareSerial object
Indeed!
Please post your code in code tags
I would have copied your mistake but can't sensibly copy part of your picture of code to explain what is wrong
You don't change SoftwareSerial into anything. You just user Serial1 the same way that you would use Serial
Either do as @UKHeliBob advises, or get another Nano as you said you were using ever since post 1.
All I did was copy and paste Terrypin's code. I then removed SoftwareSerial because when i asked you said yes, i then replaced it with Serial1 and got that result.
int pirPin = 3; // my edit
// int pirPin = 12; // Arduino pin the PIR sensor is connected to
int rxPin = 10; // my edit
// int rxPin = 3; // Arduino pin the TX pin of mp3 player is connected to
int txPin = 11; // my edit
// int txPin = 2; // Arduino pin the RX pin of mp3 player is connected to
int ledPin = 13; //Arduino built-in LED, and a more visible one
int motionStatus = 0; // variable to store the PIR's current reading (high or low)
int pirState = 0; // variable to store the PIR's state change
int track = 1; // variable to store current track number
Serial1 fxSerial(rxPin, txPin); // Software Serial object
DFRobotDFPlayerMini fxPlayer;
void setup()
{
pinMode(pirPin, INPUT); // set Arduino pin that PIR is connected to as an INPUT
pinMode(rxPin, INPUT); // set Arduino pin that mp3 player TX is connected to as an INPUT
pinMode(txPin, OUTPUT); // set Arduino pin that mp3 player RX is connected to as an OUTPUT
pinMode(ledPin, OUTPUT); // my edit
Serial.begin(115200); // my preference
// Serial.begin(9600); // initialize Serial Monitor (for looking at PIR readings)
fxSerial.begin(9600); // initialize Serial communication for mp3 player
fxPlayer.begin(fxSerial); // tells mp3 player to use fxSerial for communication
delay(1000); // my edit
fxPlayer.volume(15); // my edit // mp3 player volume (pick a value 10-30)
delay(8000); // my edit, allow say 8 secs for PIR sensor to settle
}
void loop()
{
motionStatus = digitalRead(pirPin); // read the PIR pin's current output (is it HIGH or LOW?)
// if PIR pin output is HIGH:
if (motionStatus == HIGH)
{
if (pirState == LOW)
{
Serial.println("Motion Detected"); // print result to the serial monitor
digitalWrite(ledPin, LOW); // turn OFF built-in LED
pirState = HIGH; // update the previous PIR state to HIGH
fxPlayer.play(track); // play up to 3 s of current track
// delay(1000); // // my edit length in MILLIseconds of the current track
// delay(5000); // length in microseconds of the longest track
track++; // add 1 to the current track for the next loop
// if track number tries to exceed 5 (I have 5 total in my case)
if (track > 5)
{ // change this value to match your total # of tracks
track = 1; // reset track number to 1
}
}
}
// or else if PIR pin output is LOW:
else
{
// if (pirState == LOW)
if (pirState == HIGH)
{
Serial.println("Motion Ended"); //print result to the serial monitor
digitalWrite(ledPin, HIGH); // turn ON built-in LED
pirState = LOW; // update the previous PIR state to LOW
}
}
}
I got my other Nano to finaly work with my laptop again but i get this when trying to upload.
FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
C:\Users\callu\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\callum\AppData\Local\arduino\sketches\8F464C72E6D35ECDBA16E0B9E62A4491\sketch\sketch_aug29a.ino.cpp -o nul
Generating function prototypes...
C:\Users\callu\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\callu\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\callum\AppData\Local\arduino\sketches\8F464C72E6D35ECDBA16E0B9E62A4491\sketch\sketch_aug29a.ino.cpp -o C:\Users\callum\AppData\Local\Temp\2676374344\sketch_merged.cpp
C:\Users\callu\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\callum\AppData\Local\Temp\2676374344\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\callu\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\callu\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\callu\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\callum\\AppData\\Local\\arduino\\sketches\\8F464C72E6D35ECDBA16E0B9E62A4491\\sketch\\sketch_aug29a.ino.cpp" -o "C:\\Users\\callum\\AppData\\Local\\arduino\\sketches\\8F464C72E6D35ECDBA16E0B9E62A4491\\sketch\\sketch_aug29a.ino.cpp.o"
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:12:1: error: 'SoftwareSerialHardware' does not name a type
SoftwareSerialHardware fxSerial(rxPin, txPin); // Software Serial object
^~~~~~~~~~~~~~~~~~~~~~
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:13:1: error: 'DFRobotDFPlayerMini' does not name a type
DFRobotDFPlayerMini fxPlayer;
^~~~~~~~~~~~~~~~~~~
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino: In function 'void setup()':
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:24:3: error: 'fxSerial' was not declared in this scope
fxSerial.begin(9600); // initialize Serial communication for mp3 player
^~~~~~~~
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:24:3: note: suggested alternative: 'Serial'
fxSerial.begin(9600); // initialize Serial communication for mp3 player
^~~~~~~~
Serial
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:25:3: error: 'fxPlayer' was not declared in this scope
fxPlayer.begin(fxSerial); // tells mp3 player to use fxSerial for communication
^~~~~~~~
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino: In function 'void loop()':
C:\Users\callum\AppData\Local\Temp\.arduinoIDE-unsaved2025729-14588-1ggpfob.0ils\sketch_aug29a\sketch_aug29a.ino:43:7: error: 'fxPlayer' was not declared in this scope
fxPlayer.play(track); // play up to 3 s of current track
^~~~~~~~
exit status 1
Compilation error: 'SoftwareSerialHardware' does not name a type
Remove this line
Serial1 fxSerial(rxPin, txPin); // Software Serial object
Change this
fxSerial.begin(9600); // initialize Serial communication for mp3 player
to
Serial1.begin(9600); // initialize Serial1 communication for mp3 player
Change this
fxPlayer.begin(fxSerial); // tells mp3 player to use fxSerial for communication
to
fxPlayer.begin(Serial1); // tells mp3 player to use Serial1 for communication
Please stop posting error messages without the code that caused them
Where does SoftwareSerialHardware appear in this topic apart from your post 51 ?
You need to check your code more carefully before rattling off hasty posts. There are various errors but the most ovbious one is this missing line:
#include <DFRobotDFPlayerMini.h> // download this library from Arduino IDE "Manage Libraries"
As my final contribution here is a version for hardware serial. Read it carefully and make appropriate pin changes to suit your board, as this is for my MEGA2560, where it works correctly.
Good luck.
/*
Fri 29 Aug 2025; Revised for a board using hadware serial,
MEGA2560 in my case.
*/
#include <DFRobotDFPlayerMini.h> // download this library from Arduino IDE "Manage Libraries"
int pirPin = 3; // my edit
int ledPin = 13; //Arduino built-in LED, and a more visible one
int motionStatus = 0; // variable to store the PIR's current reading (high or low)
int pirState = 0; // variable to store the PIR's state change
int track = 1; // variable to store current track number
// Serial1: Rx=19 (to DFR Tx),Tx=18 (to 1k then DFR Rx)
DFRobotDFPlayerMini fxPlayer;
void setup()
{
pinMode(pirPin, INPUT); // set Arduino pin that PIR is connected to as an INPUT
pinMode(ledPin, OUTPUT); // my edit
Serial.begin(115200); // my preference
delay(200);
Serial1.begin(9600);
delay(200);
fxPlayer.begin(Serial1); // tells mp3 player to use Serial1 for communication
delay(1000); // my edit
fxPlayer.volume(15); // my edit // mp3 player volume (pick a value 10-30)
delay(8000); // my edit, allow say 8 secs for PIR sensor to settle
Serial.println("Setup ended");
}
void loop()
{
motionStatus = digitalRead(pirPin); // read the PIR pin's current output (is it HIGH or LOW?)
// if PIR pin output is HIGH:
if (motionStatus == HIGH)
{
if (pirState == LOW)
{
Serial.println("Motion Detected"); // print result to the serial monitor
digitalWrite(ledPin, LOW); // turn OFF built-in LED
pirState = HIGH; // update the previous PIR state to HIGH
fxPlayer.play(track); // play up to 3 s of current track
// delay(1000); // // my edit length in MILLIseconds of the current track
// delay(5000); // length in microseconds of the longest track
track++; // add 1 to the current track for the next loop
// if track number tries to exceed 5 (I have 5 total in my case)
if (track > 5)
{ // change this value to match your total # of tracks
track = 1; // reset track number to 1
}
}
}
// or else if PIR pin output is LOW:
else
{
// if (pirState == LOW)
if (pirState == HIGH)
{
Serial.println("Motion Ended"); //print result to the serial monitor
digitalWrite(ledPin, HIGH); // turn ON built-in LED
pirState = LOW; // update the previous PIR state to LOW
}
}
}
My apologies if that document I linked was mis-leading.
No need, not your fault.
![]()
He did in post #9, only there he described something totally different to what he is claiming to use now!.
And post #1.
Hi all, I seam to be having an issue which I believe is a power problem, everything is all wired up nicely to my knowledge but the dfplayer mini seams to light up for a split second before turning off could this be due to lack of power the Arduino nano V3 is getting if so would increasing the power given to the nano solve this problem? If sould what would be the best way to boost the power?

