I need help with Arduino for an electronic project.
I am new with Arduino, I haven't done much codes for it.
It is to make a headset wireless.. just for fun...
Consider there are 4 LEDs, indicating a function.
I want to use a two (or three) WS2812B LED to show all 4 functions (two groups).
I will be using a Arduino Nano.
Is it possible like this
If the WS2812B(s) (1/2/3) is connected to pin 5.
it should work like following
WS2812B 1
A. is pin 1 detected voltage increase the WS2812B should turn red
B. is pin 2 detected voltage increase the WS2812B should turn green
A is for power on indicator and B is Bluetooth activity indicator.
If necessary, it is OK to use separate WS2812Bs (total 3 WS2812B) for A&B (I have 3 long strips of WS2812Bs here...)
WS2812B 2
C. is pin 3 detected voltage increase the WS2812B should turn blue
D. is pin 4 detected voltage increase the WS2812B should turn white
A & B will not happen at the same time...
C & D charging indicators C= Charging and D= full charged.
I short I have a bluetooth board and a charging board. Both has total 4 LEDs. (from 0V to max 3V positive).
A battery charging circuit (TP4056 with protection circuit).
it has two LEDs one for "charging" and the second for "charging complete". Only one will light up at the same time. no blinking/fading effect here..
A bluetooth audio module. haven't decided yet, ordered 3..
Has two LEDs, one for "power" and the second for "connecting/pairing". both will blink depends on connected or not.
Searched all over the internet,and couldnt find anything...
If anyone can give me a code, I might be able to add more features in it. Right now I have no Idea where to start.
But you need to specify it a bit more. Two points come to mind:
define voltage increase. Above a certain level? Specific dV/dt?
What if two actions happen at the same time?
Hi, thanks for the reply, I have edited the question with more details.
Specific dV/dt? I didnt get it...
Consider there are 4 LEDs, indicating a function.
I want to use a two (or three) WS2812B LED to show all 4 functions (two groups).
I will be using a Arduino Nano.
Is it possible like this
If the WS2812Bs is connected to pin 5 & 6.
it should work like following
WS2812B 1
A. is pin 1 detected voltage increase the WS2812B should turn red
B. is pin 2 detected voltage increase the WS2812B should turn green
A is for power on indicator and B is Bluetooth activity indicator.
If necessary, it is OK to use separate WS2812Bs (total 3 WS2812B) for A&B (I have 3 long strips of WS2812Bs here...)
WS2812B 2
C. is pin 3 detected voltage increase the WS2812B should turn blue
D. is pin 4 detected voltage increase the WS2812B should turn white
A & B will not happen at the same time...
C & D charging indicators C= Charging and D= full charged.
I short I have a bluetooth board and a charging board. Both has total 4 LEDs. (from 0V to max 3V positive).
Look it it like this, if I tell you to call me if the length of the corn on the field increased, when will you call me?
But I think it's even smarter to give us more details about that magic board. Changing the color of 1, 2,5, 30 WS2812B is all possible if we know what the signals really are.
Look it it like this, if I tell you to call me if the length of the corn on the field increased, when will you call me?
But I think it's even smarter to give us more details about that magic board. Changing the color of 1, 2,5, 30 WS2812B is all possible if we know what the signals really are.
I am sorry for providing less details...
There are two boards
A battery charging circuit
it has two LEDs one for "charging" and the second for "charging complete". Only one will light up at the same time. no blinking/fading effect here..
A bluetooth audio module.
Has two LEDs, one for "power" and the second for "connecting/pairing". both will blink depends on connected or not.
I am not sure if it is complicated coding or not, but if you can help me with the LED A & B alone, I might be able to do the rest.
Searched all over the internet,and couldnt find anything...
Am I reading this correctly that you want to connect separate WS2812b's to different pins? The correct way to do that is to connect a single chain of multiple WS2812b's to a single pin, and control them individually through code.
silly_cone:
Am I reading this correctly that you want to connect separate WS2812b's to different pins? The correct way to do that is to connect a single chain of multiple WS2812b's to a single pin, and control them individually through code.
YES, I didn't think that way. You are right.
connecting separate WS2812b's to different pins is the way to do it.
Ahh, okay. Do you know to BT and charger chips? Because yes, you can probably measure voltages to check to see if the go above a threshold but it looks digital so that's even easier.
The voltages you measure are probably across the led? But I bed all those leds have a resistor in series as well. And the controllers just source (or sink!) the supply. Easy to detect with a digital pin.
And no, connecting two WS2812b to separate pins only makes it harder. They are individually controlled leds for a reason
septillion:
Ahh, okay. Do you know to BT and charger chips? Because yes, you can probably measure voltages to check to see if the go above a threshold but it looks digital so that's even easier.
The voltages you measure are probably across the led? But I bed all those leds have a resistor in series as well. And the controllers just source (or sink!) the supply. Easy to detect with a digital pin.
And no, connecting two WS2812b to separate pins only makes it harder. They are individually controlled leds for a reason
can you give me a sample code, so that I can play with, it might take some time... but I can make it work. I am at point ZERO now...
To see how to control WS2812b's individually on a single string, take a look through FastLED library examples. That's probably the best one to use for those LEDs.
For controlling the leds? Have a look at the example of a library that can drive them. I would recommend Fastled.
But I think setting the leds to the correct color is the easy part of this project Interfacing with something unknown is harder
OK, I will try.
if possible try to give me a code which can work by sensing "touch".
If I press a wire on PIN 1, the WS2812B sould light red, if I press a wire on PIN 2, the WS2812B sould light green.
Thanks for the replys.
This code uses the internal pullup resistors on the arduino pins to pull them high, and the WS2812b is connected to pin 5. If pin 2 grounds (like through a button press), the LED lights up red and stays red. If pin 3 grounds, the LED turns to green and stays green.
The #define statements create a variable of type const byte, in case you're unaware. The #define statements don't use an "=" nor are they terminated by a ";"
silly_cone:
This code uses the internal pullup resistors on the arduino pins to pull them high, and the WS2812b is connected to pin 5. If pin 2 grounds (like through a button press), the LED lights up red and stays red. If pin 3 grounds, the LED turns to green and stays green.
The #define statements create a variable of type const byte, in case you're unaware. The #define statements don't use an "=" nor are they terminated by a ";"
silly_cone:
I forgot a ";" after the delay statements. Its been added now.
Ya, I saw that.
How to make it turn on only when the pin connects to positive ?
like if I use a push button, it should turn only only while the button is pressed, it should turn off right after I release the button. That is the final help I needed, please reply.
This code will do that. It assumes pins 2 and 3 are tied to ground and connected to a button whose other side is connected to the high-side, so when the button is pressed, the pin goes high.
If BUTTON_1 goes high, the led will light red until the button is released.
If BUTTON_2 goes high, the led will light green until the button is released.
silly_cone:
This code will do that. It assumes pins 2 and 3 are tied to ground and connected to a button whose other side is connected to the high-side, so when the button is pressed, the pin goes high.
If BUTTON_1 goes high, the led will light red until the button is released.
If BUTTON_2 goes high, the led will light green until the button is released.
I uploaded and tested the code, so I can confirm it does work. Maybe try testing your LED to make sure the green channel isn't shot; that does happen.
Also, did you notice that I changed the pin-states to reflect detecting a pin-HIGH, not pin-LOW? My first example detected a button press tied to ground. My second example detects a button press tied to high. So if you kept the original wiring configuration from the first example, then you're correct, the second example would do nothing.
Also, I realized my IF-statements weren't necessary. So see below for the condensed code.
Again, this code assumes you have pin 2 and 3 tied to ground with pull-down resistors, and have them connected to a button whose other side is connected to VCC.
Macro's are outdated and if you start numbering, arrays. Calling .show() multiple times in loop() is stupid. Same for writing blocking code...
@shijil, but I'm out. If you're to damn stubborn to give details I wish you good luck. Like I said, the code is the easy part. Because some chip turns on a LED you can't simply assume it drives it high...