hi all!
im hitting wall here.
i not sure put post, in audio section ore here. sorry if missed forum section.
anyways, im trying achive store audio sample (wav), convertetd char array variable , store on external eeprom 24lc1024. after that, retrive variable , play on small speaker.
im using pcm.h library playing, or better pwm numbers pin 11 on arduino speaker connected to.
i have 2 sketches. 1 writing eeprom, , other fore retriving , playback.
writing eeprom successfull, however, comping read eeprom sketch gives me error
does have clue doing wrong
i know has <pcm> library, accepts pointer variable.
any suggestions other method?
thx!
here code
---------- write.ino
---------- read.ino
im hitting wall here.
i not sure put post, in audio section ore here. sorry if missed forum section.
anyways, im trying achive store audio sample (wav), convertetd char array variable , store on external eeprom 24lc1024. after that, retrive variable , play on small speaker.
im using pcm.h library playing, or better pwm numbers pin 11 on arduino speaker connected to.
i have 2 sketches. 1 writing eeprom, , other fore retriving , playback.
writing eeprom successfull, however, comping read eeprom sketch gives me error
code: [select]
invalid conversion 'byte {aka unsigned char}' 'unsigned char*' [-fpermissive]
does have clue doing wrong
i know has <pcm> library, accepts pointer variable.
any suggestions other method?
thx!
here code
---------- write.ino
code: [select]
#include <wire.h> //i2c library
// warning: address page address, 6-bit end wrap around
// also, data can maximum of 30 bytes, because wire library has buffer of 32 bytes
void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, unsigned char* data, byte length ) {
wire.begintransmission(deviceaddress);
wire.write((int)(eeaddresspage >> 8)); // msb
wire.write((int)(eeaddresspage & 0xff)); // lsb
byte c;
for ( c = 0; c < length; c++)
wire.write(data[c]);
wire.endtransmission();
}
void setup()
{
unsigned char somedata[] = {
126, 127, 128, 128, 128, 128, 128, 127, 128, 128, 128, 129, 129, 128, 127, 128, 128, 127, 126, 127, 128, 129, 128, 127, 126, 127, 128, 128, 126, 126, 127, 127, 127, 127, 127, 127, 126, 127, 129, 130, 129, 128, 126, 126, 126, 126, 127, 129, 130, 129, 127, 127, 127, 127, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 128, 130, 131, 129, 127, 126, 126, 126, 127, 127, 128, 128, 128, 128, 127, 128, 128, 127, 127, 128, 128, 130, 130, 129, 126, 125, 127, 129, 130, 129, 128, 126, 125, 126, 129, 131, 131, 127, 123, 125, 129, 131, 130, 128, 129, 130, 130, 129, 127, 127, 128, 130, 129, 128, 126, 125, 126, 129, 131, 130, 128, 128, 128, 126, 125, 126, 128, 129, 128, 125, 125, 127, 129, 129, 129, 129, 127, 124, 123, 125, 128, 128, 126, 125, 125, 127, 129, 127, 126, 127, 128, 129, 129, 127, 124, 121, 123, 127, 130, 130, 128, 124, 122, 123, 127, 130, 131, 129, 125, 122, 122, 126, 128, 128, 128, 125, 123, 121, 118, 114, 111, 112, 113, 112, 109, 106, 107, 112, 117, 115, 111, 108, 109, 111, 112, 115, 116, 115, 112, 109, 107, 110, 114, 116, 115, 116, 117, 118, 118, 118, 117, 116, 115, 113, 110, 109, 111, 111, 111, 111, 114, 116, 115, 112, 110, 111, 113, 113, 110, 108, 110, 115, 117, 116, 114, 114, 114, 114, 113, 112, 113, 116, 116, 116, 116, 118, 119, 120, 121, 123, 124, 123, 119, 114, 112, 115, 118, 120, 122, 123, 123, 119, 116, 118, 124, 131, 130, 122, 116, 117, 123, 128, 132, 133, 131, 126, 121, 117, 117, 120, 124, 125, 123, 120, 118, 120, 125, 129, 128, 124, 120, 116, 115, 118, 123, 126, 125, 121, 117, 116, 118, 121, 122, 121, 120, 119, 121, 125, 126, 123, 119, 120, 126, 129, 125, 119, 116, 116, 118, 120, 124, 128, 127, 122, 119, 122, 128, 128, 123, 119, 120, 120, 119, 119, 124,
}; // data write
wire.begin(); // initialise connection
serial.begin(9600);
i2c_eeprom_write_page(0x50, 0, (byte *)somedata, sizeof(somedata)); // write eeprom
delay(10); //add small delay
serial.println("memory written");
}
void loop(){}
---------- read.ino
code: [select]
/*
* use i2c bus eeprom 24lc64
* sketch: eeprom.pde
*
* author: hkhijhe
* date: 01/10/2010
*
*
*/
#include <wire.h> //i2c library
#include <pcm.h>
byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
unsigned char rdata = 0xff;
wire.begintransmission(deviceaddress);
wire.write((int)(eeaddress >> 8)); // msb
wire.write((int)(eeaddress & 0xff)); // lsb
wire.endtransmission();
wire.requestfrom(deviceaddress,1);
if (wire.available()) rdata = wire.read();
return rdata;
}
void setup() {}
void loop()
{
int addr=0; //first address
byte b = i2c_eeprom_read_byte(0x50, 0); // access first address memory
while (b!=0)
{
startplayback(b)); //playing sound sample
// serial.print((byte)b); //print content serial port
addr++; //increase address
b = i2c_eeprom_read_byte(0x50, addr); //access address memory
}
//delay(2000);
}
somewhere use byte, function needs pointer.
turn on line numbers, , have better @ error message. compiler tells @ line number problem is.
turn on line numbers, , have better @ error message. compiler tells @ line number problem is.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > I2C EEPROM and audio playback
arduino
Comments
Post a Comment