// const byte LED = 13;
// const byte BUTTON = 2;
// Interrupt Service Routine (ISR)
// void switchPressed()
// {
// if (digitalRead(BUTTON) == HIGH)
// digitalWrite(LED, HIGH);
// else
// digitalWrite(LED, LOW);
// }
// void setup()
// {
// pinMode(LED, OUTPUT); // so we can update the LED
// digitalWrite(BUTTON, HIGH); // internal pull-up resistor **** Focus On This ****
// attachInterrupt(digitalPinToInterrupt(BUTTON), switchPressed, CHANGE); // attach interrupt handler
// }
// void loop()
// {
// // loop doing nothing
// }
long OldTimeOfGreenLED = 0;
long TimeToBlinkGreenLED = 300;
volatile bool StatusOfRedLED = false;
bool StatusOfGreenLED = false;
void setup()
{
// Testing How To Make A Pin Mode Of A Pin With INPUT_PULLUP By Using pinMode(pin, mode)
// And Without Using It
// pinMode(2, INPUT_PULLUP);
// digitalWrite(2, HIGH);
// Testing How To Disable All INPUT_PULLUP Pins By PUD Bit In MCUCR
// MCUCR |= 1 << 4;
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
PORTD |= 1 << 2;
EIMSK |= 1;
SREG |= 1 << 7;
// attachInterrupt(digitalPinToInterrupt(2), ReverseLEDStatus, RISING);
// Not recommended to use this syntax (Typing the interrupt number directly without using digitalPinToInterrupt() function )
// because it May will raise another interrupt in different board
// attachInterrupt(2, ReverseLEDStatus, RISING);
}
// void ReverseLEDStatus()
// {
// StatusOfRedLED = !StatusOfRedLED;
// digitalWrite(3, StatusOfRedLED);
// }
void loop()
{
// Pin Number 4
if (millis() - OldTimeOfGreenLED > TimeToBlinkGreenLED)
{
digitalWrite(4, StatusOfGreenLED);
StatusOfGreenLED = !StatusOfGreenLED;
OldTimeOfGreenLED = millis();
}
}
// Debouncing Not Completed Yet
ISR(INT0_vect)
{
StatusOfRedLED = !StatusOfRedLED;
digitalWrite(3, StatusOfRedLED);
}