Hi, I'm
Today I'll display you the next chapter of the manual:
06 LIGHT THEREMIN create a musical instrument you play by waving your hands
In this chapter we will try to reproduce a Theremin (an instrument that make sound based on the movements of a musician hand around the instrument, here for more info).
While the Arduino can't exactly replicate the sound, nor the operation behind this instrument, it is only possible to emulate them using the tone() function and a piezo sounder.
Furthermore, here the author explain an helpful method to calibrate your sensor, using a while loop in the setup() function.
Our beloved/hated wikipedia about the while loop say "The while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition". I can't explain better than this.
Syntax:
while (booleanCondition) {Into the booleanCondition in this case the author choose to put the millis() function.
//..
}
The millis() function return the number of millisecond from when the Arduino is on.
Syntax:
int millis()
For play sound on a piezo you need the tone() function. Let see this function:
Syntax:
void tone(pin,freqPlay,timePlay)
Where pin is the pin which you had connected to the piezo; freqPlay is the frequency for play obtained using the map() function, we talk about that in the previous chapter, to change the range of the sensor(0-1023) to the range of the piezo (50-4000); timePlay is the time in millisecond you want to play that frequency.
As ever I don't put the entire code, because you can find it easily into the IDE.
My modification this time is not mine, or rather, I followed the advise on the manual:
But the sound was really to low, and I don't really like this solution.
Built like this the operation of our Theremin is more like a real Theremin.
Unfortunately for the second photoresistor I do not put any function for modulate the voltage level like it was the volume. Because the tone() function, in her internal code, use the same condition of the analogWrite() I don't really know if these two work in the same pin.
Maybe it is possible, but I need to know how both functions work in their internal code and try to mix they together for changing both frequency and pwm.
For today it's over, next post next week.
Ygy Freezone.





























