Pages: [1]   Go Down
Author Topic: Help trying to read in voltages on a mega 2560 without potentiometer  (Read 170 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 38
Posts: 1335
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: