- #1
CognitiveNet
- 53
- 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;
}
//----------------------------------------------
}
}
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;
}
//----------------------------------------------
}
}