Skip to main content
Inlined links
Source Link
Adrian
  • 108
  • 8

This is admittedly a cross-post from LED fade malfunction (random flash) but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that iti is reset to 0 in the first program whereas in the second, iti keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?) problem.

There is a video on youtube of it happening here, Arduino - fading LED problem.

This is admittedly a cross-post from LED fade malfunction (random flash) but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that it is reset to 0 in the first program whereas in the second, it keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?) problem.

There is a video on youtube of it happening here, Arduino - fading LED problem.

This is admittedly a cross-post from LED fade malfunction (random flash) but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that i is reset to 0 in the first program whereas in the second, i keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?) problem.

There is a video on youtube of it happening here, Arduino - fading LED problem.

This is admittedly a cross-post from http://forum.arduino.cc/index.php?topic=360468.0LED fade malfunction (random flash) but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that iit is reset to 0 in the first program whereas in the second, iit keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?????) problem.

There is a video on youtube of it happening here, https://www.youtube.com/watch?v=mbBJWjYScngArduino - fading LED problem.

This is admittedly a cross-post from http://forum.arduino.cc/index.php?topic=360468.0 but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that i is reset to 0 in the first program whereas in the second, i keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?????) problem.

There is a video on youtube of it happening here https://www.youtube.com/watch?v=mbBJWjYScng

This is admittedly a cross-post from LED fade malfunction (random flash) but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that it is reset to 0 in the first program whereas in the second, it keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?) problem.

There is a video on youtube of it happening here, Arduino - fading LED problem.

Tweeted twitter.com/StackArduino/status/671076330092552193
Source Link
Adrian
  • 108
  • 8

Why does an LED sometimes flash when increasing brightness?

This is admittedly a cross-post from http://forum.arduino.cc/index.php?topic=360468.0 but I can't get an answer on the Arduino forum.

I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random).

int led = 11; int brightness = 0; void setup() { pinMode(led, OUTPUT); } void loop() { if(brightness >= 256) //checks if brightness has passed 255, resets to 0 { analogWrite(led, 255); brightness = 0; } analogWrite(led, brightness); if(brightness == 0) { delay(1000); //LED off for 1 second } brightness+=1; //increment brightness delay(20); } 

So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!

int i = 0; int led = 11; void setup() { pinMode(led,OUTPUT); } void loop() { analogWrite(led, i); delay(6); if(i%256 == 0) { i = 0 ; delay(1000); } i++; } 

Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that i is reset to 0 in the first program whereas in the second, i keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?????) problem.

There is a video on youtube of it happening here https://www.youtube.com/watch?v=mbBJWjYScng