This page explains how to add a Serial Base Class to the Arduino Serial classes.
A Base Class lays down some guidelines for how you build a bunch of related classes. In our case we're using serial classes. The base class will give us a set of methods that are available in all of the classes that are based upon it.
The short answer: to make things easier.
The long answer: there are a lot of confusing bits when it comes to interfacing with a serial device. Using a Serial Base Class for the serial devices on the Arduino will allow for better hardware abstraction. This way, we don't need to know exactly how a device is connected to our hardware - but we will be able to talk to it in the same way if it were connected to a hardware serial pin or a software serial pin.
OK. You've read the stuff above, and you're thinking, “what a bunch of mumbo-jumbo. I don't care. How do I add this silly thing?”. Well you're in luck. Here are the steps:
With the 1.0+ releases there is a built in software serial interface that will allow your project to work with the rMP3 shield. Here is some example code:
//Use the SoftwareSerial in place of NewSoftSerial.h #include <SoftwareSerial.h> #include <RogueMP3.h> //Use SoftwareSerial in place of NewSoftSerial SoftwareSerial rmp3_serial(6, 7); RogueMP3 rmp3(rmp3_serial); void setup() { Serial.begin(9600); rmp3_serial.begin(9600); rmp3.sync(); rmp3.playfile("/Daft Punk - Technologic.mp3"); } void loop() { }
The NewSoftSerial files do not need to be installed with the Arduino 1.0+ versions.
After collaboration with the people of the Arduino development mailing list, the name of the base class was changed from SerialBase to Stream. Unfortunately, there is still a problem with the Arduino core, so you still need download a modified version.
SKETCHBOOK/hardware folder (create the hardware folder if it doesn't exist).These Arduino Versions are messed up. Don't download them.
SKETCHBOOK/hardware folder (create the hardware folder if it doesn't exist).SerialBase.h to your arduino/hardware/cores/arduino folder.HardwareSerial.cpp and HardwareSerial.h in arduino/hardware/cores/arduino.To make it easier, I've already made the changes and they can be downloaded from:
Google Code - Rogue Robotics Libraries for Arduino
SerialBase.h, HardwareSerial.h, HardwareSerial.cpp → arduino/hardware/cores/arduino.
The modified NewSoftSerial library can replace your existing NewSoftSerial library in arduino/hardware/libraries.
After that, you're ready to go!
Discussion
How's this working on 0019, is it still the same as on 0018?
I have also been having some issues and I can't remember what I've done/not done.
Error:
sketch_sep06a.cpp: In function 'void doLCDSpec()':
sketch_sep06a:120: error: 'class RogueMP3' has no member named 'getspectrumanalyzer'
sketch_sep06a.cpp: In function 'void playTrack()':
sketch_sep06a:180: error: 'class RogueSD' has no member named 'entrytofilename'
sketch_sep06a:185: error: 'class RogueMP3' has no member named 'setspectrumanalyzer'
Thanks,
Mowcius
Added the information for Arduino IDE 0021.
RE: the RogueSD and RogueMP3 errors you're getting, you need to download the latest versions of the libraries (V0004+ and V0003+ respectively).
b
I have an Arduino Mega board with the Rogue rMP3 shield. I've been trying to download the correct versions and fixes of the software and libraries in order to get the XMAS sample program to work. I'm getting the following error: no matching function for call to 'RogueMP3::RogueMP3(NewSoftSerial&)'C:\Program Files\Arduino\arduino-0018\libraries\RogueMP3/RogueMP3.h:114: note: candidates are: RogueMP3::RogueMP3(SerialBase&)
C:\Program Files\Arduino\arduino-0018\libraries\RogueMP3/RogueMP3.h:107: note: RogueMP3::RogueMP3(const RogueMP3&)
Would it be possible for me to download or receive by email a zipped copy of all the directories and files nessasary to establish communication?
Hi Don,
The Arduino Mega should be a snap. Use one of the hardware serial ports instead. Use the rMP3 on an Arduino Mega example to help.
If you need any more help, just email support@roguerobotics.com.
b
I would like to use one of these for the next wearable peonfrmarce piece in a series I call Being Counted The first in the series, which I have already completed, is a neclace which senses when the wearer has swallowed, counts it, and keeps a running led display of the number of times on a pendant. The piece is intended to be worn to perform the action of swallowing. It makes visible the invisible and surveilles the mundane. Our space is becoming increasingly inundated with technologies which watch, count, and measure with little supervision. These technologies have become so embedded in our material world as well as our consciousness that they have become almost invisible to us. In many cases, we desire these objects that infringe on our rights to privacy, other times they are foisted upon us. The piece also speaks to a type of personal surveillance practiced by many who self-consciously pore over every bite of food. By creating a wearable object which counts the seemingly mundane, I seek to create an awareness in the viewer- an awareness that we are all being counted.I chose new materials, sillicone and acrylic, and combined them with old lace patterns to reference restriction and bodily awareness. The necklace/choker is a strip of silicon sheet that I hand punched in a delicate lace pattern. The pendant, the housing for the electronics, is made of lazer-cut clear acrylic in a doilly pattern. The sensing is done with a 4” flex sensor. The signal is read by an arduino lilypad which counts the signals and drives a multiplex 4-digit, 7-segment led display. Ostensibly, the piece could count up to 9999 swallows. The led display has just 12 pins because it is a common cathode display. This presented several challenges in building and programing the work, but enabled me to drive the led directly with the lilypad. In order to make the common cathodes work, I placed a transistor between the pin and the lilypad. This allowed me to selectively activate single digits of the display. Another challenge was presented in the delays necessary to individually light each digit and also in reading the sensor. These were eventually worked out so that the display lights continually and the sensor is read only once a second (so as to avoid multiple readings for the same swallow). The piece is soft in order to interact with the body of the wearer. These material choices were a combination of practicality and aesthetic choices with regards to a victorian-tech idea.I would like to continue this series of banal counters for the body. The next one I plan is a bracelet which counts the number of times the wearer swings their arm.