Go Down

Topic: Help trying to read in voltages on a mega 2560 without potentiometer (Read 183 times) previous topic - next topic

guegue12

Hello everyone,

I'm new to microcontrollers and I need help reading in voltages and printing them in the serial monitor. I have done this using a potentiometer, but I was wondering if I could do the same with just voltages. this is the code that I used when I read the potentiometer values:

Code: [Select]
int potPin = 0;    // select the input pin
int val = 0;       // variable to store the value coming from the function generator
void setup()
{
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
}
void loop() {
  val = analogRead(potPin); // read the value from the function generator
  Serial.println(val);
  delay(1000); //Sampling rate for the signal
}


My ultime goal is to input emg signals in an analog pin of the arduino and send them wirelessly to a computer

michinyon

A potentiometer does not "read in"  voltages.    You might be able to create a variable voltage with one,  but not read it.

You need to use an analog pin for the input on your arduino.  Pin 0 is probably not the right one, (  unless the compiler is smart enough to know that you mean  pin A0.)

You need to make sure that the voltage you are connecting to the analog input,  does not exceed 5V.

A one second sampling interval is unlikely to give you very meaningful results of the output of your "function generator".

groundfungus

What sort of signal does the emg output (mV, pulse,...?  what is emg?  I will echo what michinyon said with the addition that the signal must not go negative with respect to ground.

Go Up