Go Down

Topic: maintaining a color on arduino uno with a 2 pin rgb led (Read 1 time) previous topic - next topic

8bitbacon

Hi, I have an arduino uno r3 and I also have 2 pin rgb led's that flash randomly, you can take a look at them here:
http://www.ebay.com/itm/50Pcs-LED-RGB-Rainbow-FAST-flash-2-PINS-F5-5MM-Super-Bright-Bulb-Lamp/182172156458?_trkparms=aid%3D222007%26algo%3DSIM.MBE%26ao%3D1%26asc%3D20150313114020%26meid%3D046891983fee405e8a045611db288af5%26pid%3D100338%26rk%3D5%26rkt%3D30%26sd%3D252928250466&_trksid=p2141725.c100338.m3726

 so basically I found out that if I put the leds in a 3x3 array and pulse them with microsecond functions I can get the led to stay on the blue color perfectly, if I change the timing, I was able to get one of the led's in the array to start and stay on red, but it was a very light red, I couldn't get it as bright as the blue, and as for staying on green, I couldn't get it to stay on green at all but with the right timing order im sure I will be able to, now these led's don't really come with instructions to do something like this and no one really teaches you how to maintain a certain color with 2 pin led's all the tutorials are for 3 pin or 4 pin led's, so if you want to help out on the project I advise you buy the product I showed you and help me find the right timing order so we can all start channeling colors through 2 pin led's because 4 pin led's are super funny im not going to waste 4 spots on my arduino to change colors, any ways here is some more light that some one has done something like this, except in this case, these leds are made to do this and are a completely different story but let me know if you find some of these online but don't relate this thread to these at all because again these are different ones made to do this and are probably expensive:

https://www.youtube.com/watch?v=gxdgRHmOuIo

I messed up the sketch to keep the ebay led's on red but I will try to remake it and post it, oh and also I was able to have all 3 colors on at the same time but at a very light brightness, so these leds are definitely capable of being kept on certain colors or all 3 at the same time, or even 2 at once

if I buy a product in the future that you probably made and it has one of those retarded 4 pin octopus looking leds I will roast you live on youtube gaming channel for life because you can definately do it with 2 pins with some team work
theres that branded diode 0_o all happy in its housing and stuff

pert

It's cool to mess with that just for the sake of hacking but really you should just use the WS2812B, SK6812, or APA102 addressable LEDs. Then you can control hundreds of RGB LEDs with one pin (or two in the case of the APA102).

8bitbacon

can you make the WS2812B work with 2 pins? it has like 7 colors says 3 pins though
theres that branded diode 0_o all happy in its housing and stuff

8bitbacon

well the WS2812B works with 2 pins only thanks man I got it to work.
theres that branded diode 0_o all happy in its housing and stuff

pert

It only takes one I/O pin on your Arduino to control the WS2812B. Also power and ground, but those don't need to come from your Arduino. You can use a separate power source as long as the grounds are connected. You can add many more of them without using any more pins on your Arduino too since they're addressable.

It actually has 256 red brightness levels x 256 green brightness levels x 256 blue brightness levels = 16777216 colors. Definitely fun stuff to play with!

8bitbacon

theres that branded diode 0_o all happy in its housing and stuff


8bitbacon

theres that branded diode 0_o all happy in its housing and stuff

8bitbacon

Here is my sketch for it, you type a number in the serial moniter 0-6 and it changes to that color while saving to the eeprom so when you reset it, it boots in that color, you also need the adafruit library installed here it is:


Code: [Select]
#include <Adafruit_NeoPixel.h>
#define PIN 6
#include <EEPROM.h>
int value = EEPROM.read(0);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
Serial.begin(9600);
strip.setPixelColor(0,strip.Color(EEPROM.read(0), EEPROM.read(1), EEPROM.read(2)));
strip.show();
}
 
void loop(){
char c = Serial.read();  //gets one byte from serial buffer
if(c=='0'){//blue 5 volts
strip.setPixelColor(0,strip.Color(0, 0, 255));
strip.show();
EEPROM.write(0, 0);
EEPROM.write(1, 0);
EEPROM.write(2, 255);
}
if(c=='1'){//red 5 volts
strip.setPixelColor(0,strip.Color(255, 0, 0));
strip.show();
EEPROM.write(0, 255);
EEPROM.write(1, 0);
EEPROM.write(2, 0);
}
if(c=='2'){//green 5 volts
strip.setPixelColor(0,strip.Color(0,255, 0));
strip.show();
EEPROM.write(0, 0);
EEPROM.write(1, 255);
EEPROM.write(2, 0);
}
if(c=='3'){//pink 5 volts
strip.setPixelColor(0,strip.Color(131,14,53));
strip.show();
EEPROM.write(0, 131);
EEPROM.write(1, 14);
EEPROM.write(2, 53);
}
if(c=='4'){//dimmed white 5 volts
strip.setPixelColor(0,strip.Color(60,70,70));
strip.show();
EEPROM.write(0,60);
EEPROM.write(1, 70);
EEPROM.write(2, 70);
}
if(c=='5'){//white 5 volts
strip.setPixelColor(0,strip.Color(255,255,255));
strip.show();
EEPROM.write(0, 255);
EEPROM.write(1, 255);
EEPROM.write(2, 255);
}
if(c=='6'){//yellow 5 volts
strip.setPixelColor(0,strip.Color(255,255,45));
strip.show();
EEPROM.write(0, 255);
EEPROM.write(1, 255);
EEPROM.write(2, 45);
}
}
theres that branded diode 0_o all happy in its housing and stuff

Go Up