Initialising Analog Pins

I am currently building an synthesizer where the pitch of the note is controlled by the resistance between two people. I implemented the ohmmeter code into my Daisy Code but the Seed doesn’t really react to any changes in resistance. The code works fine on the Arduino Uno though…

All in all, I can’t get the analogRead() to work, tried it with the AnalogInOutSerial example, with no success…


int analogPin = A3;
int raw = 0;
int Vin = 3.3;
float Vout = 0;
float R1 = 15100;
float R2 = 0;
float buffer = 0;
int x;

void setup(){
Serial.begin(9600);
delay(100);
}

void loop(){
   raw = analogRead(analogPin);
 // if(raw){
    buffer = raw * Vin;
    Vout = (buffer)/1024.0;
    buffer = (Vin/Vout) - 1;
    R2= R1 * buffer;
    x = R2 / 1000;
    
    
   
  //}
   Serial.print("Vout: ");
    Serial.print(Vout);
    Serial.print("       R2: ");
    Serial.print(R2);
     Serial.println("     pitch: ");
    //Serial.println(pitch); 
    delay(1000);
}

I would be happy to have a closer look at this with you!

You can reference the oscillator.ino example code in the DaisyDuino library (https://github.com/electro-smith/DaisyDuino/blob/master/examples/Seed/oscillator/oscillator.ino) to see how sensors are used with DaisyDuino.

And you can also flash the AnalogReadSerial.ino example code (Examples01.BasicsAnalogReadSerial) to make sure that the sensor value is being read by the Daisy as you expect.
USB support (if available) needs to be set to "CDC (generic Serial supersede U(S)ART)" and the Port should say something like /dev/cu.usbmodem3955337333301

If what’s being displayed in the serial monitor doesn’t look right, please make sure that your sensor is hooked up to the Daisy correctly.
One important step is to connect the DGND and AGND together in order for ADC to work appropriately.

Okay, so the AnalogReadSerial.ino puts out the same problem - the analogRead just puts out 767 (and ever so often 1023 once if potentiometer is all the way to one side and same with 0 on the other side…)
The settings for the upload to Daisy are as they should be.
DGND and AGND are connected.

I tried it out with the Arduino, it worked fine. On the Daisy…nothing but a headache for me haha

What does ‘resistance between two people’ mean?

So basically, it’s an ohmmeter, as described here: https://www.circuitbasics.com/arduino-ohm-meter/
But instead of an unknown resistor, it’s one or more human. Therefore, if noone is interacting/touching, the V (out) should be 0.

Yes, I figured you got that code from that article.
Frankly, pretty ridiculous to present that as an ohmmeter, as it only works when you’ve got a good idea of the unknown value. Clickbait.

Are you intending for a person to touch it with two hands? A resistor has two ends.

Firstly, well yeah I’ve got the base of the code from the article and the sound is from the oscillator.ino reverb.ino etc. etc. examples. No rocket science. I am not a software dev-
I am not advertising it as ohmmeter, but describing its function as one.

It has two points of contact for one or more people. As mentioned before.

My point (I am a software engineer, retired), is that the analogRead() code definitely works on Daisy.
If testing it with a pot doesn’t work for you, then you’re wiring it wrong, or using the wrong pin or PIN number , have a defective pot, or have a defective Daisy.
Whether you’ll read human resistances exactly the same as on an Arduino is another matter. Might need a different value for the known resistor.

As tele_player mentioned, I recommend testing things out with a 10k potentiometer if you have access to one right now. That’ll remove some variables and help us troubleshoot better.

And if it’s not a messy circuit, please feel free to share a photo to show how things are connected.

Hey, just so you know - as usual the problem has been 30 cm infront of the display. I am still not sure what exactly has been the problem (if hard- or software related, but probably a mix of both). I started back at 0 with a new circuit and new sketch and it works now.
Thanks tho!
(fyi currently using it with a 220 ohm resistor and planning to make adaptable for different circumstances)

1 Like

Restarting can certainly help! Glad to hear it’s working now :slight_smile:

1 Like