Page 1 of 1

I need some help wiring a caps lock led to a Teensy

Posted: 08 Jan 2018, 01:42
by SpacemanToby
I have it wired up like this:

pin D4 ---> +anode led ---> -cathode led ---> 1k resistor ---> GND

My code looks like this:

Code: Select all

void led_layer_set(uint32_t state) {

    DDRD |= (1<<4);

    if ((1<<1 & state) != 0) {
      print("layer pressed");
      PORTD |= (1<<4);
    } else {
      print("released");
      PORTD &= ~(1<<4);
    }
}  
I have this code trigger when I press my function key (CAPS LOCK), and the led should turn off when I release it.
I've used HID Listen and print statements to verify that the code triggers properly when I press and release, but the light doesn't come on. I have to believe I don't understand how it should be wired and how pins are activated.

Posted: 08 Jan 2018, 04:20
by SpacemanToby
I'm so dumb. It was working perfectly, but the switch was put in upside down in the plate and I couldn't see that the light was coming on through the window. Ugh