Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
Lightsensor.ino
1/*
2 Light Sensor Example
3
4 This example demonstrates how to use the LightSensor class from the TKJHAT library to read light intensity values and print them to the Serial Monitor.
5
6 Circuit:
7 - Light sensor integrated in Pico HAT
8
9 created 2026
10*/
11
12#include "TKJHAT.h"
13
14// Create an instance of the TKJHAT class
15TKJHAT hat;
16
17// Initialize the light sensor and set up serial communication
18void setup() {
19 Serial.begin(9600);
20 hat.lightSensor.begin();
21}
22
23// This loop continuously reads the light intensity from the sensor and prints it to the serial monitor every second
24void loop() {
25 uint32_t lux = hat.lightSensor.readLight();
26 Serial.println("Light: " + String(lux) + " lx");
27 delay(1000);
28}
Main interface for accessing TKJHAT board features.
Definition TKJHAT.h:35
void begin()
Initialize all peripherals on the HAT Also initializes the default I2C bus for sensors and display.