Overview:

A lamp used to indicate the moisture present in the air through color in order to prevent frequent nosebleeds and indicate that I should turn my humidifier on.

With a motion sensor, the lamp intended for my bedroom has two states in order to conserve electricity and provide suitable lighting for sleep and getting ready in the morning. Humidity level changes the color of the LED strips; an a rocker switch was also added to turn off the lamp completely when I am away from my apartment.

Overview Image

Detail Images:

Close up of hexagonal shape and acrylic panels

Light color depends on humidity level of the environment. Light changes in increments on the RGB scale. 1. Red Hue: 0-30% humidity level, 2. Pink Hue: 30-60% humidity level, 3. Purple Hue: 60-90% humidity level, 4. Blue Hue 90-100% humidity level

Two States of Lamp dependent on whether motion is sensed: Active displays humidity reading (left image) and idle (right image)

Rocker Switch and PIR motion sensor exposed on lower section of lamp

Two sections of lamp: Upper housing holds the LED strips and lower housing holds the battery, breadboard, and Arduino

 

ON/OFF rocker switch demonstration and motion sensor adjacent to switch

 

Motion detection when lamp is on either triggers the active state: displaying the humidity reading or if motion is not detected the idle state: a pale white color.

 

Opening demonstration of inner lamp components

 

Process:

Initial Idea Sketches

PIR motion sensor affecting an LED

I started the project with experimenting with the DHT sensor as well as the PIR sensor. Once I developed a basic understanding of the two sensors, I began to move on to fabrication of the physical piece.

Sketches exploring the construction and laser cut pieces of the lamp.

After sawing the angles on the laser cut pieces, I laid the half stained pieces down in order to test my cuts.

Fully stained wood pieces and bottom piece attached with tape. Experimenting with different materials for the top cap

At this point with most of my physical components completed, I decided to move onto the code. I had some difficulty with the map function and converting the humidity reading to an RGB scale with the LED strip. After asking for help, I moved on to the PIR sensor and rocker switch. I originally hadn’t intended to add the rocker switch; however, if I were to use this lamp I wouldn’t want to open the bottom section and unplug the battery every time I leave for an extended period of time.

Had a lot of difficulty with the LED colors changing based on humidity reading. Asked Zach for help (pictured on whiteboard!)

First time soldering experience with a rocker switch! Rocker switch turns lamp on and off to conserve energy

Figuring out dimensions of bottom pieces and decided to work with wood for the top cap

Discussion:

I was pretty satisfied with the overall result of the lamp, through this project I was able to grow more comfortable with coding and understanding how different inputs and outputs can influence each other. I was also thankful  for the opportunity to create something that I can used in everyday life that serves a purpose. I do wish that I had the time to create another physical prototype due to bad craft in some angled cuts and over-staining the wood. On the electronics side of things, I wish I could have incorporated pulsing with the lights in order to represent abnormally low humidity readings. I believe that incorporating a LCD display screen could also give some specifications to the moisture content in the environment.

From this project I learned that balancing the creating of both electronics and physical models is very important. Though this time I balanced both pretty efficiently, I do wish I had spent more time with the electronics side of the project because that’s the field I feel more uncomfortable with. My advice to my future self would be to understand more about C and learn all the capabilities of the sensors before starting on the physical prototypes.

From the critique my peers stated that the physical form was “very aesthetically pleasing” and an “interesting concept” in that I designed my own housing. They recommended I used a break beam so that when I walk in and out of the room the lamp could make sure that I was in the room. I would like to explore the use of the break beam because that seems like something that doesn’t require constant motion and seems to be more of a ON/OFF state while motion is more analog. I am also interested in exploring if there is a way for the humidity levels to change the lights more gradually, whether that is trying a new library or changing something in my code. Overall, this was a fun project to do and I definitely learned more about coding and some fabrication methods.

 

Schematic:

Wiring Diagram of Lamp

