Twilight Switch Using Linkit One

Introduction: 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

Here are the parts required by you:

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

Step 2: 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

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()




void loop()


int value=analogRead(photocell);





Step 5: 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.

Tech Contest

Participated in the
Tech Contest

Be the First to Share


    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    2 Discussions


    5 years ago

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


    Reply 5 years ago

    I will try to do that.