This is still very much in progress. As of now, this functions well with two RGB Common Anode LEDs. If you are not using RGB Common Anode, put two "//" in front of the line that says "define COMMON_ANODE." It will make BB-9E's side lights flicker a random amount of times from blue to red, like in the film "Star Wars, Episode VIII: The Last Jedi," then return to blue for a random amount of time. Please comment if you have any suggestions. int redPin = 11; int greenPin = 10; int bluePin = 9; //If not using common anode, put "//" in front of text below. #define COMMON_ANODE void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop() { for(int ii=0; ii<random(5,20); ii++) { setColor(0,0,255); delay(300); setColor(255, 0, 0); delay(100); } setColor(0, 0, 255); // blue delay(random(100, 20000)); } void setColor(int red, int green, int blue) { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }
0 Comments
|
ArchivesCategoriesPlease note: Emma's Droids is not associated with Lucasfilm. This is simply a fan site. Star Wars, its characters (including BB-9E) and all associated items are the intellectual property of Lucasfilm. © & ™ Lucasfilm Ltd.
|