Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support regular (non-RGB) LEDs, including an onboard LED #127

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions atmega_duck/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,25 @@ namespace led {
}
}

#else // if defined(NEOPIXEL)

#else // Use onboard LED, or LED_PIN if defined
#include <Arduino.h>
namespace led {
void begin() {}
#if defined(LED_PIN)
int ledPin = LED_PIN;
#else
int ledPin = LED_BUILTIN;
#endif
void begin() {
pinMode(ledPin, OUTPUT);
}

void setColor(int r, int g, int b) {}
void setColor(int r, int g, int b) {
// On unless all colours are below 50 (about 20%)
if (r > 50 && g > 50 && b > 50) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
}

#endif // if defined(NEOPIXEL)