Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LEDs/lights
#5
Code I used

// We're updating 4x/second

void updateLEDs()
{
  // Our things happen 4x/second
  int time = (millis() % 1000) / 250;
 
  // Right side counts down from 3 in binary
  // Right Red is 2's on time 0 & 1
  leds[LED_RIGHT_A].r = 0;
  leds[LED_RIGHT_A].g = 0;
  leds[LED_RIGHT_A].b = 0;   
  if (time < 2)
  {
    leds[LED_RIGHT_A].r = 255;   
  }
 
  // Right Green is 1's on time 0 & 2
  leds[LED_RIGHT_B].r = 0;
  leds[LED_RIGHT_B].g = 0;
  leds[LED_RIGHT_B].b = 0;   
  if (time == 0 || time == 2)
  {
    leds[LED_RIGHT_B].g = 255;
  }
   
  // Left & rear LED blinks red about 2hz, but slightly off of right side?
  time = (millis() % 510) / 255;
  leds[LED_REAR].r = 0;
  leds[LED_REAR].g = 0;
  leds[LED_REAR].b = 0;
  leds[LED_LEFT].r = 0;
  leds[LED_LEFT].g = 0;
  leds[LED_LEFT].b = 0;
  if (time == 0)
  {
    leds[LED_REAR].r = 255;
    leds[LED_LEFT].r = 255;
  } 
 
  // Front is Blue
  leds[LED_FRONT].r = 0;
  leds[LED_FRONT].g = 0;
  leds[LED_FRONT].b = 255;
  // Show our updates
  FastLED.show(); 
}
Reply


Messages In This Thread
LEDs/lights - by kresty - 02-21-2017, 11:02 PM
RE: LEDs/lights - by Ramjet - 06-26-2017, 02:22 PM
RE: LEDs/lights - by kresty - 06-26-2017, 02:34 PM
RE: LEDs/lights - by kresty - 03-19-2018, 02:32 PM
RE: LEDs/lights - by kresty - 03-19-2018, 02:32 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)