Table of Contents

Fun with LDR Sensor and Quarky

Example Description
Learn about LDR (Light Dependent Resistor) sensor and its analog properties while creating a fun activity using Quarky.
Introduction

The LDR (Light Dependent Resistor) sensor is a renowned analog-type sensor that adapts its resistance according to surrounding light intensity. With its ability to fluctuate resistance based on light changes, the LDR plays a vital role in various light-sensing applications. Though typically designed as a two-pin sensor, it is also available as a three-pin module, offering enhanced features and versatility.

In this example, we embark on a fun activity using the LDR sensor and Quarky. Through this engaging experience, you will grasp essential concepts like analog and PWM signals, creating an exciting learning journey. So, let’s dive in and explore the wonders of LDR and Quarky together!

Circuit Diagram:

Code:

Follow these steps to implement the code using Pictoblox for Quarky and explore the behavior of the LDR sensor:

  1. Open Pictoblox and create a new file.
  2. From the board menu, select Quarky and connect it to Pictoblox.
  3. Add the “when flag clicked” event block into the scripting area.
  4. Create two variables named “brightness” and “LDR value” from the “my variables” category and set them both to 0.
  5. Add a forever loop to ensure continuous execution of the code.
  6. From the sensor palette of Quarky, drag the block read analog sensor () at pin () and the LDR value equal to the value of this block as shown below.
  7. Map this value to change the range from 0-4095 to 0-255 (0V-5V) and store the result in the “brightness” variable.
  8. Go to the Quarky palette and drag the “set PWM pin() output as()” block. Select D1 from the drop-down menu.
  9. Set the PWM value as the “brightness” variable.

 

With these steps, your script is complete, and Quarky is ready to interact with the LDR sensor.

Output:

Through this exciting project, you have learned about the LDR sensor, its analog characteristics, and how Quarky can control an LED based on the light intensity sensed by the LDR. Delve deeper into the concepts of analog and PWM signals, making your robotics journey even more captivating with Quarky! Stay curious and keep exploring the endless possibilities!