

"acqNote" gets the acceleration in the 3 directions from the sensor, selects the highest and returns the associated frequency. tone (board.D5, 440, duration 1.0 ) You should hear a 440 hz tone, or an A4 note, played for one second.
#Arduino piezo tricks download
Try the following to play a 440 hz tone for 1 second: Download File. Int sensorValue3 // value read from the Accelerometer's second pin Now you'e ready to use the tone function in SimpleIO to play a tone on a pin connected to a piezo buzzer. Int sensorValue2 // value read from the Accelerometer's second pin Int sensorValue1 // value read from the Accelerometer's first pin 380 is the real rhythm, but beginning with 600 is easier to learnįloat freq_rediese = freq_rediese0*pow(2, octave) //frequency of a sharp Re in Hz, for the retained octaveįloat freq_mi = freq_mi0*pow(2, octave) //frequency of a Mi in Hz, for the retained octaveįloat freq_soldiese = freq_soldiese0*pow(2, octave) //frequency of a sharp Sol in Hz, for the retained octave Be careful, below 2(low) and above 6 (acute), it gets very uglyĬonst int temps=380 //number of milliseconds for 1 musical note. #define AUTO 0 // Automatic mode : if 1, the music is played automatically.Ĭonst int analogInPinX = 0 // Analog input pin that the Accelerometer's first pin is attached toĬonst int analogInPinY = 1 // Analog input pin that the Accelerometer's second pin is attached toĬonst int analogInPinZ = 2 // Analog input pin that the Accelerometer's third pin is attached toĬonst int tone1Pin = 9 // tone output signalĬonst int highPin1 = 11 //5 V alimentationĬonst int highPin2 = 12 //5 V alimentationĬonst int lowPin1 = 5 //ground for one of the 2 accelerometer gnd.Ĭonst int lowPin2 = 6 //ground for one of the 2 accelerometer gnd.Ĭonst int ledOKPinGnd = 8 //ground for OK PinĬonst int ledOKPinH = 10 // 5 V alimentation for OK PinĬonst int ledNOKPinGnd = 2 //ground for NOK PinĬonst int ledNOKPinH = 4 // 5 V alimentation for NOK PinĬonst float freq_rediese0 = 38.9 //frequency of a sharp Re in Hz, for octave 0Ĭonst float freq_mi0 = 41.2 //frequency of a Mi in Hz, for octave 0Ĭonst float freq_soldiese0 = 51.9 //frequency of a sharp Sol in Hz, for octave 0Ĭonst int octave=4 //octave number. The music is "where is my mind" from The Pixies, which is really easy to play. Currently I am collecting funds against Cancer, please donate!Īttempt to play a cool music with a crap speaker, hoping that the "cool" will compensate the "crap".
#Arduino piezo tricks code
The code is basic : the song rhythm is implemented and before each time step, the glove senses the gravity direction and chooses one of the three notes of the song.

1 song able to challenge the crap sound of the speaker If you however downloaded the official version and this trick did give you.

The aim of this project is to generate music through motion thanks to accelerometers. Getting started with Arduino and a WS2811 or WS2812 LED strand using NEOPixel.
