luxmetre-couture.ino
The sewn LDR forms a divider with a resistor: the ADC value drops in the dark and the LED lights by itself. LilyPad references at 3.3 V, so the divider ties to 3.3 V, not 5 V.
Hardware required
A LilyPad Arduino (ATmega168V/328V, 8 MHz, 3.3 V) with its sew tabs, programmed via an FTDI cable (breakout) and powered by 3.7 V (LiPo) or 5 V on V-REG. 1 LDR + 10 kΩ resistor + 1 LED + 220 Ω, conductive thread and tape.
Wiring
LDR between 3V3 and A0, 10 kΩ between A0 and GND; LED + 220 Ω on pin 9.
How it works
The divider midpoint tracks ambient light; a threshold on the ADC value drives the LED. Calibrate SEUIL with the serial monitor. In the Arduino IDE, select « LilyPad Arduino » and the FTDI port, then Upload. Conductive thread adds a few ohms of resistance: keep runs short and insulate crossings.
Going further
Swap the LED for a buzzer for an audible cane, or add sleep to spare the battery.
luxmetre-couture.ino
// LDR sur A0 (diviseur avec resistance 10k vers 3,3V) + LED sur 9.
const int LDR = A0;
const int LED = 9;
const int SEUIL = 300; // a ajuster a la lumiere ambiante
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
int lumiere = analogRead(LDR);
Serial.println(lumiere);
digitalWrite(LED, lumiere < SEUIL ? HIGH : LOW);
delay(100);
}