Coding Guru Needed!

Hey I’m pretty new to the coding game. Just looking to get lights blinking with a piezo buzzer playing music at the same time. All I can get is just music, then just blinking, and so on…

Here’s the code:

int data = 2;
int clock = 3;
int latch = 4;
int speakerPin = 9;
int length = 15;
char notes = "ccggaagffeeddc ";
int beats = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;

void playTone(int tone, int duration) {
for (long a = 0; a < duration * 1000L; a += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}

void playNote(char note, int duration) {
char names = { ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘a’, ‘b’, ‘C’ };
int tones = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

for (int a = 0; a < 8; a++) {
if (names[a] == note) {
playTone(tones[a], duration);
}
}
}

int ledState = 0;
const int ON = HIGH;
const int OFF = LOW;

void setup()
{
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(speakerPin, OUTPUT);
}

void loop()
{
for (int a = 0; a < length; a++) {
if (notes[a] == ’ ') {
delay(beats[a] * tempo);
} else {
playNote(notes[a], beats[a] * tempo);
}

delay(tempo / 2);
}

int delayTime = 100;
for(int i = 0; i < 256; i++){
updateLEDs(i);
delay(delayTime);
}
}

void updateLEDs(int value){
digitalWrite(latch, LOW);
shiftOut(data, clock, MSBFIRST, value);
digitalWrite(latch, HIGH);

void updateLEDsLong(int value){
digitalWrite(latch, LOW);
for(int i = 0; i < 8; i++){
int bit = value & B10000000;

value = value << 1;
if(bit == 128){digitalWrite(data, HIGH);}
else{digitalWrite(data, LOW);}
digitalWrite(clock, HIGH);
delay(1);
digitalWrite(clock, LOW);
}
digitalWrite(latch, HIGH);
}

int bits = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000};
int masks = {B11111110, B11111101, B11111011, B11110111, B11101111, B11011111, B10111111, B01111111};

void changeLED(int led, int state){
ledState = ledState & masks[led];
if(state == ON){ledState = ledState | bits[led];}
updateLEDs(ledState);

I see the problem right off, no comments used.

Lefty

deleted comments because I thought it would be clearer for someone who knew about coding. Should I post with comments?

All I can get is just music, then just blinking, and so on....

You need to get rid of some delays then. Have a look at the blink without delay tutorial.

Please use the # (code) icon on the editor's toolbar when posting code.