Experimenting with Capillary tubes

LED diffusion has in my minimal experience usually meant sanding: sanding acrylic surfaces in layers and sanding the LEDs too. This time I wanted to experiment with an object I’ve had in my possession for a few years for reasons unknown: a canister of capillary tubes. My goal was to put the LEDs at the bottom of the container to see what would happen with the light and how it would diffuse both sideways through the tubes and also up along them. Between the LEDs and the bottoms of the tubes I put some stuffing to help with the diffusion process, and carefully cut a plastic cup to fit inside for the tubes to stand on. 

 

I also had ambitions to make the code translate normal strings of text into different colored patterns, brightnesses, and fade lengths, but my shortcomings with C ended up forcing me to settle for the simpler interaction (increasing brightness with key presses). Still, it’s an interesting looking object both with the tubes bunched and unbunched, and does a great job of diffusing light.

 

Materials:

Arduino Uno

Arduino Mini

Wires

Capillary Tubes; container

3 LEDs, (R, G, B)

3 Resistors (220 ohm)

Soldering iron, solder

 

Code: 

/* 
* 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 <tod@nulltodbot.com
* http://todbot.com/
*
*
* Special thanks to Neera, whose post I looked at in order to troubleshoot my own 🙂
*/

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
char colorCode;
int colorVal;

int redPin = 9; // Red LED, connected to digital pin 9
int greenPin = 10; // Green LED, connected to digital pin 10
int bluePin = 11; // Blue LED, connected to digital pin 11

int brightNess = 0;

int i = 0; // Loop counter 
int wait = 20; // 50ms (.05 second) delay; shorten for faster fades
int DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup() {
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(greenPin, OUTPUT); 
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
analogWrite(redPin, 255); // set them all to v bright
analogWrite(greenPin, 255); 
analogWrite(bluePin, 255); 
Serial.println(“enter color command”); 
}

void loop () 
{
// clear the string
memset(serInString, 0, 100);
//read the serial port and create a string out of what you read
readSerialString(serInString);
brightNess = strlen(serInString);

colorCode = serInString[0];
if( colorCode == ‘r’ || colorCode == ‘g’ || colorCode == ‘b’) {
colorVal = int(brightNess * 10 * 2.55);
Serial.print(“setting color “);
Serial.print(colorCode);
Serial.print(” to “);
Serial.print(colorVal);
Serial.println();
serInString[0] = 0; // indicates we’ve used this string
if(colorCode == ‘r’) 
analogWrite(redPin, colorVal);
else if(colorCode == ‘g’)
analogWrite(greenPin, colorVal);
else if(colorCode == ‘b’)
analogWrite(bluePin, colorVal);

}

delay(wait); // Pause for ‘wait’ milliseconds before resuming the loop 
}

//read a string from the serial and store it in an array
//you must supply the array variable
void readSerialString (char *strArray) {
int j = 0;
if(!Serial.available()) {
return;
}
while (Serial.available()) {
strArray[j] = Serial.read();
j++;
}
}

 

Video:

https://www.youtube.com/watch?v=fxTJK_eC5Xw&feature=youtu.be

4 3 2 1

Sing happy birthday with LEDs

Description

Learning about blinking LED using Arduino, I wanted to create something that could deliver value/benefit to an observer. A thought came to my mind: sing a song for him/her! By varying the tempo, I was able to make the LEDs blink along with the song, Happy Birthday.  One obstacle I found was that the LED bulbs were too bright to a naked eye and, thus, are in need of appropriate/decorative cover.

 

Components

  • 1 Arduino Uno
  • 1 Breadboard
  • 2 LEDs
  • Jumper wires
  • 1 USB cable
  • 1 220 ohm resistor

Code

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // Happy birthday to you
delay(375);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH); //turn the LED on (HIGH is the voltage level)
delay(125); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(50);

digitalWrite(13, HIGH); // Happy birthday to you
delay(375);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(125);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(50);

digitalWrite(13, HIGH); // Happy birthday dear my friend
delay(375);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(125);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);

digitalWrite(13, HIGH); // Happy birthday to you
delay(375);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(125);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(50);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(50);
}

 

image1 image2

Fading LED

Description

After having the LED blink in accordance with the preloaded program, I proceeded to write my own. I wanted the LED to glow at its maximum brightness, slowly fade to zero and then rise again. I used a for() loop for accomplishing this. Also, I used analogWrite instead of digitalWrite so I can have varying levels of brightness instead of a binary HIGH or LOW.

Components

  • 1 Arduino Uno
  • 1 Breadboard
  • 1 LED
  • Jumper wires
  • 1 USB cable
  • 1 220 ohm resistor

Code



int green = 11;

void setup() {
pinMode(green, OUTPUT);             // initialize analog pin 11 as an output.
}

void loop() {
int x = 1;
for (int i = 0; i &gt; -1; i = i + x)
 {
   analogWrite(green, i);
   if (i == 255)                     // if the LED reaches maximum brightness,
     x = -1;                         // start dimming it by 1 point every second
   delay(100);
 }
}

 

IMG_20160831_153826 IMG_20160831_153426

Lab 01 – Sandeep

Description

The lab was about the basic task of blinking an LED. I connected the output pin 13 and the ground pin to the breadboard. Next I placed a resistor (220 ohms) on the breadboard and connected it to the jumper cable connecting output pin 13. The long leg of the LED was connected to the resistor and the shorter was connected to the jumper cable connecting to the ground pin. I wrote a code to vary the duration of LED blinking using a for loop. This reminded me of the lights we have up at diwali (festival of lights) where a similar random repeating set of LEDs are lit.

Components

  • 1 Arduino Uno R3
  • 1 Breadboard
  • 1 LED
  • 5 jumper cables
  • 1 USB power cable

Code


/*
 * Lab 01: LED Blink
 * Sandeep Pal
 * Prof : Kimiko Ryokai
 * TA : Noura Howell
 * 
 * Description: 
 *  
 * The following code is a modification of the basic example of LED blinking using and Arduino
 * I have made the LEDs blink at a varying rate over time by using a for loop
 * 
 * Materials:
 * 
 * 1 Arduino Uno R3
 * 1 Breadboard
 * 1 LED
 * 5 jumper cables
 * 1 USB power cable
 * 
 * 
 */

 /*
  * Defining output pin
  */
int ledPin = 13;

/*
 * Writing the setup function to initialize the output pin to 13
 */
void setup() {
  pinMode( ledPin, OUTPUT);
}

void loop() {
  // writing a for loop to vary the duration for which the LED should blink
  for(int j =0; j<5;j++){
    int jVal = j*200;
    //writing high voltage to the digital output : 13
    digitalWrite(ledPin, HIGH);
    //modifying the delay based on the loop variable
    delay(1000-jVal);
    //writing low voltage to the digital output : 13
    digitalWrite(ledPin, LOW);
    delay(jVal);
  }
}
 

IMG_20160831_153346