Code:

  1. <span class="com">/*
  2. Project Two: An Assistive Device for someone you know well
  3. Elena Deng, edeng1
  4. Designed a lamp used to detect the humidity of the room meant for me to prevent my chronic nosebleeds in winter.
  5. Code can be used to program a lamp that takes in the humidity reading through a DHT sensor and depending on whether motion is sensed in the PIR sensor, one of two LED states is activated. There is also a rocker switch used to turn the lamp on/off
  6. Sensors and switches used: DHT22, RGB LED strip, PIR Motion Sensor, Rocker switch
  7. Used the Pololu LED strip library, DHT sensor library, and Adafruit's
  8. https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/using-a-pir-w-arduino
  9. */</span><span class="pln">
  10. </span><span class="com">#include</span><span class="pln"> </span><span class="str">"DHT.h"</span><span class="pln">
  11. </span><span class="com">#define</span><span class="pln"> DHTTYPE DHT22
  12. </span><span class="com">#include</span><span class="pln"> </span><span class="str"><PololuLedStrip.h></span><span class="pln">
  13. </span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> DHTPIN </span><span class="pun">=</span><span class="pln"> </span><span class="lit">8</span><span class="pun">;</span><span class="pln">
  14. </span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> ledPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">13</span><span class="pun">;</span><span class="pln">
  15. </span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> inputPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span><span class="pln">
  16. </span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> buttonPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">5</span><span class="pun">;</span><span class="pln">
  17. </span><span class="kwd">int</span><span class="pln"> buttonState </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
  18. </span><span class="kwd">int</span><span class="pln"> pirState </span><span class="pun">=</span><span class="pln"> LOW</span><span class="pun">;</span><span class="pln">
  19. </span><span class="kwd">int</span><span class="pln"> val </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
  20. </span><span class="kwd">int</span><span class="pln"> ledState</span><span class="pun">;</span><span class="pln">
  21. DHT dht</span><span class="pun">(</span><span class="pln">DHTPIN</span><span class="pun">,</span><span class="pln"> DHTTYPE</span><span class="pun">);</span><span class="pln">
  22. </span><span class="com">//two ledStrips</span><span class="pln">
  23. </span><span class="typ">PololuLedStrip</span><span class="pun"><</span><span class="lit">12</span><span class="pun">></span><span class="pln"> ledStrip</span><span class="pun">;</span><span class="pln">
  24. </span><span class="typ">PololuLedStrip</span><span class="pun"><</span><span class="lit">11</span><span class="pun">></span><span class="pln"> ledStrip2</span><span class="pun">;</span><span class="pln">
  25. </span><span class="com">#define</span><span class="pln"> LED_COUNT </span><span class="lit">60</span><span class="pln">
  26. rgb_color colors</span><span class="pun">[</span><span class="pln">LED_COUNT</span><span class="pun">];</span><span class="pln">
  27. </span><span class="kwd">int</span><span class="pln"> lastHumid </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> </span><span class="com">// compares the last temperature of the loop</span><span class="pln">
  28. </span><span class="kwd">void</span><span class="pln"> setup</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  29. </span><span class="typ">Serial</span><span class="pun">.</span><span class="kwd">begin</span><span class="pun">(</span><span class="lit">9600</span><span class="pun">);</span><span class="pln">
  30. pinMode</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">,</span><span class="pln"> OUTPUT</span><span class="pun">);</span><span class="pln"> </span><span class="com">// declare LED as output</span><span class="pln">
  31. pinMode</span><span class="pun">(</span><span class="pln">inputPin</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln"> </span><span class="com">// declare sensor as input</span><span class="pln">
  32. pinMode</span><span class="pun">(</span><span class="pln">DHTPIN</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln"> </span><span class="com">//humidity sensor is an input</span><span class="pln">
  33. pinMode</span><span class="pun">(</span><span class="pln">buttonPin</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln"> </span><span class="com">//switch pin is an input</span><span class="pln">
  34. dht</span><span class="pun">.</span><span class="kwd">begin</span><span class="pun">();</span><span class="pln">
  35. </span><span class="pun">}</span><span class="pln">
  36. </span><span class="kwd">void</span><span class="pln"> loop</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  37. </span><span class="kwd">float</span><span class="pln"> h </span><span class="pun">=</span><span class="pln"> dht</span><span class="pun">.</span><span class="pln">readHumidity</span><span class="pun">();</span><span class="pln">
  38. </span><span class="kwd">int</span><span class="pln"> humidReading </span><span class="pun">=</span><span class="pln"> h</span><span class="pun">;</span><span class="pln">
  39. </span><span class="kwd">int</span><span class="pln"> humidity</span><span class="pun">;</span><span class="pln">
  40. </span><span class="com">//prints humidity level reading</span><span class="pln">
  41. </span><span class="typ">Serial</span><span class="pun">.</span><span class="kwd">print</span><span class="pun">(</span><span class="pln">F</span><span class="pun">(</span><span class="str">"Humidity: "</span><span class="pun">));</span><span class="pln">
  42. </span><span class="typ">Serial</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="pln">h</span><span class="pun">);</span><span class="pln">
  43. val </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">inputPin</span><span class="pun">);</span><span class="pln"> </span><span class="com">// read input value of motion sensor</span><span class="pln">
  44. digitalWrite</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">,</span><span class="pln"> val</span><span class="pun">);</span><span class="pln"> </span><span class="com">//if motion is sensed the led is HIGH and vice versa</span><span class="pln">
  45. ledState </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">);</span><span class="pln"> </span><span class="com">//reads whether the led on breadboard is on</span><span class="pln">
  46. buttonState </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">buttonPin</span><span class="pun">);</span><span class="pln"> </span><span class="com">//reads the state of the switch</span><span class="pln">
  47. </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="typ">uint16_t</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> LED_COUNT</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln">
  48. </span><span class="pun">{</span><span class="pln">
  49. humidity </span><span class="pun">=</span><span class="pln"> map</span><span class="pun">(</span><span class="pln">humidReading</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">);</span><span class="pln"> </span><span class="com">//change 0-100 scale of DHT sensor to 0-255 RGB scale</span><span class="pln">
  50. rgb_color red </span><span class="pun">=</span><span class="pln"> rgb_color</span><span class="pun">(</span><span class="lit">280</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> humidity</span><span class="pun">,</span><span class="pln"> </span><span class="lit">40</span><span class="pun">,</span><span class="pln"> humidity</span><span class="pun">);</span><span class="pln"> </span><span class="com">//range of colors of LED</span><span class="pln">
  51. rgb_color black </span><span class="pun">=</span><span class="pln"> rgb_color</span><span class="pun">(</span><span class="lit">20</span><span class="pun">,</span><span class="pln"> </span><span class="lit">20</span><span class="pun">,</span><span class="pln"> </span><span class="lit">17</span><span class="pun">);</span><span class="pln"> </span><span class="com">//idle state of LEDs</span><span class="pln">
  52. </span><span class="com">//turn on active state if motion is sensed and switch is on</span><span class="pln">
  53. </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">buttonState </span><span class="pun">==</span><span class="pln"> HIGH</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  54. </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ledState </span><span class="pun">==</span><span class="pln"> HIGH</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  55. colors</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> red</span><span class="pun">;</span><span class="pln">
  56. </span><span class="pun">}</span><span class="pln">
  57. </span><span class="pun">}</span><span class="pln">
  58. </span><span class="com">//turn off if motion is not sensed and switch is off</span><span class="pln">
  59. </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">buttonState </span><span class="pun">==</span><span class="pln"> LOW</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  60. </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ledState </span><span class="pun">==</span><span class="pln"> LOW</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  61. colors</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> black</span><span class="pun">;</span><span class="pln">
  62. </span><span class="pun">}</span><span class="pln">
  63. </span><span class="pun">}</span><span class="pln">
  64. ledStrip</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">colors</span><span class="pun">,</span><span class="pln"> LED_COUNT</span><span class="pun">);</span><span class="pln">
  65. ledStrip2</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">colors</span><span class="pun">,</span><span class="pln"> LED_COUNT</span><span class="pun">);</span><span class="pln">
  66. </span><span class="pun">}</span><span class="pln">
  67. lastHumid </span><span class="pun">=</span><span class="pln"> humidity</span><span class="pun">;</span><span class="pln"> </span><span class="com">//compare the humidity reading to last loop</span><span class="pln">
  68. </span><span class="pun">}</span>
