PortalGun icon indicating copy to clipboard operation
PortalGun copied to clipboard

Flickering LED

Open setiupyguppie opened this issue 9 years ago • 2 comments

I'd like to make the main (middle) LED flicker, to simulate the effect seen in the show. Is there a quick-and-dirty way of doing this with your existing code?

SHOW ME WHAT YOU GOT!

:)

setiupyguppie avatar Nov 16 '16 14:11 setiupyguppie

All of the LEDS are wire to pins that are able to do PWM, so you can set the output using "analogWrite()".

Right now the part of the main loop that deals with the LEDS is:

void loop() {  
  if (justWokeUp) {  
    digitalWrite(frontRightPin, HIGH);  
    digitalWrite(frontLeftPin, HIGH);  
    digitalWrite(frontCenterPin, HIGH);  
    digitalWrite(topBulbPin, HIGH);  
    justWokeUp = false;  
  }  

This basically says "if you just turned on the portal gun, set all outputs to a 5V output". If you wanted to modulate the LED, you'd modify that part of the code to set a specific PWM value from 0-255, rather than always "HIGH" (Which is just another way of writing "255".

Check this link for an easy flickering effect

And this one if you want more of a soft breathing effect.

pomeroyb avatar Nov 16 '16 20:11 pomeroyb

More excellent support and guidance! Thank you! I'll keep you posted on my progress.

setiupyguppie avatar Nov 17 '16 12:11 setiupyguppie