Control an LED with the TEMT6000 ambient light sensor
FunduinoPublished on
Bei Dunkelheit eine LED automatisch einschalten
You need this
TEMT6000 light sensor - analog, 0-1000 lux, XH2.54 connector
4,59 € *Item no. F23108989About the product — TEMT6000 light sensor - analog, 0-1000 lux, XH2.54 connector
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
LED 5 mm - 100 Pieces, 5 Colors, 2 V
1,97 € *Item no. F23107316About the product — LED 5 mm - 100 Pieces, 5 Colors, 2 V
Resistor Assortment - 8 Values, 10 Pieces Each, 10 Ohms to 100 kOhms, ±5%
1,30 € *Item no. F23106603About the product — Resistor Assortment - 8 Values, 10 Pieces Each, 10 Ohms to 100 kOhms, ±5%
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
Breadboard cables male-female - 40 pieces, 20 cm
1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm
All 6 parts together 22,46 € *
* All prices include statutory VAT, plus shipping costs.
The TEMT6000 light sensor
The circuit diagram
The program
Switch an LED with the TEMT6000
int TEMT6000 = A0;
int LED = 8;
int DarknessThreshold = 30;
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop()
{
// Comment out lines 15 and 16
// once the desired value for "darkness" has been set
Serial.println("TEMT6000 reading: " + String(analogRead(TEMT6000)));
delay(500);
if (analogRead(TEMT6000) < DarknessThreshold)
{
digitalWrite(LED, HIGH);
}
else digitalWrite(LED, LOW);
}Rate the instructions