can I connect a potentiometer or an accelerometer directly to a uC?

Discussion in 'Electronics Resources' started by spo, Mar 23, 2011.

  1. spo

    Thread Starter New Member

    Feb 15, 2011
    10
    0
    Hi all,

    I think that the title is pretty self explanatory. I just want to know if it is safe for me to connect a potentiometer and an accelerometer directly onto a uC. Specifically, I am using an arduino UNO. If it is not safe, can you please tell me an alterntaive way to read accelerometer data or potentiometer data from the arduino?

    Thanks!
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    A potentiometer should be fine. To answer you accelerometer question, I will need the part number so I can access the datasheet.

    hgmjr
     
  3. spo

    Thread Starter New Member

    Feb 15, 2011
    10
    0
    hgmjr, thanks for the really quick reply! Ill send you the links to both:

    http://www.robotshop.com/ca/parallax-futaba-continuous-rotation-servo.html - This is the servo that I have

    http://www.robotshop.com/ca/dimension-engineering-de-accm2g.html - and this is the accelerometer I have

    The thing is, I have actually tried out both the potentiometer and the accelerometer on my UNO, and they did not work. It wasnt after a while of trying them out that I realized that the pins not being able to handle it could have been the problem. There can also be something wrong with my code too, I was thinking.

    const int xaccel = 3;
    const int yaccel = 5;
    const int potent = 0;

    void setup() {
    Serial.begin(9600); // open the serial port at 9600 bps:
    }

    void loop() {
    while(millis() < 15000){
    Serial.print("x = ");
    Serial.print(analogRead(xaccel));
    Serial.print(" y = ");
    Serial.print(analogRead(yaccel));
    Serial.print(" potent = ");
    Serial.print(analogRead(potent));
    Serial.print("\n");}
    }

    Thanks again for the help man!
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    The servo and the accelerometer are both compatible with the arduino.

    You need to provide a schematic of how you have connected up your accelerometer and the servo to your arduino. That will assist us in interpreting your code.

    hgmjr
     
  5. spo

    Thread Starter New Member

    Feb 15, 2011
    10
    0
    woops, I dunno why I sent you the servo, I meant potentiometer. Anyhow, for the accelerometer, All I did was connect the vCCin of the accelerometer to the 5v pin of the UNO and the ground to the GND of the UNO. and then the x and y pins to analog pins.

    http://www.robotshop.com/ca/seeedstudio-electronic-brick-rotary-sensor-potentiometer-3.html - this is the potentiometer.

    What should I be expecting for the serial output? I have been getting numbers, but they are basically constant, and they do not relate at all to the position that I spin the potentiometer, or the position that I tilt the accelerometer.
     
  6. spo

    Thread Starter New Member

    Feb 15, 2011
    10
    0
    I found the answer. All it was was bad soldering on my arduino protoshield. figured it out by poking around with my multimeter. Turns out neither my potentiometer nor my accelerometer were even powered up. Thanks for all the help!
     
Loading...