Introduction: Twilight Switch Using Linkit One

Picture of Twilight Switch Using Linkit One

A twilight switch is the one which switches itself according to day and night. The amount of light falling on the LDR helps us to know whether it is day or night. You can also use it as a dark sensor. The is a led attached to it. When more light will fall on the LDR, led will glow more bright . This instructable will help you to make your own projects with LDR.

Step 1: Gather Parts

Picture of Gather Parts

Here are the parts required by you:

  • Linkit one
  • Breadboard
  • LDR
  • led
  • 10K ohms resistor
  • Jump cables

Step 2: Connecting the Photocell

Picture of Connecting the Photocell

A photocell or LDR is a device which is used to detect the amount of light. It increases its decreases its resistance when light is falling on it and increases it resistance when light is not falling on it. This increase ad decrease in the resistance is measured by the linkit one board and led will give output in respect to that. Here are its connection:

  • first pin of ldr-----linkit one vcc
  • second pin of ldr-----linkit one analog input A0
  • short gnd and analog input A0 of linkit one board using a 10K resistor

Step 3: Connecting the Led

Picture of Connecting the Led

To detect the output of the photocell, a led is used I could have used serial monitor of the board but the better option would be to use a led. The led is connect to PWM of the linkit one The input received by the photocell is converted into a output which is given out through PWM. Connect negative of led to gnd and positive of led to digital pin 3.

Step 4: Upload the Code

Here is a code by which you can check your project. Upload it to your board and using a torch, make some light fall on photocell and then switch off the torch. If the output in both the cases by the led is different then your project is working.

int photocell=A0;

int led=3;

void setup()

{

pinMode(photocell,OUTPUT);

}

void loop()

{

int value=analogRead(photocell);

value=map(value,0,1023,0,255);

analogWrite(led,value);

delay(50);

}

Step 5: END

Picture of END

This is the end of this instructable. Use it to detect day and night or to turn on and off your appliance. Hope you like it. For any query comment below.

Comments

audreyobscura (author)2015-12-03

It would be swell if you could include video of all these great things you are building, just as demonstration

I will try to do that.

About This Instructable

163views

3favorites

License:

More by kamlakant0903:Entry counterPresence Notifier With Push ButtonTheft protector using tilt sensor
Add instructable to: