Happy Birthday

/* I made this code for me and my brothers birthday, our favorite colors are blue and green, so thats why the colors i used in this code are colored the way they are, the list of tones is supposed to be the happy birthday song but im not sure, i havent tested it yet,
I only listened to each individual tone, it should work, enjoy this for your birthday or someone elses, comment on what the song sounds like so i can fix it. Made by Mike44449. */

int button = 9;
int greenLed = 8; //you can change the colors if you want
int blueLed = 7;
int buzzer = 4;

void setup()
{
pinMode(button,INPUT);
pinMode(greenLed,OUTPUT);
pinMode(blueLed,OUTPUT);
pinMode(buzzer,OUTPUT);
}

void loop()
{
if(digitalRead(button) == HIGH)
{
tone(buzzer,340,1500); //supposed to be the birthday song
tone(buzzer,400,2000);
tone(buzzer,440,1000);
tone(buzzer,390,1000);
tone(buzzer,340,1500);
tone(buzzer,400,2000);
tone(buzzer,450,1000);
tone(buzzer,400,1000);
tone(buzzer,340,1500);
tone(buzzer,470,2000);
tone(buzzer,320,1000);
tone(buzzer,300,1000);
tone(buzzer,380,1300);
tone(buzzer,340,1000);
tone(buzzer,300,1100);
digitalWrite(greenLed = HIGH); // makes the two LEDs flash at intervels
delay(900);
digitalWrite(greenLed = LOW);
digitalWrite(blueLed = HIGH);
delay(900);
digitalWrite(blueLed = LOW);
digitalWrite(greenLed = HIGH);
delay(900);
digitalWrite(greenLed = LOW);
digitalWrite(blueLed = HIGH);
delay(900);
digitalWrite(blueLed = LOW);
}
else{
digitalWrite(blueLed = LOW);
digitalWrite(greenLed = LOW);
}
}

  • you posted that in the wrong group. Exhibition/Gallery is for projects that work.
  • your code doesn't even compile
  • you didn't post the code properly: How to post code properly

Pete

It can't possibly have compiled for you. There's no way you can avoid this error:

S:\arduino-1.0.6\hardware\teensy\cores\teensy/core_pins.h:826: error: too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'

And don't repost it. I'll have a mod move it.

Pete

It exactly means what it says, not enough arguments. You use digitalWrite(greenLed = HIGH), thats not the way to use it. See digitalWrite()

Ah, so now it doesn't play Happy Birthday? (trust me - it's not even close) Happy Birthday - Programming Questions - Arduino Forum
You still haven't bothered to read this: How to post code properly

Pete

Mike44449:
i see your solution as one that makes sense, but i need to turn both LEDs off, not one on and one off

Then you did not understand what he was saying.

You are using digitalWrite() incorrectly - you are putting an assignment statement (LED=LOW) where you should be putting two arguments.

digitalWrite(LED=LOW); is totally wrong syntax.

You need two arguments, separated by a comma, since they're arguments to a function.

The = sign indicates assignment, it does not separate arguments to a function. You do not even want to assign the value of LOW (0) to variable LED. You want to write the digital value LOW (0) to pin number LED (since LED is just an integer containing the pin number).

You want digitalWrite(LED,LOW); (ofc, change LED to the proper LED variable, and LOW to HIGH where appropriate)

You originally posted this in Exhibition/Gallery where one of the things I pointed out to you was that "your code doesn't even compile" to which you replied "it worked for me". Now here you are asking about the specific compiler error I pointed out to you but which you implicitly claimed didn't exist.
And you still haven't added code tags to your first message.
Pardon me for being a bit testy.

This smells like an assignment. When is it due?

Pete

it worked for me, but ill post it in the right category, thanks for letting me know
...
I don't know what the error message means, but can someone review my code and tell me whats wrong

The old "it worked for me but it doesn't work" trick, eh?

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

Please use code tags.

Read this before posting a programming question

Sheezz The bloke will never come back again . Really getting stuck into him . get out of the wrong bed

He posted code that doesn't compile, claiming it works. He cross-posted questions about why it doesn't work.

Now I am being attacked for commenting on this fact? What are you? A sock-puppet?

What is your interest in this?

Hi,
To quote the OP. Post #1

i havent tested it yet,

At no time did he say it works....
I'm only going on what I see in this thread.
Tom..... :slight_smile:

At no time did he say it works....

But he did.

I'm only going on what I see in this thread.

And that's the problem. When Nick merged the original thread from Exhibition/Gallery into this thread a few posts got lost.
When the thread started in Exhibition, there was the original post as shown in this thread followed by my message #1 shown here. BUT then Mike44449 replied:

it worked for me, but ill post it in the right category, thanks for letting me know

which should be message #2 here.
I then replied, still in Exhibition, that there was no way that it could compile etc.
At that point, OP started this thread in Programming by reposting the code without the comment at the top and with the title
"too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'".
After a few posts here, Nick merged the two threads (possibly after I reported the thread) and changed the title back to that of the original thread "Happy Birthday".
There are at least two other posts by the OP which are now missing. One in which he admitted that this was an assignment and he apologized for misleading me/us. He also said that he got a B on the assignment!
How can that post be deleted? It wasn't part of the merging process because the merge had already been done.

Pete

I have just realized that all of Mike44449's posts except the first have been deleted from this thread. It wasn't a merging problem at all.
How did he manage that?

Pete

There is a post in the recycle bin, I don't know who put it there:

Mike44449:
Sorry Nick, I'll watch it next time and try to take the other one down. el_supremo, yes it was an assignment, that's why I seemed arrogant and refused to acknowledge your ideas, I was in a real hurry and I apologize, I still got a B on it at least

So @b-james:

b-james:
Sheezz The bloke will never come back again . Really getting stuck into him . get out of the wrong bed

Perhaps you would like to rethink your criticism of the moderator(s) after we got an apology and admission he had done the wrong thing. And stay out of things that aren't your concern. No, I didn't get out of the "wrong bed" - we have to put up with sort of thing all day, every day.