Extra LEDs For the Onewheel (Because RGB adds a 15% preformance boost)
-
I figured the issue you are having with the lights strobing. In your pattern1 you have delay(10) which will only delay it for 10 milliseconds. I changed the 10 to 1000 for one second and here are the results.
I also recommend changing your "time" variable name to something else such as "timer". There are certain variable names that are reserved for other things.
Check out the Neopixel Uber Guide for a bunch of information about the leds and the library. For example you can set the whole "strip" to a color with a single line of code, instead of having to create a function to iterate through the addresses.
https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use
-
@cheppy44 You are a life saver, holy crap
all I need to do is add a part so if I use a second button, I can control the other four LEDs
-
@cheppy44 good find…. 👍
Typical… NOT available on Amazon UK or EBay UK !!!
Edit…. Found it in RS;)
I think maybe sticking one on the helmet and using voice commands could be an idea, easy to keep PSU and device safe top end (hopefully). -
@puzz360 let me know how it goes! I am tempted to pick a few up to experiment with.
-
@cheppy44 struggling with the code currently. Trying to have two button inputs and two switch functions but nothing is working for the other LEDs
-
@loaffette what are you trying to have the buttons change?
-
@cheppy44 if I understand your question correctly, I want one LED to control half of the LEDs (for the left side), and another button control the other half (right side)
-
@loaffette ahh ok so you want 1 button each for a left turn and a right turn.
-
@cheppy44 yep!
And I don't know how to get that to work
-
@loaffette I am setting up the electronics to try and write the code for it. I might start from scratch with the code, but I can try to explain the code I end up writing! I dont exactly want to rob you of learning how to do this, but it sounds like a fun small project to work on for me.
-
@cheppy44 Thanks man!
I really owe you for this one! I'm pretty bad at programming and this really helps!
I'll probably get around to building a controller for this and designing a mount for the arduino and the LEDs. Found that under the fender is the only safe bet for now, and the footpad would be a pain.May look at doing on the fender itself (On top) could be an option.
-
@loaffette here is a demo! still working out a few kinks
-
@loaffette
Here is the code I made! it uses 2 buttons and has 2 outputs for a front and a rear strip. Depending on what controller you use, you may have to set up the button inputs a bit differently. The ESP 32 I am using has Internal Pull up/down resistors for the inputs. I attempted to comment my code pretty good so you can attempt to learn a bit if you feel like it. If you've got any questions or want me to make some changes I am more than willing to help you out!#include <Adafruit_NeoPixel.h> #define PIN1 12 // Pin for Front Strip #define PIN2 13 // Pin for Rear Strip #define BUTTON_PIN1 4 // Pin for Button 1 #define BUTTON_PIN2 19 // Pin for Button 2 #define NUMPIXELS 9 // Number of Neopixels in each strip Adafruit_NeoPixel strip1(NUMPIXELS, PIN1, NEO_GRB + NEO_KHZ800); //Setup for Strip1 Adafruit_NeoPixel strip2(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800); //Setup for Strip1 int buttonState1 = 0; // variable for reading the pushbutton status int buttonState2 = 0; // variable for reading the pushbutton status uint32_t white = strip1.Color(255, 255, 255); //Defines a color later to be used in strip1.fill (r,g,b) uint32_t red = strip1.Color(255, 0, 0); uint32_t yellow = strip1.Color(255, 255, 0); void setup() { pinMode(BUTTON_PIN1, INPUT_PULLUP); // Pin for button 1 other side connected to ground pinMode(BUTTON_PIN2, INPUT_PULLUP); // Pin for button 2 other side connected to ground strip1.begin(); // INITIALIZE NeoPixel strip1 object (REQUIRED) strip1.setBrightness(4); // a value from 0 to 255 strip1.show(); // Initialize all pixels to 'off' strip2.begin(); // INITIALIZE NeoPixel strip2 object (REQUIRED) strip2.setBrightness(4); // a value from 0 to 255 strip2.show(); // Initialize all pixels to 'off' Serial.begin(9600); //start Serial console for debuging Serial.println("begin"); } void loop() { buttonState1 = digitalRead(BUTTON_PIN1); buttonState2 = digitalRead(BUTTON_PIN2); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState1 == LOW) { // turn left turn signal on Serial.println("button one left"); strip1.fill(white, 0, 4); //strip.fill(color, first led index, number of leds to fill); strip1.fill(yellow, 5, 4); strip1.show(); strip2.fill(red, 0, 4); strip2.fill(yellow, 5, 4); strip2.show(); delay(500); //delay for 500 milliseconds or .5 seconds strip1.fill(white, 5, 4); strip1.show(); strip2.fill(red, 5, 4); strip2.show(); delay(500); } if (buttonState2 == LOW) { // turn right turn signal on Serial.println("button two right"); strip1.fill(yellow, 0, 4); strip1.fill(white, 5, 4); strip1.show(); strip2.fill(yellow, 0, 4); strip2.fill(red, 5, 4); strip2.show(); delay(500); strip1.fill(white, 0, 4); strip1.show(); strip2.fill(red, 0, 4); strip2.show(); delay(500); } else { // turn leds back to "normal" //Serial.println("normal"); strip1.fill(white, 0, 4); strip1.fill(white, 5, 4); strip1.show(); strip2.fill(red, 0, 4); strip2.fill(red, 5, 4); strip2.show(); } delay(50); }
-
@cheppy44 thanks man!
This really helps me out with getting this going!
I'll give the code a spin in Tinkercad when I have time later tonight! -
Got the button code translated to work for the Arduino! Just had to change (INPUT_PULLUP) to (INPUT).
Tinkercad simulator is a bit broken though currently, and it's running slow. I'm gonna go and try to find a USB cable for the arduino and test it using real hardware instead.
Again, thank you so much for helping me out with the code!
-
No dice yet.
The arduino isn't recognizing the button press.Gonna try and see what I can chagne or what I can do
Changed the
} if (buttonState2 == HIGH) {
to LOW instead of high, and found that when I hold it down, it pauses the flashing -
@cheppy44 So I messed around a bit with the code to try and make it work
Added a fuction that would print to the console if button two wasn't pressed.
I don't have anything plugged into the pin for button 2 or 1 and it's reading that button one is pressed..Could my arduino be messed up?
what board are you using, I might try and buy the board you have instead.
Also, when I have the button plugged in and I hold it down, the LEDs stop flashing but are stuck on red -
@loaffette I am using an ESP 32 dev module, but I would not recommend it if you want to implement this on your board. I have a suspicion your issue has to do with pull up/down resistors. Could you post a picture of what your electronics looks like? The purpose of the resistors is to give the digital inputs a default state. If you leave them unconnected or “floating”, they are subjected to back ground electronic noise and are not reliable. Some micro controller have certain pins that have internal resisters that you can enable.
-
@cheppy44 I may have forgotten about the resistor...
-
@loaffette the controller you have may have internal pull up you can enable, that was why I was asking what your electronics situation looks like.