I am a complete newbie, I know next to nothing about programming, so try to facepalm too hard.
I bought the Arduino Starter Pack, with the 15 Project book, and have been trying to edit the code on Project 07, the Keyboard Theremin Project, and was wondering if I could edit the program to play a series of notes, like a guitar riff.
This is the direct program, I edited the note values using a table of values of the Twelth Roots of 2, Hz, but I can't figure out how to tell it to play a series of notes and pitches with "pitch" and "delay"
// int buttons[6];
// int buttons[0] = 2;
int notes[] = {493.88,232.82,219.75,293.67};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
I am a complete newbie, I know next to nothing about programming, so try to facepalm too hard.
I bought the Arduino Starter Pack, with the 15 Project book, and have been trying to edit the code on Project 07, the Keyboard Theremin Project, and was wondering if I could edit the program to play a series of notes, like a guitar riff.
This is the direct program, I edited the note values using a table of values of the Twelth Roots of 2, Hz, but I can't figure out how to tell it to play a series of notes and pitches with "pitch" and "delay"
// int buttons[6];
// int buttons[0] = 2;
int notes[] = {493.88,232.82,219.75,293.67};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int keyVal = analogRead(A0);
Serial.println(keyVal);
if(keyVal == 1023){
tone(8, notes[0]);
}
else if(keyVal >= 990 && keyVal <= 1010){
tone(8, notes[1]);
}
else if(keyVal >= 505 && keyVal <= 515){
tone(8, notes[2]);
}
else if(keyVal >= 5 && keyVal <= 10){
tone(8, notes[3]);
}
else{
noTone(8);
}
}
It's possible, but probably not for a single output. In order to play multiple frequencies, you need to add the frequencies together to form a chord. If you can find a way to do that in code (quite possible but might be quite difficult - unless someone has already done it and is willing to share), or you can easily do it in hardware.
In hardware: Have multiple output pins. Each pin should output a different tone (pure sinusoidal signal) and feed each of those tones to an input of a summing opamp. Then feed the output to a power amplifier, and then feed the output of the amplifier to your speakers. link