LDR values -> MIDI information.. Voltage/Resistor/Code problem?

Hello, this is our first post on the forum although we have browsed for a while..

We are currently producing a circuit that takes the values from LDRs on the circuit and maps them to different controls of a synthesiser (for example pitch, volume etc)

However in the initial stages we are having trouble with the readings from the LDR, we have set up 2 LDRs at the moment to test. On 1 of the LDRs, when the resistor is being covered the value increases, it is the opposite on the other.

Could anybody shed some light on this situation and how we could make both of the values coming from the LDRs read the same?

Thanks in advance :)

How did you hook them up ?

And show us your code.

Cheers for the reply

int vpin = 2;
const int analogInPin1 = A0;
// Analog input pin that the potentiometer is attached to
const int analogInPin2 = A1;

int sensorValue1 = 0; // value read from the pot
int outputValue1 = 0;
int sensorValue2 = 1;
int outputValue2 = 1; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(vpin, OUTPUT);
}

void loop() {
digitalWrite(vpin, HIGH);
// read the analog in value:
sensorValue1 = analogRead(analogInPin1);
sensorValue2 = analogRead(analogInPin2);

// print the results to the serial monitor:
Serial.print(“sensor1 = " );
Serial.print(sensorValue1);
Serial.print(”\t output = ");
Serial.println(outputValue1);

Serial.print(“sensor2 = " );
Serial.print(sensorValue2);
Serial.print(”\t output = ");
Serial.println(outputValue2);

// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}

IMAG0103.jpg

PS

I apologise about the bad quality of the photo, only have a rubbish phone camera at hand..

It looks like your wiring is wrong. Try the following:

+5V --> fixed resistor --> LDR --> ground.

The connection between the fixed resistor and the LDR goes to the analog pin.

-- Beat707: MIDI drum machine / sequencer / groove-box for Arduino