Hi all
I'm having Problems to convert the following code from an Arduino Uno (ATmega168/328) into a running Version on the Arduino Mega 2560 (ATmega2560). Problem is that Timer1 is not wird to Pin5 at Arduino Mega 2560.
#define SET(x,y) (x |=(1<<y)) //-Bit set/clear macros
#define CLR(x,y) (x &= (~(1<<y))) // |
#define CHK(x,y) (x & (1<<y)) // |
#define TOG(x,y) (x^=(1<<y)) //-+
unsigned long t0=0; //-Last time
int t=0; //-time between ints
unsigned char tflag=0; //-Measurement ready flag
float SENSITIVITY= 1000.0; //-Guess what
//-Generate interrupt every 1000 oscillations of the search coil
SIGNAL(TIMER1_COMPA_vect)
{
OCR1A+=1000;
t=micros()-t0;
t0+=t;
tflag=1;
}
void setup()
{
pinMode(13,OUTPUT); //-piezo pin
digitalWrite(12,HIGH); //-NULL SW. pull up
//-Set up counter1 to count at pin 5
TCCR1A=0;
TCCR1B=0x07;
SET(TIMSK1,OCF1A);
}
I found several Information that T5 (Pin47) can be used the same wise but I'm not able to get it run.
Does anyone of you know how to handel the code that T5 (Pin47) on Arduino Mega is controlled the same wise as T1 (Pin5) on Arduino Uno. Project ist the metal detector found here..