Author Options:

Arduino to computer commands? Answered

I want to make arduino ultrasonic range meter and after it hits certain value to print command to my mackbook (to play a song) I think it could be possible with serial monitor, but i have no idea how to do this. Any help would be appreciated.



Best Answer 4 years ago

If I were doing it I'd have the arduino sending the command over serial, with a Python script watching the serial then playing the sound when it gets the right command. Quick and easy.

Watching the serial connection:

Playing a Wav file:

i was trying to do the same thing. I was make a portal turret with lasers, i wanted it to play various turret recording on different mode. I'm using



had some luck, but most of the time the output from the arduino is too fast and the gobetwino says its executing (open a wav file) but only some wav actually was opened.

Now i need implant some sort of filter so slow the command and loop the sound when i needed.

But for if you just want to have one command to pc and play a whole 3 minute song, i guess it'll be pretty straight forward

Tutorial :


check page 16.

Does the song need to play through the PCor would you rather it play from a standalone unit?

If you want it separate then get a Wave Shield for your Arduino. Store the sound or sounds you want on an SD card and your all set.

If you need the Mac to play the sound that will take a bit more work. Involving finding a compatible bit of software (not very likely for a mac) or programming your own (which may be difficult).

i have arduino with sensor. i want to play it from pc because i dont have any shields. and it doesnt necessarily need to be on mac, i have bootcamp. it could be played on standalone unit, but shields are rather expensive. could it be just an sd card module?

Weather it's on a PC or a mac you will need to create software to check the input from the arduino and execute your desired commands.

An SD card module doesn't offer any sound processing so you'd have no way to play an audio file back.

Don't know what you consider expensive but a wave shield kit is only $22 USD. Sure there is some soldering required but it's not really expensive. At least not for what it can do.


im in poland, it costs about 100 pln, its about 20 bucks, but its still expensive