Hello and apologies to all for my inexperience.
I am completely new to arduino and programming in general.
I do have experience with electronics at a basic level (automotive mainly).
I was looking for a new hobby and programming and arduino seemed to be a very interesting past time.
So I have bought a mega 2560 and have been working through the beginners projects on the arduino main site.
Everything has been going well until I got to the project, simple keyboard, where you use force sensors to control the notes played. I did not have any force sensors so I used pots instead, only connecting one end of the resistance and the wiper of the pot to the circuit.
Having built the circuit and programmed it into the arduino (cut and pasted the code into the IDE) all I seem to get is one continuous horrible tone that is not effected in any way by movement of the pots.
The circuit im pretty sure is good, so it must be down to the code not understanding the pots. My problem is that I have no idea what that could be or what I should be looking at changing.
Im hoping to get some friendly advice here that can guide me to the solution.
One other problem I have been having is that when uploading code to the board I get a time out and communication error message.
anyone else had this?
avrdude: stk500_2_ReceiveMessage(): timeout
Are you taking into account any differences in the total resistance of your pot versus that of the force sensor? Glancing at sparkfun's force sensors, they tend to read very high resistance while on. It could be that if you have just dropped in replaced the force sensor with a pot, you are only varying your voltage by a few millivolts, and thus not hearing significant tone differences. I'm just guessing that the force sensor is connected to some pull up resistor and the arduino pin and then connected to ground on the other side, creating a variable voltage divider.
Disclaimer, I have not read the project you are working on. I'm just making wild assumptions and guessing.
Sparkfun has the force sensors: (There are cheaper ones as well)
I have added resistors on each pot as is required by the original. I cant say if there is any variation in resistance between the pots and force sensors. And any reference to resistance I cant see in the code.
*
keyboard
Plays a pitch that changes based on a changing analog input
circuit:
3 force-sensing resistors from +5V to analog in 0 through 5
3 10K resistors from analog in 0 through 5 to ground
8-ohm speaker on digital pin 8
created 21 Jan 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include "pitches.h"
const int threshold = 10; // minimum reading of the sensors that generates a note
// notes to play, corresponding to the 3 sensors:
int notes[] = {
NOTE_A4, NOTE_B4, NOTE_C3 };
void setup() {
}
void loop() {
for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
// get a sensor reading:
int sensorReading = analogRead(thisSensor);
// if the sensor is pressed hard enough:
if (sensorReading > threshold) {
// play the note corresponding to this sensor:
tone(8, notes[thisSensor], 20);
}
}
}