Digipixel Piezo
Moderators: Chuckt, Garth, bitfogav
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Digipixel Piezo
I was just wondering how to use the Piezo buzzer on the DigiPixel. It goes here right? I soldered the negative lead to the square hole and positive to the circle.
How would I figure out which pins to send the sound to? I'm a complete newbie to the DigiPixel as well as Arduino but I've made games in other computer languages and I was able to create something simple for the DigiPixel. I've barely worked with micro-controllers and don't know how to add sound to my game.
EDIT: Just in case anyone was wondering I soldered the Piezo on wrong. Don't do it the way I did.
How would I figure out which pins to send the sound to? I'm a complete newbie to the DigiPixel as well as Arduino but I've made games in other computer languages and I was able to create something simple for the DigiPixel. I've barely worked with micro-controllers and don't know how to add sound to my game.
EDIT: Just in case anyone was wondering I soldered the Piezo on wrong. Don't do it the way I did.
Last edited by ZephaniahNoah on Fri Jan 02, 2015 6:02 pm, edited 3 times in total.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
The piezo speaker connection was a bit of a late requested addition and as such I didn't write any code for it myself however the main thing you need to know is that it is connected to the Arduino pin 9.
So if you have a look on google for 'arduino sound' or something to that effect, you should get some pretty good tutorials.
Here is one such example:
http://arduino.cc/en/pmwiki.php?n=Reference/tone
Just remember that your piezo speaker is connected to pin 9
So if you have a look on google for 'arduino sound' or something to that effect, you should get some pretty good tutorials.
Here is one such example:
http://arduino.cc/en/pmwiki.php?n=Reference/tone
Just remember that your piezo speaker is connected to pin 9
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
Awesome! Thanks, I'll have a look.brad wrote:The piezo speaker connection was a bit of a late requested addition and as such I didn't write any code for it myself however the main thing you need to know is that it is connected to the Arduino pin 9.
So if you have a look on google for 'arduino sound' or something to that effect, you should get some pretty good tutorials.
Here is one such example:
http://arduino.cc/en/pmwiki.php?n=Reference/tone
Just remember that your piezo speaker is connected to pin 9
Re: Digipixel Piezo
I was going to say isn't that the wrong way around for the piezo connections? but I see you have now updated your post
How did you get on with this ZephaniahNoah? I was hoping to try out this too
How did you get on with this ZephaniahNoah? I was hoping to try out this too
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
It went well. Any time I wanted my game to play a sound I just added:bitfogav wrote:I was going to say isn't that the wrong way around for the piezo connections? but I see you have now updated your post
How did you get on with this ZephaniahNoah? I was hoping to try out this too
tone(9, frequency, duration);
However, if I wanted to play a little jingle when the player died I would have to put a delay(X); and set X to the previous tone's duration. For instance, if I were to just do... :
Code: Select all
tone(9, 100, 100);
tone(9, 200, 100);
tone(9, 300, 100);
Code: Select all
tone(9, 100, 100);
delay(100);
tone(9, 200, 100);
delay(100);
tone(9, 300, 100);
The link brad provided was very useful and I was able to look up pretty much everything else on the web but other than that it was quite simple.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
What you could do is look into using interrupts. You can set the interrupt for a certain amount of time (like your delays) but your code still runs and then when that certain amount of time has ticked over, the interrupt will trigger your audio code.
- ZephaniahNoah
- semi-newbie
- Posts: 24
- Joined: Wed Dec 31, 2014 7:17 am
- Location: Milky Way, Earth [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
Ok, I'll look into that.brad wrote:What you could do is look into using interrupts. You can set the interrupt for a certain amount of time (like your delays) but your code still runs and then when that certain amount of time has ticked over, the interrupt will trigger your audio code.
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Digipixel Piezo
Infant the tone function uses interrupts itself in the form of timer2
Who is online
Users browsing this forum: No registered users and 9 guests