Author Archives: clordia

Light up different LEDs under different light intensity

I built a little fun device with Arduino that uses a light sensor to detect how light the ambience is and lights up one of the LEDs accordingly. If it is bright in the surroundings the green LED will light, if it is dim the yellow LED will light and the red LED lights if it is completely dark.

Here is the circuit diagram for setting up the device

Image

Each LED has a wire connected to the UNO board to slot 9, 10, 11 individually, and the resistor and light sensor(photocell) all ultimately connect to the negative ground. Make sure they are all interconnected.

Below is the code with detailed comments:

// LDR reads the ambient light, and lights up one of the three LEDs,
//depending on how light the ambience is

#define LEDg 11
#define LEDy 10
#define LEDr 9
#define SENSOR 0

int val = 0;
int val_sensor = 0;

void setup() {

pinMode(LEDg, OUTPUT);
pinMode(LEDy, OUTPUT);
pinMode(LEDr, OUTPUT);
Serial.begin(9600);

//when plugged in, all the LED will light at first
digitalWrite(LEDg, HIGH);
digitalWrite(LEDy, HIGH);
digitalWrite(LEDr, HIGH);
delay(1000);
}

void loop() {
val = analogRead(0);

//print out the readings for light intensity from the sensor
Serial.println(val);

//default all the LED values to LOW so at first they won’t light

digitalWrite(LEDg, LOW);
digitalWrite(LEDy, LOW);
digitalWrite(LEDr, LOW);

 //bright surroundings light the green LED

if (val >= 500)
{
digitalWrite(LEDg, HIGH);
}

//medium light intensity, light the yellow LED
else if (val > 200)
{

digitalWrite(LEDy, HIGH);

}

//when the light intensity is VERY LOW, light the red LED
else
{

digitalWrite(LEDr, HIGH);
}

//set up the delay to 100 milliseconds so the LED respond to change in the light intensity faster
delay(100);
}

Color certain part of the photo

Want to make your photo fancier? Here is a little useful trick

This is the original image:

Image

If we want to color only the flower and make the rest black and white, it will look like this:

Image

 

 

Open the image and select ‘Pen Tool’ from the tool barImage, the select ‘Path’ from the function window at the topImage, and draw along the figure of flower like this

Image

 

press ‘CTRL+ENTER’ to select the area you just drew, and then press ‘CTRL+SHIFT+I’ to select the counterpart

Image

 

Duplicate the background layer to get background layer copy, then select ‘<Image –> Adjustments –> Hue/Saturation>, a window will pop up and enter the data like following

Image

 

Now your image will look like this:

Image

You are done for now, but if you want to further change the color of the flower, do the following:

press ‘CTRL+SHIFT+I’ to counter-select the flower part, and get the window for ‘Hue/Saturation’ again( A fast way to do this is to press ‘CTRL+U’)

If I want the flower in bright color, I will enter the data as following

Image

 

Notice the color of flower changed? Press ‘CTRL+D’ to cancel selection, and you are done!

Image

Making mirrored image

We also see fancy cosmetics commercials like this:

Image

 

 

 

Using photoshop makes the product looks more presentable, and you may find the trick is very useful in photo-processing. Wonder it is done? Here is the simple tutorial:

First, we need to set up the background, click ‘File –> New’, in the window popped up, entry the data

Image

Note the entry could be different depends on what size and background color you want, for the example above, we get a image like this:

Image

 

Open the target image, select ‘Magic Wand Tool’Image, click at the background , press ‘CTRL+SHIFT+I’ to select the counterpart

Image

 

Drag the selected image to the background image

Image

 

Use the same method to get the bottle image

 

Image

Now we want to make the mirrored images, selected ‘Layer 1’ and ‘Layer 2’ and duplicate them, and we get ‘Layer 1 copy’ and ‘Layer 2 copy’

Image 

Select these 2 copies of layers and press ‘CTRL + T’ to transform them,  right click on the image and select ‘Flip Vertical’, we get the image like this

Image

 

Adjust the opacity of this two copies of layer to 40%

Image

 

and we get the result image, YEAH~

Image

Change background of a photo

 

Changing background of a photo is an easy, fun trick of photoshop. Using Lasso Tool to extract necessary part of image is one basic skill of photoshop and it is extremely helpful in photo processing.

Suppose we have two separate pictures:

ImageImage

and this is how it looks in the end:

Image 

Wondering how it is done? Below is the detailed tutorial, the tools involved may come in handy in basic photoshop manipulating

First, open the two individual pictures in PS

Then select ‘Polygonal Lasso Tool‘ on the left side tool bar.(Note Polygonal Lasso Tool is in the sub menu of ‘Lasso Tool’)

Image 

Extract the image by clicking consecutively along the human figure, you may want to be as precise as possible, as following

Image

Move the selected image to the background picture, and scale it proportionately

Image  

Enlarge the pictures, notice the little area, obviously we need to get rid of that.

Image

Again, use Polygonal Lasso Tool to get the area and press ‘DELETE’ , the selected area will disappear and reveal the background

Image  

Press ‘CTRL+D’ to cancel selection, and then ‘CTRL+0’ to restore the original image size

Now, TAH-DAH~ You are done! Simple, right?

,Image