Go Down

Topic: ADC and pull-up resistors (Read 3114 times) previous topic - next topic



I have a Arduino BT and want to make analog data aquisition. I have read in arduino site  If  I want to make ADC, I will have to enable pull-up resistors first with this commands :
pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);
Here is my question: How can I set my analog pins as inputs [besides the pinMode(adcPin, INPUT) command]. I would like to know if necessary the [digitalWrite(A0, HIGH);  // set pullup on analog pin 0] commad.

Thanks Mikele


To enable the internal pull-up resistors the commands would be:

Code: [Select]

pinMode(A0, INPUT);  //not OUTPUT
digitalWrite(A0, HIGH);

In your code, you made A0 an output and then set it to HIGH.  Instead you write a HIGH to an INPUT pin, to turn on the internal pull-up.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


First of all thanks for your answers.
[ch921] work with an ECG and I wish to convert its analog signal to digital. ECG's output gives me 2VDC and I wonder if this voltage level is high enough in order to be read by the Arduino [ch914][ch932] that I own. I have write this ADC code with time stamps:

int adcPin= 0;
int val= 0; // variable to store the value coming from the sensor
unsigned long time_1, time_2, delayTime, dt;
void setup()
pinMode(adcPin, INPUT); // declare the adcPinas an OUTPUT
Serial.begin(115200); // initialize serial communication with computer
time_1 = millis(); // read the initial time stamp
delayTime= 10; // delay time in ms
void loop()
time_2 = millis(); // read the current time stamp
dt= (time_2 -time_1); // compute delta time in seconds
val= analogRead(adcPin); // read the value from the sensor
Serial.print(dt, DEC);
Serial.println(val, DEC); // send it to the computer (as ASCII digits)
delay(delayTime); // define sample rate in ms


Go Up