/*
  Bug test for https://github.com/wokwi/wokwi-features/issues/924
  https://wokwi.com/projects/416353531338279937 

Built upon:
  Uno with Scope https://github.com/Dlloydev/Wokwi-Chip-Scope
        and https://github.com/Dlloydev/Wokwi-Chip-PWM
        and https://github.com/drf5n/Wokwi-Chip-FrequencyCounter

  Wokwi Uno https://wokwi.com/projects/390819301187622913
  Wokwi Nano https://wokwi.com/projects/415005801198505985
  Wokwi Mega: https://wokwi.com/projects/390819455604080641
  Wokwi ESP32S3 https://wokwi.com/projects/404720144387009537

  See also https://wokwi.com/projects/359331973918199809

*/

/*

Test of continuous interrupt progress per 
https://forum.arduino.cc/t/physical-uno-and-wokwi-give-different-results-for-a-simple-test/1328159
and
https://github.com/wokwi/wokwi-features/issues/924

Expected behavior is that at 0% duty cycle on pin 2, the code should
advance 1 instruction per interrupt (as per the datasheet) and blink pin 13

Observed behavior is that Wokwi completely stalls with a continuously
triggered LEVEL interrupt.

Adjust the PWM Breakout duty cycle from 0-100% to see the behavior as
the interrupts are triggered or not.

*/

void Interrupt ()
{
  if (digitalRead(2) == LOW)
    digitalWrite(6, HIGH);
}

void setup ()
{
  pinMode(2, INPUT_PULLUP);	
  pinMode(6, OUTPUT);
  pinMode(13, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(2), Interrupt, LOW);
}

void loop ()
{
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}
ScopeBreakout
Loading chip...chip-pwm
Loading chip...chip-freq
Wokwi UnoScope https://wokwi.com/projects/390819301187622913
cnt/meas
en/!dis