Output swatch

Swatch: LDR Light switch

For the output swatch I used this code:


 void setup() {
   Serial.begin(115200);
  pinMode(D2, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(D3, INPUT);
}

 
void loop() {
  int lichtSterkte = analogRead(A0);
  
  Serial.println(lichtSterkte);


  if (lichtSterkte <= 300) { 
    digitalWrite(D2, HIGH);
    
 Serial.println("Blauw licht");
 Serial.println("Donkere tint");
    delay(50);
    
  }
  
  if (lichtSterkte >= 350) { 
    digitalWrite(D3, LOW);
 
Serial.println("Groen licht");
 Serial.println("Lichte tint");
    delay(50);
     
  }
  
  
}

Needs for the output swatch:

  • LDR sensor

  • female - male connections

  • male - male connections

  • Arduino NodeMCU

  • Bread board

  • RGB LED

  • Black 10x10 paper

  • Backing paper

  • Copper tape

  • Soft ball

This is how I made the swatch:

  1. I used backing paper and cut it the same size as my black 10x10 cm paper..

  2. I made two holes with a scissor in the black paper for the LDR and the RGB LED.

  3. I taped the backing paper on the paper with copper tape, just for the look and feel.

  4. Put the soft and fluffy ball in the middle so people could push on a soft 'button'.

  5. Then I installed my NodeMCU in such a way that the LDR and the LED would fit into the holes. I made the connection cables longer by attatching them with a female-male cable.

  6. And run the code!

Installation details:

Last updated