Hey people, when I try to compile this code I get this error "undefined reference to analogRead". Is there a library or something I'm supposed to include?
/* Blinker Demo */
/* Include useful pre-defined functions*/
#include <avr/interrupt.h> // Defines pins, ports, etc to make programs easier to read
#define F_CPU 100000UL // Sets up the default speed for delay.h
#include <util/delay.h>
int IR_pin = 5;
int val = 0; //a variable to store IR value
int IR_thresh = 100;
int main()
{
for ( ;; )
{
val = analogRead(IR_pin);
if (val < IR_thresh)
{
DDRD = _BV(PD7); // enable output on port D, pin 7
PORTD = _BV(PD7);
_delay_ms(1000);
PORTD &= ~_BV(PD7);
_delay_ms(1000);
}
}
return(0);
}