Comments (16)
This is an odd one. What happens when you try to use it? I assume the LED doesn't come on at all?
Here's my theory: The library doesn't set the pin output mode itself and D0
is by default RX
, which would be an input pin. Try this line in the setup()
method:
pinMode(0, OUTPUT);
I don't think it has anything to do with the line you referenced in the header. That's just a default initialization and if you pass the pin number explicitly, that will be ignored.
from arduino-ledfader.
Unfortunately, that didn't work. I even added:
UCSR0B = 0;
but that didn't help, either. And yes, the LED doesn't come on at all.
EDIT: Also, regular analogWrite(0,255);
works, as does other LED libraries like jLed.
from arduino-ledfader.
That's really odd. Offhand I'm not sure why that would happen. I'll see if I have any Atmega 328PB chips lying around I can try this on.
from arduino-ledfader.
Just out of curiosity, does led.set_value(125);
set the LED to half brightness?
from arduino-ledfader.
Same result - the LED does not light.
#define LED_PIN 0
LEDFader led;
void setup() {
led = LEDFader(LED_PIN);
led.set_value(125);
}
void loop() {
led.update();
}
from arduino-ledfader.
Ah ha! I think I found the problem:
https://github.com/jgillick/arduino-LEDFader/blob/master/LEDFader.cpp#L30
The code is first checking if the pin has been set. Well pin 0
is equivalently false
. You can remove any of those lines. I'll try to update the library soon, but would also take a pull request if someone else wanted to take a stab at it. The library needs to be initialized with a pin, so those checks are likely moot.
from arduino-ledfader.
That's definitely the issue - if I comment out:
// No pin defined
//if (!pin) {
// return;
//}
then all works as expected.
I would happily do a pull request for this, but wanted to check with you first - is it sufficient to just remove those checks from all functions, or would it be better to initialize the class with a signed int instead, as in:
// Create a new LED Fader for a pin
LEDFader(int pwm_pin=-1);
Then the checks can remain, but like this:
// No pin defined
if (pin == -1) {
return;
}
from arduino-ledfader.
I think it's safe to remove those checks entirely. A pin must be defined at initialization, so the checks are really unnecessarily. Thank you!
from arduino-ledfader.
Ok, I’ll remove them and submit a pull request.
from arduino-ledfader.
Done
from arduino-ledfader.
Great. Did you submit a pull request?
from arduino-ledfader.
I did, although this is my first Github pull request. Do you not see it?
from arduino-ledfader.
It would show up here:
https://github.com/jgillick/arduino-LEDFader/pulls
Can you send me a link to it?
from arduino-ledfader.
from arduino-ledfader.
It is showing up now under Pull requests.
from arduino-ledfader.
Got it and merged! Thanks @RossAWaddell, I really appreciate the help on this one.
from arduino-ledfader.
Related Issues (20)
- RFDuino HOT 1
- after 6 led.fade command not working HOT 1
- Need to include <avr/pgmspace.h> HOT 1
- Use function in "Curve::exponential" instead of table HOT 3
- Does not compile for ESP8266 b/c of pgmspace.h HOT 6
- Setting PWM with value more than 255 HOT 4
- lights show HOT 5
- 2 leds HOT 4
- Percent variable
- RGB led fading HOT 2
- Startup Fade in Setup() HOT 3
- Fader resets fade state when the same value is continuously set HOT 1
- does not seem compatible with Teensy HOT 4
- avr/pgmspace.h
- Curve.h HOT 1
- curve function how to set
- Redefinition of void setup
- help on execute a command after fade down HOT 1
- Pause after 3 fades
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-ledfader.