Thread Tools
This thread is privately moderated by NobatteryNopower, who may elect to delete unwanted replies.
Dec 01, 2021, 04:23 AM
Registered User
NobatteryNopower's Avatar
Thread OP
Build Log

Throttle / Steering LED bar Indicator / WS2812 leds


Edit - Dec 2nd 2021 - It Works!

PWM / RC control of WS2812 leds. (0 min 20 sec)


Code:
#include <FastLED.h>
#define LED_PIN     7
#define NUM_LEDS    16
#define BRIGHTNESS  20
#define LED_TYPE    WS2812
CRGB leds[NUM_LEDS];
int PWMin = 13;
int PWMvalue = 0;
int value=0;

void setup() 
{
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  pulseIn (13, INPUT);
  Serial.begin(9600);
  FastLED.setBrightness(  BRIGHTNESS );
}
void loop() 
{
  
  PWMvalue      = pulseIn(PWMin, HIGH, 20000);
  Serial.println(PWMvalue);
  FastLED.clear();


  if ((PWMvalue >950) && (PWMvalue < 1000))
  {
  leds[0] = CRGB(255, 0, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >950) && (PWMvalue < 1300))
  {
  leds[1] = CRGB(255, 69, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >950) && (PWMvalue < 1400))
  {
  leds[2] = CRGB(255, 255, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >950) && (PWMvalue < 1500))
  {
  leds[3] = CRGB(0, 215, 0);
  FastLED.show();
  delay(1);
  }

  
  if ((PWMvalue >1500) && (PWMvalue < 2000))
  {
  leds[4] = CRGB(0, 215, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >1600) && (PWMvalue < 2000))
  {
  leds[5] = CRGB(255, 255, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >1700) && (PWMvalue < 2000))
  {
  leds[6] = CRGB(255, 69, 0);
  FastLED.show();
  delay(1);
  }
  if ((PWMvalue >1800) && (PWMvalue < 2000))
  {
   leds[7] = CRGB(255, 0, 0);
  FastLED.show();
  delay(1);
  } 
}
-----Below this line are my previous attempts----------------------------------------

These are my findings so far in controlling a WS2812 ledstrip via RC control (PWM signal) - This post will be update when I make progress. My project doesn't work correct yet. Still some debugging to do. The code will be posted once it works.

LEDs used are WS2812. In my case two strips of Matek. (see attachment)

First result tinkering with Arduino. Bug fixes needed: Leds need to start on LOW / Off, and they light up, but never turn off when decreasing PWM
Arduino WS2812 control with PWM - Not quite there yet (0 min 20 sec)
Last edited by NobatteryNopower; Dec 10, 2021 at 11:44 PM.
Sign up now
to remove ads between posts


Quick Reply
Message:
Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Using WS2812 LEDs and PWM reciever viper98 Multirotor Drone Electronics 3 Jul 24, 2018 03:39 AM
Data Using Arduino Compatible boards to drive full color LED strips (WS2812 and similar) extremewing Night Flying 57 Dec 20, 2016 01:22 PM
Help! Naze32 10DOF LED WS2812 only working with USB connected Tassilo Multirotor Drone Electronics 0 Jul 10, 2016 03:41 PM
Discussion WS2812 LED strip problem - random colors Asalas77 Multirotor Drone Electronics 1 Mar 07, 2016 09:53 PM