![]() |
Simple light sensor connected to a Luminet2 board with conductive thread.
|
- + connected to power (VCC)
- - connected to ground (GND)
- S connected to an input pin (A0)
The code uploaded to Luminet2 lights the LED green when it becomes darker.
![](/files/migrated/images/wearables_LightSensor_working.png)
The code is written in the Arduino IDE and is uploaded to the Luminet2 board through a serial connection.
{CODE(colors="c")}
int greenLed=9; //the pin number for the Green LED
void setup() {
//inform the micro-controller that a sensor is connected to pin A0
pinMode(A0, INPUT);
//inform the micro-controller that an actuator (in our case the green LED) is connected to pin 9
pinMode(greenLed, OUTPUT);
}
void loop() {
if(analogRead(0)<100){
digitalWrite(greenLed, HIGH);//turns the green LED ON
}else{
digitalWrite(greenLed, LOW); //turns the green LED OFF
}
}{CODE}
See the Luminet2 with Arduino tutorial for how to reprogram Luminet2 with the Arduino IDE.