LED and piezo

a very simple tutorial that blinks a led and makes a piezo beep
join led with a 220 ohm resistor to pin 13 and piezo with a resistor of your choice to pin 3

int piezoPin = 3;
int ledPin = 13;

void loop()
{
  digitalWrite(piezoPin, HIGH);
  digitalWrite(ledPin, HIGH);
  delay (1000)
  digitalWrite(piezoPin, LOW);
  digitalWrite(ledPin, LOW);
  delay (1000)
}

please let me know if this is better than the blink example

devcoder:
please let me know if this is better than the blink example

No. This would fail to compile. Undefined reference to setup in function main.

Missing pinMode calls for the pins.

See the "Blink Without Delay" example to see how to make it better. All you've done is add a buzzer to the basic blink sketch and remove the setup function so it doesn't work and doesn't compile.

There should really be some sort of vetting process for these posts or this thing is going to get filled up with stuff like this.

devcoder:
a very simple tutorial

Apart from its incompleteness as Delta_G points out, it's not a tutorial in the first place. A tutorial needs to, well, tutor*, that is provide some guidance to aid understanding, not just throw out a solution (even if the solution is technically correct which this isn't).

*tute?

devcoder:
and piezo with a resistor of your choice to pin 3

Is it ok if I choose this one?

link.jpg

link.jpg