<span class="com">/*
  Project Two: An Assistive Device for someone you know well
  Elena Deng, edeng1

  Designed a lamp used to detect the humidity of the room meant for me to prevent my chronic nosebleeds in winter.
 
  Code can be used to program a lamp that takes in the humidity reading through a DHT sensor and depending on whether motion is sensed in the PIR sensor, one of two LED states is activated. There is also a rocker switch used to turn the lamp on/off

  Sensors and switches used: DHT22, RGB LED strip, PIR Motion Sensor, Rocker switch

  Used the Pololu LED strip library, DHT sensor library, and Adafruit's
https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/using-a-pir-w-arduino
*/</span><span class="pln">

</span><span class="com">#include</span><span class="pln"> </span><span class="str">"DHT.h"</span><span class="pln">
</span><span class="com">#define</span><span class="pln"> DHTTYPE DHT22
</span><span class="com">#include</span><span class="pln"> </span><span class="str"><PololuLedStrip.h></span><span class="pln">

</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> DHTPIN </span><span class="pun">=</span><span class="pln"> </span><span class="lit">8</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> ledPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">13</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> inputPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> buttonPin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">5</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">int</span><span class="pln"> buttonState </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">int</span><span class="pln"> pirState </span><span class="pun">=</span><span class="pln"> LOW</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">int</span><span class="pln"> val </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">int</span><span class="pln"> ledState</span><span class="pun">;</span><span class="pln">

