Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

AnalogReference (EXTERNAL) undeclared?

  1. Oct 6, 2012 #1
    Hi! I'm trying to read the voltage( from ARef I assume) by using analogRead.
    I've set analogReference to EXTERNAL, and I'm doing this in main.
    Yet, I'm told that EXERNAL is undeclared. What am I doing wrong?

    #include<avr/io.h>
    #include<teensy_pins.h>
    #include<timer0.h>
    #include<util/delay.h>
    #define CPU_PRESCALE(n)(CLKPR=0x80,CLKPR=(n))
    #define CPU_16MHz 0x00

    int main(void)
    {
    CPU_PRESCALE(CPU_16MHz);

    // Initialize DDR
    DDRC = 0x0e; // Output (Lamp Status) (Sets output to 3 pins)
    DDRD = 0x00; // Input (Switch Status)

    // Initialize PORT
    PORTD = 0xff;
    --------------------------------------------------------------------------
    int analogInput = 0;
    int analogAmount = ;

    void setup()
    {
    analogReference(EXTERNAL); // use AREF for reference voltage
    }


    while(1)
    {

    analogAmount = analogRead(analogInput);

    //--------------------- D4 ---------------------
    if (!(PIND & 0x10))
    {
    PORTC = 0x0e;
    _delay_ms(250);
    PORTC = 0x00;
    _delay_ms(250);
    }
    //--------------------- D5 ---------------------
    if (!(PIND & 0x20))
    {
    PORTC = 0x0e;
    }
    else
    {
    PORTC = 0x00;
    }
    //----------------------------------------------
    }
    }
     
  2. jcsd
  3. Oct 8, 2012 #2

    Mark44

    Staff: Mentor

    I wrapped your code in [ code ] [ /code ] tags (without the spaces) so that your indentation is preserved. When you post code, you should do that, too.
    Is EXTERNAL a macro with a value, or are you trying to tell the compiler that analogReference is a function that is defined in an external file.

    It's possible that you are missing the include file that defines EXTERNAL.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: AnalogReference (EXTERNAL) undeclared?
  1. NULL undeclared (Replies: 1)

Loading...