I was impressed by JQ6500 audio shield. easy to use & good clarity & amplification.
But I need help running it using digispark USB digistump attiny85
code below is not compiling
I am getting error:
fatal error: TinyPinChange.h: No such file or directory #include <TinyPinChange.h>
/** Example sketch which plays files on the media in random order.
*
* @author James Sleeman, http://sparks.gogo.co.nz/
* @license MIT License
* @file
*/modified by goldenshuttle attempt to run on digispark USB digistump attiny85
#include <Arduino.h>
#include <SoftSerial.h>
#include <JQ6500_Serial.h>
// Create the mp3 module object,
// Arduino Pin 2 is connected to TX of the JQ6500
// Arduino Pin 3 is connected to one end of a 1k resistor,
// the other end of the 1k resistor is connected to RX of the JQ6500
// If your Arduino is 3v3 powered, you can omit the 1k series resistor
JQ6500_Serial mp3(2,3);
unsigned int numFiles; // Total number of files on media (autodetected in setup())
byte mediaType; // Media type (autodetected in setup())
void setup() {
// Start debugging terminal
Serial.begin(9600);
// Begin the connection, reset the device, and set volume to a reasonable level
mp3.begin(9600);
while(numFiles == 0)
{
mp3.reset();
mp3.setVolume(20);
mp3.setLoopMode(MP3_LOOP_NONE);
// Try to get the number of files on the SD Card
numFiles = mp3.countFiles(MP3_SRC_SDCARD);
if(numFiles)
{
// If there are SD Card files, make sure we have selected that source
mp3.setSource(MP3_SRC_SDCARD);
mediaType = MP3_SRC_SDCARD;
}
else
{
// If none are found, the SD Card is not present or empty, so use
// the on board memory; Make sure we select the built in source
mp3.setSource(MP3_SRC_BUILTIN);
numFiles = mp3.countFiles(MP3_SRC_BUILTIN);
mediaType = MP3_SRC_BUILTIN;
}
if(!numFiles)
{
Serial.println(F("Error! No files were found on the media, both SD Card and Built In memory were checked."));
Serial.println(F("We will try again in 3 seconds."));
Serial.println(F("If there are files there and we still can't find them, try turning everything off and on again, perhaps the module is confused."));
Serial.println(F("I think this might happen sometimes if you insert/remove an SD Card while powered up, but not totally sure!"));
Serial.println(F("In a real application, you might consider powering the JQ6500 module through a suitable MOSFET or BJT controlled from a pin so you can power-cycle the JQ6500 if it starts to act weird like this!"));
delay(3000);
}
}
}
void loop() {
// ** NOTE: Checking for STOPPED doesn't work with the builtin memory
// because in that case the devie appears to only return PAUSED, not STOPPED
byte stat = mp3.getStatus();
if(stat != MP3_STATUS_PLAYING)
{
// pick a random file, numbered 1 to numFiles (NB: random() returns up to but not including the highest number, hence why we add 1)
// if the file is the same as the one which was just played, pick a different one
unsigned int pick;
do
{
pick = random(1,numFiles+1);
} while(pick == mp3.currentFileIndexNumber(mediaType));
Serial.print("Randomly selected #");
Serial.print(pick);
Serial.print(" of ");
Serial.println(numFiles);
// and play it
mp3.playFileByIndexNumber(pick);
mp3.play();
// if we are in SD Card mode, we can print the file name
// the built in memory does not have file names
if(mediaType == MP3_SRC_SDCARD)
{
char buffer[20];
mp3.currentFileName(buffer, sizeof(buffer));
Serial.print("> ");
Serial.println(buffer);
}
}
}
@Paul...thanks really funny reply..Im a no-wastage minded so I do not tend to repeat the same code becoz of one line...anyhow; if it suits, here is the code
#include <TinyPinChange.h>
/** Example sketch which plays files on the media in random order.
*
* @author James Sleeman, http://sparks.gogo.co.nz/
* @license MIT License
* @file
*/modified by goldenshuttle attempt to run on digispark USB digistump attiny85
#include <Arduino.h>
#include <SoftSerial.h>
#include <JQ6500_Serial.h>
// Create the mp3 module object,
// Arduino Pin 2 is connected to TX of the JQ6500
// Arduino Pin 3 is connected to one end of a 1k resistor,
// the other end of the 1k resistor is connected to RX of the JQ6500
// If your Arduino is 3v3 powered, you can omit the 1k series resistor
JQ6500_Serial mp3(2,3);
unsigned int numFiles; // Total number of files on media (autodetected in setup())
byte mediaType; // Media type (autodetected in setup())
void setup() {
// Start debugging terminal
Serial.begin(9600);
// Begin the connection, reset the device, and set volume to a reasonable level
mp3.begin(9600);
while(numFiles == 0)
{
mp3.reset();
mp3.setVolume(20);
mp3.setLoopMode(MP3_LOOP_NONE);
// Try to get the number of files on the SD Card
numFiles = mp3.countFiles(MP3_SRC_SDCARD);
if(numFiles)
{
// If there are SD Card files, make sure we have selected that source
mp3.setSource(MP3_SRC_SDCARD);
mediaType = MP3_SRC_SDCARD;
}
else
{
// If none are found, the SD Card is not present or empty, so use
// the on board memory; Make sure we select the built in source
mp3.setSource(MP3_SRC_BUILTIN);
numFiles = mp3.countFiles(MP3_SRC_BUILTIN);
mediaType = MP3_SRC_BUILTIN;
}
if(!numFiles)
{
Serial.println(F("Error! No files were found on the media, both SD Card and Built In memory were checked."));
Serial.println(F("We will try again in 3 seconds."));
Serial.println(F("If there are files there and we still can't find them, try turning everything off and on again, perhaps the module is confused."));
Serial.println(F("I think this might happen sometimes if you insert/remove an SD Card while powered up, but not totally sure!"));
Serial.println(F("In a real application, you might consider powering the JQ6500 module through a suitable MOSFET or BJT controlled from a pin so you can power-cycle the JQ6500 if it starts to act weird like this!"));
delay(3000);
}
}
}
void loop() {
// ** NOTE: Checking for STOPPED doesn't work with the builtin memory
// because in that case the devie appears to only return PAUSED, not STOPPED
byte stat = mp3.getStatus();
if(stat != MP3_STATUS_PLAYING)
{
// pick a random file, numbered 1 to numFiles (NB: random() returns up to but not including the highest number, hence why we add 1)
// if the file is the same as the one which was just played, pick a different one
unsigned int pick;
do
{
pick = random(1,numFiles+1);
} while(pick == mp3.currentFileIndexNumber(mediaType));
Serial.print("Randomly selected #");
Serial.print(pick);
Serial.print(" of ");
Serial.println(numFiles);
// and play it
mp3.playFileByIndexNumber(pick);
mp3.play();
// if we are in SD Card mode, we can print the file name
// the built in memory does not have file names
if(mediaType == MP3_SRC_SDCARD)
{
char buffer[20];
mp3.currentFileName(buffer, sizeof(buffer));
Serial.print("> ");
Serial.println(buffer);
}
}
}
this is the error in compile
fatal error: SoftwareSerial.h: No such file or directory #include <SoftwareSerial.h>
The EXACT error message includes the line number and the column number where the compiler threw up its hands and said "what rubbish". Since you still posted only a small snippet of the error message, I'll assume that you really don't want help.
What I find hard to imagine, though, is why the compiler would complain, even vaguely, about SoftwareSerial.h, when your code does not #include SoftwareSerial.h.
Frankly I didn t pay attention to the rest of the message; but here is the entire error message..forgive my rush..but of course I need help..
In file included from stump_JQ_try.ino:14:0:
C:\Users\Duke.Duke-PC\Documents\Arduino\libraries\JQ6500_Serial-master/JQ6500_Serial.h:35:28: fatal error: SoftwareSerial.h: No such file or directory #include <SoftwareSerial.h>
^
compilation terminated.
Error compiling.
SoftwareSerial is not designed to work on all Arduinos or things pretending that they could be, if you squinted, mistaken for an Arduino. So, there are, as part of the build process, files that are consulted to determine if it is appropriate to include the SoftwareSerial header, based on the directory where it lives.
Perhaps those files, for your digistump, are not accurate/up-to-date.
Thanks Paul...any advice how to mitigate this for a beginner ?
I thought <SoftSerial.h> is the digistump equivalent for <SoftwareSerial.h>
But they did not function together or away from each other..
I thought <SoftSerial.h> is the digistump equivalent for <SoftwareSerial.h>
It looks like it is, which is why I don't understand why other code is trying to include SoftwareSerial.h. Perhaps if those files were changed to use SoftSerial.h instead, the code would compile.
thanks Paul..this is educating and useful..yet costing time..I will move back 2 Nano or miniPro since Im not being able 2 sort it..just need to get the lovely JQ6500 randomly play on a small gadget w smallest possible arduino.
After modyfying the JQ6500_Serial class to use SoftSerial and adding timedRead() (normally inherited from Stream, but the Stream class in the Digistump tiny core does not have it) I got this:
Sketch uses 6,536 bytes (108%) of program storage space. Maximum is 6,012 bytes.
Luckily we can compress this excerpt of War and Peace over the MP3 Player
Serial.println(F("Error! No files were found on the media, both SD Card and Built In memory were checked."));
Serial.println(F("We will try again in 3 seconds."));
Serial.println(F("If there are files there and we still can't find them, try turning everything off and on again, perhaps the module is confused."));
Serial.println(F("I think this might happen sometimes if you insert/remove an SD Card while powered up, but not totally sure!"));
Serial.println(F("In a real application, you might consider powering the JQ6500 module through a suitable MOSFET or BJT controlled from a pin so you can power-cycle the JQ6500 if it starts to act weird like this!"));
into
Serial.println(F("No files found!"));
Serial.println(F("Retrying in 3 seconds"));
Sketch uses 5,992 bytes (99%) of program storage space. Maximum is 6,012 bytes.
Global variables use 222 bytes of dynamic memory.
Omitting Serial output completely will save a few hundred bytes more.
@oqibidipo: I really do not need to print serial anything. so if it saves memory it would be great to omit.
I will run the info you gave and see what happens. I was afraid to get another ghostly hint like some sadist members are doing here...many thanks indeed.
After trying this solution by oqibidipo; the entire IDE is no more working after I loaded the modified library of digistump..IDE began giving errors even on previously working sketches..so now I had to remove this library, uninstal and reinstall Arduino IDE; back to square one looking for a solution...