DHT dht</span><span class="pun">(</span><span class="pln">DHTPIN</span><span class="pun">,</span><span class="pln"> DHTTYPE</span><span class="pun">);</span><span class="pln">

</span><span class="com">//two ledStrips</span><span class="pln">
</span><span class="typ">PololuLedStrip</span><span class="pun"><</span><span class="lit">12</span><span class="pun">></span><span class="pln"> ledStrip</span><span class="pun">;</span><span class="pln">
</span><span class="typ">PololuLedStrip</span><span class="pun"><</span><span class="lit">11</span><span class="pun">></span><span class="pln"> ledStrip2</span><span class="pun">;</span><span class="pln">
</span><span class="com">#define</span><span class="pln"> LED_COUNT </span><span class="lit">60</span><span class="pln">
rgb_color colors</span><span class="pun">[</span><span class="pln">LED_COUNT</span><span class="pun">];</span><span class="pln">


</span><span class="kwd">int</span><span class="pln"> lastHumid </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">       </span><span class="com">// compares the last temperature of the loop</span><span class="pln">

</span><span class="kwd">void</span><span class="pln"> setup</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  </span><span class="typ">Serial</span><span class="pun">.</span><span class="kwd">begin</span><span class="pun">(</span><span class="lit">9600</span><span class="pun">);</span><span class="pln">
  pinMode</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">,</span><span class="pln"> OUTPUT</span><span class="pun">);</span><span class="pln">      </span><span class="com">// declare LED as output</span><span class="pln">
  pinMode</span><span class="pun">(</span><span class="pln">inputPin</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln">     </span><span class="com">// declare sensor as input</span><span class="pln">
  pinMode</span><span class="pun">(</span><span class="pln">DHTPIN</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln">       </span><span class="com">//humidity sensor is an input</span><span class="pln">
  pinMode</span><span class="pun">(</span><span class="pln">buttonPin</span><span class="pun">,</span><span class="pln"> INPUT</span><span class="pun">);</span><span class="pln">    </span><span class="com">//switch pin is an input</span><span class="pln">

  dht</span><span class="pun">.</span><span class="kwd">begin</span><span class="pun">();</span><span class="pln">
</span><span class="pun">}</span><span class="pln">

</span><span class="kwd">void</span><span class="pln"> loop</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  </span><span class="kwd">float</span><span class="pln"> h </span><span class="pun">=</span><span class="pln"> dht</span><span class="pun">.</span><span class="pln">readHumidity</span><span class="pun">();</span><span class="pln">
  </span><span class="kwd">int</span><span class="pln"> humidReading </span><span class="pun">=</span><span class="pln"> h</span><span class="pun">;</span><span class="pln">
  </span><span class="kwd">int</span><span class="pln"> humidity</span><span class="pun">;</span><span class="pln">

  </span><span class="com">//prints humidity level reading</span><span class="pln">
  </span><span class="typ">Serial</span><span class="pun">.</span><span class="kwd">print</span><span class="pun">(</span><span class="pln">F</span><span class="pun">(</span><span class="str">"Humidity: "</span><span class="pun">));</span><span class="pln">
  </span><span class="typ">Serial</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="pln">h</span><span class="pun">);</span><span class="pln">


  val </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">inputPin</span><span class="pun">);</span><span class="pln">  </span><span class="com">// read input value of motion sensor</span><span class="pln">
  digitalWrite</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">,</span><span class="pln"> val</span><span class="pun">);</span><span class="pln">  </span><span class="com">//if motion is sensed the led is HIGH and vice versa</span><span class="pln">
  ledState </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">ledPin</span><span class="pun">);</span><span class="pln">  </span><span class="com">//reads whether the led on breadboard is on</span><span class="pln">
  buttonState </span><span class="pun">=</span><span class="pln"> digitalRead</span><span class="pun">(</span><span class="pln">buttonPin</span><span class="pun">);</span><span class="pln">  </span><span class="com">//reads the state of the switch</span><span class="pln">

  </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="typ">uint16_t</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> LED_COUNT</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln">
  </span><span class="pun">{</span><span class="pln">
    humidity </span><span class="pun">=</span><span class="pln"> map</span><span class="pun">(</span><span class="pln">humidReading</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">);</span><span class="pln">  </span><span class="com">//change 0-100 scale of DHT sensor to 0-255 RGB scale</span><span class="pln">

    rgb_color red </span><span class="pun">=</span><span class="pln"> rgb_color</span><span class="pun">(</span><span class="lit">280</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> humidity</span><span class="pun">,</span><span class="pln"> </span><span class="lit">40</span><span class="pun">,</span><span class="pln"> humidity</span><span class="pun">);</span><span class="pln"> </span><span class="com">//range of colors of LED</span><span class="pln">
    rgb_color black </span><span class="pun">=</span><span class="pln"> rgb_color</span><span class="pun">(</span><span class="lit">20</span><span class="pun">,</span><span class="pln"> </span><span class="lit">20</span><span class="pun">,</span><span class="pln"> </span><span class="lit">17</span><span class="pun">);</span><span class="pln">  </span><span class="com">//idle state of LEDs</span><span class="pln">

    </span><span class="com">//turn on active state if motion is sensed and switch is on</span><span class="pln">
    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">buttonState </span><span class="pun">==</span><span class="pln"> HIGH</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
      </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ledState </span><span class="pun">==</span><span class="pln"> HIGH</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        colors</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> red</span><span class="pun">;</span><span class="pln">
      </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
    </span><span class="com">//turn off if motion is not sensed and switch is off</span><span class="pln">
    </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">buttonState </span><span class="pun">==</span><span class="pln"> LOW</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
      </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ledState </span><span class="pun">==</span><span class="pln"> LOW</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        colors</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> black</span><span class="pun">;</span><span class="pln">
      </span><span class="pun">}</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
    ledStrip</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">colors</span><span class="pun">,</span><span class="pln"> LED_COUNT</span><span class="pun">);</span><span class="pln">
    ledStrip2</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">colors</span><span class="pun">,</span><span class="pln"> LED_COUNT</span><span class="pun">);</span><span class="pln">
  </span><span class="pun">}</span><span class="pln">
  lastHumid </span><span class="pun">=</span><span class="pln"> humidity</span><span class="pun">;</span><span class="pln">   </span><span class="com">//compare the humidity reading to last loop</span><span class="pln">
</span><span class="pun">}</span>