Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Can anyone help me with led strip and distance sensor (similar concept to proximity sensor from the website)

Can anyone help me with led strip and distance sensor (similar concept to proximity sensor from the website)

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 2 Posters 24 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TinkerTailor
    wrote on last edited by
    #1

    Hey guys, I just found the proximity / LED ring example on the website as I am trying to do a similar project work with GPS instead of proximity sensor.

    I have a small strip of 7 addressable sk6812 leds and I would like to have them turn on when certain distance has been achieved. I'm looking at the proximity LED ring example but I can't figure out which parts of that sketch could I incorporate in mine.

    I would like to use the LED strip instead and have 3 criterias for 3 preset distances. For example,

    • at 5m turn on led 1 and 2 in blue
    • at 3m turn on led 3 4 5 in yellow
    • at 1m turn all leds in red.

    At the moment I only can use those clunky 5mm leds and void loop looks like this - this turns on the LED if the distance is 5m or less.

            Serial.print(F("Next in range = "));
            Serial.print(shortestDist, 2);
            Serial.println(" m");
            
            if (shortestDist < 5)   
            {
              digitalWrite(ledPin, HIGH);
            }
    
            else
            {                  
              digitalWrite(ledPin, LOW);
            }            
    
        }
        if (gps.charsProcessed() < 10)
            Serial.println(F("No GPS data."));
        last = millis();
        Serial.println();
    
    1 Reply Last reply
    0
    • E Offline
      E Offline
      ejlane
      wrote on last edited by
      #2

      Try using the Neopixel library.

      https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use

      https://sbaronda.com/2020/09/20/sk6812-with-arduino-using-neopixel-library/

      Those should get you started. Basically, instead of having your code directly turn a pin on or off, you tell it to set a color in the library and then run the show() command and the library will do all the pin toggling needed to actually control the LEDs.

      1 Reply Last reply
      1
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      12

      Online

      11.7k

      Users

      11.2k

      Topics

      113.1k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular