Wearable tech – Scarf – Jovana Ivanovic

Hey guys!
Sorry for the late post.. I had to make an entirely different project since the one I was working on was taking too much time/funds (HOWEVER, I will pursue it for the final project);Instead of making the scarf like I did/tried last time I decided to purchase this one to avoid the holes and messed up patch work (I need to work on my knitting..) What the scarf does is it has a photo resistor in it and it detects light; very simple code; if there is light the 2 led’s are off however in the absence of it they turn on!

The code:

int lightPin = 0;
int ledPin1=3;
int ledPin2=4;
void setup()
{
Serial.begin(9600);
pinMode( ledPin1, OUTPUT );
pinMode( ledPin2, OUTPUT );
pinMode( lightPin, INPUT );
}

void loop()
{
Serial.println(analogRead(lightPin));
if (analogRead(lightPin)> 400)
{
digitalWrite(ledPin1, HIGH);

} else {
digitalWrite(ledPin1, LOW);
}
delay(10);
Serial.println(analogRead(lightPin));
if (analogRead(lightPin)> 400)
{
digitalWrite(ledPin2, HIGH);

} else {
digitalWrite(ledPin2, LOW);
}
delay(10);
}

 

Comments are closed.