Stormtrooper Droid-Alert color diffuser

Submitted by MarieSpliid on Mon, 02/11/2013 - 12:27
MarieSpliid's picture


In this lab assignment I have created a diffuser in the shape of a paper folded Stormtrooper.

By default the Stormtrooper has a blue-ish color but when you type "droid" in the serial monitor, the Stormtrooper turns all red! This way the Stormtrooper functions as a droid-alarm, the same way that Frodo's (from The Lord of The Rings) sword "Sting" glows blue, when Orcs are around!

**May The Force Be With You**


  • 3 x LED Lights (red, green blue)

  • 3 x Resistor (220 ohm)

  • Breadboard

  • Arduino

  • 4 Cables

  • USB Cable

  • CubeCraft paper model Stormtrooper (

  • Cotton

Problems on the way

Elliot helped me and we found out, that we had to replace all singe citation signs (') must be replaced by double citations signs (") when we are working with springs and not just single characters.




 * Serial RGB LED
 * ---------------
 * Serial commands control the brightness of R,G,B LEDs
 * Command structure is "<colorCode><colorVal>", where "colorCode" is
 * one of "r","g",or "b" and "colorVal" is a number 0 to 255.
 * E.g. "r0"   turns the red LED off.  
 *      "g127" turns the green LED to half brightness
 *      "b64"  turns the blue LED to 1/4 brightness
 * Created 18 October 2006
 * copyleft 2006 Tod E. Kurt <
char serInString[100];  // array that will hold the different bytes of the string. 100=100characters;
                        // -> you must state how long the array will be else it won't work properly
String colorCode;
int colorVal;
int redPin   = 5;   // Red LED,   connected to digital pin 5
int greenPin = 9;  // Green LED, connected to digital pin 9
int bluePin  = 10;  // Blue LED,  connected to digital pin 10
void setup() {
  pinMode(redPin,   OUTPUT);   // sets the pins as output
  pinMode(greenPin, OUTPUT);   
  pinMode(bluePin,  OUTPUT);
  analogWrite(redPin,   100);   // set lights to blue--ish color
  analogWrite(greenPin, 80);   
  analogWrite(bluePin,  254);   
  Serial.println( "Tell me what you see!");  //print this in the serial monitor, asking the Stormtrooper what it sees.
void loop () {
  // clear the string
  memset(serInString, 0, 100);
  //read the serial port and create a string out of what you read
  colorCode = serInString;
  if( colorCode == "droid" ) {
    if(colorCode == "droid") {  // if someone writes "droid" in the serial monitor.
      analogWrite(redPin, 255); // turn red pin on full
      analogWrite(bluePin, 0); // turn off blue pin
      analogWrite(greenPin, 0); // turn off green pin
  delay(100);  // wait a bit, for serial data
//read a string from the serial and store it in an array
//you must supply the array variable
void readSerialString (char *strArray) {
  int i = 0;
  if(!Serial.available()) {
  while (Serial.available()) {
    strArray[i] =;


Screen shot 2013-02-11 at 11.35.45 AM.png
Screen shot 2013-02-11 at 11.34.50 AM.png
Your rating: None
Drupal theme by Kiwi Themes.