How to make a speaker play sound when people walk through the ultrasonic sensor

Hye, i do not know details about arduino…coz i’m new in this robotic component…so, i’m here to need some help…i hope that someone can help me in programming this arduino. I want to make the speaker will play like “welcome” when people walk through ultrasonic sensor and the LCD will display “Please scan your barcode”…
I dont know to write the code…so, i hope someone can help me… :~

This looks like an interesting starting point.

What Ultrasonic Sensor are you using?(eg.model) You can find the codes on google and edit them to fit your project.

Hi, Welcome...

Have you worked through the examples in the IDE (File > Examples) or here; if not you should start there.

There's some stuff on audio in the Playground here- it might help to look at that. Also on using an ultrasonic sensor although the specifics may depend on the actual hardware you choose. LCDs are covered here; I use one of these which has sample code.

Probably easiest if you get each of those parts- audio / ultrasonic / lcd- under your belt individually first (my opinion anyway, ymmv) and then bolt them together. This thread will help with that, and
this one will help you plan a relatively complex sketch from scratch.

hello, i am sorry coz i'm late to see your comment... i feel that nobody will ignore me coz i'm noob in this...
haha..thanks to everyone coz..
now i want to ask about that speaker...i want to make it
i think that capacitor will make it louder right?
if capacitor will make it louder...if yes, how about that circuit??
can anyone help me....please... :slight_smile:

#include <PCM.h>

const unsigned char sample PROGMEM = {
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,

void setup()
int speakerPin = 8;
startPlayback(sample, sizeof(sample));

void loop()

why it does not work??
can someone help me?