Configuring Extenal Interrupts (Teensy LC)

Status
Not open for further replies.

SolwiseMD

Member
Flipping the state of Pin 0 with this script does not invert the LED. Any help appreciated:
Code:
#include <avr/io.h>
#include <avr/interrupt.h>

volatile bool LED_State = LOW;

void setup() {
  // put your setup code here, to run once:
    pinMode(0, INPUT);
    attachInterrupt(digitalPinToInterrupt(0), startBit_isr, FALLING);
  
    pinMode(23, OUTPUT); // LED for debugging
    LED_State = HIGH;
    digitalWrite(23, LED_State);
    sei();
}

void loop() {
  // put your main code here, to run repeatedly:
    delay(1000);
}

void startBit_isr()
{
    LED_State = !LED_State;
    digitalWrite(23, LED_State);
}
 
Hello,

I don't know if your LED is realy on pin 23. If you want to invert onboard LED of teensyLC, this one is on pin 13 (may be a typo).
 
Status
Not open for further replies.
Back
Top