For my project to work I need to get my Arduino uno to connect to wifi and play MP3 files.
I have a wifi shield working fine using the basic WiServer sketch
I have a Sparkfun MP3 shield working fine using SFEMP3Shield sketch (Sparkfun MP3 Shield Arduino Library « The Mind of Bill Porter)
However once I combine these Sketches neither shield functions.
I have remapped the pin 9 - as this is used by both shields. I have connected the MP3 player pin 9 to pin 10 on the uno. this shield in therefore not connected on top of the other but connected via ribbon cable.
Has anyone had any luck getting these two shield types to work together? Any ideas if its hardware or software issue ?
The sketch is below if that helps (server details removed for security).
Bobster
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#include <WiServer.h>
SFEMP3Shield MP3player;
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
unsigned char local_ip[] = {192,168,0,101}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,0,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"XXX"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"XXXXXXXXXXXX"}; // max 64 characters
////////////////////////////////////////////////////// no need to edit below ////////////////////////////////////////
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
// IP Address for www.XXX.com.au
uint8 ip[] = {111,111,111,111};
// A request that gets the latest data for site
GETrequest getSite(ip, 80, "www.X.com", "/output.php");
void setup() {
//start the shield
MP3player.begin();
// Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages)
WiServer.init(NULL);
}
void loop(){
// Check if it's time to get an update
if (millis() >= updateTime) {
getSite.submit();
// Get another update one hour from now
// Get another update every 30 seconds
updateTime += 1000 * 30;
}
// Run WiServer
WiServer.server_task();
delay(100);
//start playing track 3
MP3player.playTrack(3);
}