Pages: [1]   Go Down
Author Topic: ADC and pull-up resistors  (Read 1227 times)
0 Members and 1 Guest are viewing this topic.
Greece
Offline Offline
Newbie
*
Karma: 0
Posts: 4
student of the Department of Automation ATEI Thessaloniki
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo,

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
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Greece
Offline Offline
Newbie
*
Karma: 0
Posts: 4
student of the Department of Automation ATEI Thessaloniki
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.print("\t");
Serial.println(val, DEC); // send it to the computer (as ASCII digits)
delay(delayTime); // define sample rate in ms
}
 
thanks,
Mikele
Logged

Pages: [1]   Go Up
Jump to: