01 - TK20 Ambient Light

<div class='markdown-content'># Overview **Unleash the power of light in your projects with the Lonely Binary TinkerBlock TK20 Ambient Light Sensor!** This compact and intuitive module is your gateway to creating smart devices that react to their environment. Whether you're building automated lighting systems, intelligent displays, or interactive art installations, the TK20 provides the crucial "eyes" your project needs to perceive ambient light levels. Designed for seamless integration with popular microcontrollers like Arduino, ESP32 and Raspberry Pi, the TK20 simplifies the process of light detection. Its analog signal output means you get a smooth, continuous reading of light intensity, allowing for nuanced control and responsive applications. With its straightforward pinout (GND, VCC, and Signal), you'll be up and running in no time, ready to illuminate your ideas. ![](images/Pasted%20image%2020250730072055.png) > Analog. When the ambient light is brighter, the analog value (voltage) on the Signal pin becomes larger. Conversely, in darker conditions, the analog value will be lower. # Pinout | Pin | Function | | ------ | ------------- | | GND | Ground | | VCC | VCC | | NC | Not Connected | | Signal | Analog | # Dimensions ![](images/Pasted%20image%2020250718162113.png) # Components ## Ambient Light 1206 SMD Sensor It is a phototransistor. This is a type of transistor where the base current is generated by light striking its sensitive area. The more light that hits it, the more current flows through its collector-emitter junction. The light-sensitive component is integrated into a simple circuit (often with a fixed resistor) to form a voltage divider. # Sample Code ```C++ // Define the analog pin connected to the TK20 Ambient Light Sensor's Signal pin. // Using a descriptive constant makes the code more readable and maintainable. const int lightSensorPin = A0; void setup() { // Initialize the serial communication at a baud rate of 9600. // This allows the Arduino to send data (light sensor readings) back to your computer's Serial Monitor. Serial.begin(9600); // Configure the specified analog pin as an INPUT. // Although analog pins are implicitly inputs, explicitly setting pinMode is good practice. pinMode(lightSensorPin, INPUT); } void loop() { // Read the analog value from the light sensor pin. // The analogRead() function converts the analog voltage (0-5V) into a digital value (0-1023). // As per the TK20's behavior, a brighter environment will result in a higher analog value. int lightValue = analogRead(lightSensorPin); // Print the read analog value to the Serial Monitor. // This allows you to observe the light intensity readings in real-time. Serial.println(lightValue); // Introduce a small delay to prevent the Serial Monitor from being overwhelmed with data // and to make the readings more readable. Adjust this value as needed. delay(100); } ``` # Product Link For product support, manuals, tutorials, and sample code, please visit our product page to access comprehensive resources. [https://lonelybinary.com/products/tk20](https://lonelybinary.com/products/tk20) # Support If you encounter any issues, please go to [https://lonelybinary.com ](https://lonelybinary.com ) and click the Support button located in the bottom right corner. Our team is ready to assist you. [![Technical Support](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20250527102623_4e41083f-a1d3-412d-a78f-9cb11ecf69e5.png?v=1754008493)](https://lonelybinary.com) # Thank You Thank you for choosing TinkerBlock to fuel your passion for STEM! Whether you’re a student diving into coding, an educator shaping future innovators, a hobbyist bringing your vision to life, or a business seeking cutting-edge solutions, TinkerBlock empowers you to create, learn, and innovate. **For school orders, wholesale inquiries, or custom business solutions, please contact us to discuss your specific needs.** [office@lonelybinar.com](office@lonelybinary.com) > **Unleash Your Creativity with TinkerBlock – Where Coding Meets the Real World!**</div>