I made a board with an ATmega8A (SMD-TQFP package). I installed the minicore library in the Arduino IDE. Now I'm able to flash the hex file using Atmel Studio 7 and able to read serial well.
But my problem is reading the digital pin status. It doesn't work well. I searched the internet and in the minicore library, I found that in the ATmega8, pin 14 (PORT B.2
) is digital pin 10. So I wrote my code, however the pin does not change its status when toggling it.
Is it a mapping problem? If so, how can I map it?
#include <TimerOne.h>
int setbit = 0;//timer 2 isr
int setbit1 = 0;
int flag=0;
int flag1=0,k=0;
int flag2=0; int Light_CMD_J6=9;
int Button_Status_J6=10;
void setup() {
Timer1.initialize(100000); // set a timer of length
Timer1.attachInterrupt( timerIsr ); //
Serial.begin(19200);
pinMode(Light_CMD_J6,OUTPUT);
pinMode(Button_Status_J6,INPUT);
}
void timerIsr()
{
setbit1=setbit1+1;
if(setbit1==10)//2 seconds
{
setbit1=0;
flag2=1;
}
}
void loop() {
if(flag2==1)
{
Button_Status_J6=digitalRead(Button_Status_J6);
Serial.print("BUTTON 6 STATE IS = ");
Serial.println(Button_Status_J6);
flag2=0;
}
}