Vortex Robot - Liberty Prime subroutine

#define MP3_VOLUME 0x10
#define TX 11
#define RX 4 // ?? was 2 in example I found, but that is unlikely
#include <SoftwareSerial.h>
#include <Wire.h>
#define I2C_LED_ADDRESS 0b1100000
#define I2C_WRITE 0x00

SoftwareSerial mySerial(RX, TX);// RX, TX
void setup() {
// put your setup code here, to run once:
Wire.begin(); // join i2c bus (address optional for master)
delay(10);
mp3Init();
mp3setVolume(10);//0~30
delay(10);
custom_eyes(1,1);
}

void loop() {
for(int i=0;i<15;i++) {
mp3setVolume(10);//0~30
custom_eyes(1,1);
mp3player(i);
delay(30000); //.5 minute
mp3stop();
delay(250);
mp3setVolume(10);//0~30
}
}
void mp3Init()
{
mySerial.begin (9600);
}
void mp3setVolume(byte vol)
{
uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x06, 0x00, 0x00, vol, 0xef};
mySerial.write(buffer, 8);
delay(20);
}
void mp3player(byte data)
{
uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x03, 0x00, 0x00, data, 0xef};
mySerial.write(buffer, 8);
delay(20);
}

void mp3stop()
{
uint8_t buffer[] = {0x7e, 0xff, 0x06, 0x16, 0x00, 0x00, 0x00, 0xef};
mySerial.write(buffer, 8);
}
void custom_eyes(uint8_t color, uint8_t eyeline[10]){
uint8_t index;
// right eye left eye
//1 2 3 4 5 - 25 24 23 22 21
//6 7 8 9 10 - 20 19 18 17 16
//11 12 13 14 15 - 15 14 13 12 11
//16 17 18 19 20 - 10 9 8 7 6
//21 22 23 24 25 - 5 4 3 2 1
Wire.beginTransmission(I2C_LED_ADDRESS << 1 | I2C_WRITE); // transmit to device #4
Wire.write(0x55); // color 55=custom eyes follow
Wire.write(0xAA); // ?? AA=color followed by 10 bytes, each defining one line
// other values cause eyes to light up in multiple colors, needs more work
Wire.write(color&0x1); //color 1-B,2-G,4-R of foreground
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.write(eyeline[40]);
Wire.endTransmission(); // stop transmitting
}

  1. Toggle switch left

  2. Add Liberty Prime mp3 (switch back to right side)

  3. Upload sketch to Arduino UNO

I apologize for the audio quality. RobotShop also doesn’t do well with video, so I will have to increase volume later and record again. Don’t forget to use headphones with this post.

The LED Matrix i2c isn’t finished, but it’s definitely ready in time to liberate Hong Kong. :joy:
:disappointed_relieved: soooon :thinking: