Trossen Dynamixel High Thread Banner
Results 1 to 5 of 5

Thread: I'm having trouble getting an arduino analog input to work

  1. I'm having trouble getting an arduino analog input to work

    Here's the setup. I have a resistor ladder that creates the same effect as a pot, just with 11 specific voltages. I'm feeding this signal into an op amp wired for negative feedback. The resistor ladder, the arduino, and the opamp are all powered from the same source (12 volt battery). with it all set up and wired and ready to go, I put my multimeter straight on the AI pin, already hooked up to the opamp output, I read a max of 4 volts, and it drops to 0 depending on theresistor in the ladder that is activated.

    In short, it all appears to be working exactly like it should.

    So to debug, I initialize the serial port, hook it up to my computer, and command a serial print of the read value of the analog port. Again, at "idle" the pin reads FOUR VOLTS, and when I pull up hyperterminal, I read straight 0's. Doesnt respond at all to the inputs.

    I'm not even sure what to think. I'm left with no clues why the read comes back all zero, not sure where to start troubleshooting. Anyone have suggestions where to start?

  2. #2
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,347
    Rep Power
    158

    Re: I'm having trouble getting an arduino analog input to work

    Welcome to the forum!

    Sounds like you have your hardware in line. Posting your code would be the next step!
    I Void Warranties´┐Ż

  3. Re: I'm having trouble getting an arduino analog input to work

    int SWI1 = 1
    int SWI2 = 2

    void setup()
    {Serial.begin(9600);}

    void loop()
    {Serial.println(analogRead(SWI1));}

    -------------

    Seems like it should work.... (swi2 doesnt work either)

    So I have to admit there is other code in there too, but I didn't include it. Can other code muck up what is here? Like using DIO pin 2? I'm not currently using DIO 0 and 1 (thought might be in the future)

    Oh, and thank you for the welcome
    Last edited by Whiterabbit; 09-01-2009 at 12:55 AM.

  4. Trossen Desktop RoboTurret Thread Banner
  5. #4
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,347
    Rep Power
    158

    Re: I'm having trouble getting an arduino analog input to work

    Try this:

    Code:
    int analogInput = 0;    // Just a place to hold the input value
    
    void setup() 
    {
      // open the serial port at 9600 baud
      Serial.begin(9600);
    }
    
    void loop() 
    {
      // read the analog input on pin 0 (are you SURE you're using analog input 1 and not analog input 0?)
      analogInput = analogRead(0);
    
      // print it out to the serial port as an ASCII-encoded Decimal value
      Serial.println(analogInput);
    
      // give it some time to get there
      delay(10);
    }
    If that works, than you should probably set out to debug the code that you didn't bother to post...
    I Void Warranties´┐Ż

  6. Re: I'm having trouble getting an arduino analog input to work

    I'll give it a shot. I'm sure I'm using 1 and 2 and not 0 because I'm using 0 for something else. And the code works for AI 0 which just has a simple pot attached.

    However, when I was testing THAT, I was doing what I think you did above. read the input and write it to a global variable before printing it.

    Is there a reason to write the analogRead command to a variable then Serial.Print the variable? Rather than serial.printing the analogRead command itself?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Turning analog inputs into multi-switch digital inputs?
    By Clavis in forum Arbotix, Microcontrollers, Arduino
    Replies: 34
    Last Post: 01-09-2011, 11:42 PM
  2. Contest Entry Bioloid Gripper
    By JonHylands in forum Project Showcase
    Replies: 12
    Last Post: 12-26-2008, 03:28 PM
  3. Analog input light sensor question
    By jcl43 in forum Sensors
    Replies: 1
    Last Post: 03-27-2008, 02:04 PM
  4. Kondo web page translated.
    By Droid Works in forum Humanoids, Walkers & Crawlers
    Replies: 4
    Last Post: 10-06-2007, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •