As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Friday, June 14, 2019

The Altar – Experimental Art Installation




The Altar is an experimental generative art installation that emphasizes time and place. By displaying a unique color visualization that changes from day to day and from space to space, the piece emphasizes here-and-now. The art and designs are unique to the surrounding of that moment in time, and can never be recaptured or recreated. 


Materials:

Arduino Uno
Breadboard
Seeed Humidity Barometer
Adafruit Ultimate GPS Breakout
SD card reader /microSD


Background/Initial Goals & Ideas:

At first we really were committed to a device that would be a fortune teller or track users entire day and output a "portrait of your day". The idea was that our device would clip onto your backpack and collect sensory data randomly throughout your day. The device would 'dock' back onto a port where the data would upload and print a visualization of your day. Having a mobile device that could easily transfer the sensors reads in a practical way quickly became quite the battle. After spending countless hours troubleshooting our SD, we transitioned towards a stationary device. We wanted the experience to be surprising as well as produce a printed takeaway. After searching the UW surplus we found the perfect furniture piece with a hole perfect for our button to fit through!





We used our Arduino to connect our Seeed humi barometer, Adafruit Ultimate GPS breakout, and our button together. Both the GPS and Humi/Barometer had a tremendous amount of data that we could potentially pull from them. We ended up focusing on GPS coordinates as well as humidity and temperature because we felt those were the most useful in framing a moment in time and space.

We had a tough time getting our sensors to work the way we needed out of the box. The first UNO we had was giving us funny reads and we ended up needing to swap it out for another mid-way through the project. The Adafruit ultimate GPS sensor was also giving us weird reads and would only connect outdoors. After inserting a watch battery, we found the GPS was able to get a fix much quicker and was able to remember the previous reads. Anyone looking to get the most out their GPS reader should invest in a battery, without it the reads are much less accurate and indoor use becomes near impossible.

The button was particularly tough to setup, as it required us to solder longer wires so that we could have the wires extend long enough to reach the hole on our housing. We laser cut a button plate which we strung the wires through and plugged into the breadboard below. The solder job was tough and required us to hot glue. The connection worked fine for awhile but quickly began short circuiting. 

The sensors were coded through Arduino, but our images were generated using a processing sketch we compiled which generated a square with a circle at its center. The outer square's color was represented through an RGB value connected to the humidity and temperature of that unique situation. The inner circle was generated by mapping the latitude and longitude to RGB values as well.

We knew early on we wanted to the final deliverable to be functional but also artful and ominous, so we decided to build in a 'key' which exposed how the design was being generated, and what senses were suggesting the outcome.

The final design was output to Automator, a built Mac app which allows users to automate specific task flows. In our case we had our piece upload to a folder on the desktop, which was then automated to send directly to a deskjet printer in the back of the room. 

Conclusion:

The project really opened our eyes to the possibilities of generative design and how coding could be used to help build design parameters. This is just a building block towards the possibilities of the collaboration between man and machine. We're excited to experiment with processing in the future and see how we could better create more complex and unique artwork with more sensing. 

Code:

Arduino


//GPS Libraries
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

//Environmental Libraries
#include "Seeed_BME280.h"
#include <Wire.h>

SoftwareSerial mySerial(3, 2);
Adafruit_GPS GPS(&mySerial);

BME280 bme280;

//Button Pin
const int buttonPin = 7;
boolean buttonState = 0; 



// If you're using a GPS module:
// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// If using software serial (sketch example default):
//   Connect the GPS TX (transmit) pin to Digital 3
//   Connect the GPS RX (receive) pin to Digital 2
// If using hardware serial (e.g. Arduino Mega):
//   Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
//   Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3

// If you're using the Adafruit GPS shield, change 
// SoftwareSerial mySerial(3, 2); -> SoftwareSerial mySerial(8, 7);
// and make sure the switch is set to SoftSerial



// If using hardware serial (e.g. Arduino Mega), comment out the
// above SoftwareSerial line, and enable this line instead
// (you can change the Serial number to match your wiring):

//HardwareSerial mySerial = Serial1;




// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences. 
#define GPSECHO  false

// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy

void setup()  
{
    
  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  //Serial.println("Begin");
  if(!bme280.init()){
    Serial.println("Device error!");
  }

  
  pinMode(buttonPin, INPUT); 

  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  
  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // uncomment this line to turn on only the "minimum recommended" data
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
  // the parser doesn't care about other sentences at this time
  
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  // For the parsing code to work nicely and have time to sort thru the data, and
  // print it out we don't suggest using anything higher than 1 Hz

  // Request updates on antenna status, comment out to keep quiet
  GPS.sendCommand(PGCMD_ANTENNA);

  // the nice thing about this code is you can have a timer0 interrupt go off
  // every 1 millisecond, and read data from the GPS for you. that makes the
  // loop code a heck of a lot easier!
  useInterrupt(true);

  delay(1000);
  // Ask for firmware version
  mySerial.println(PMTK_Q_RELEASE);
}


// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
  // if you want to debug, this is a good time to do it!
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;  
    // writing direct to UDR0 is much much faster than Serial.print 
    // but only one character can be written at a time. 
#endif
}

void useInterrupt(boolean v) {
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

uint32_t timer = millis();
void loop()                     // run over and over again
{
  // in case you are not using the interrupt above, you'll
  // need to 'hand query' the GPS, not suggested :(
  if (! usingInterrupt) {
    // read data from the GPS in the 'main loop'
    char c = GPS.read();
    // if you want to debug, this is a good time to do it!
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  
  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {
    // a tricky thing here is if we print the NMEA sentence, or data
    // we end up not listening and catching other sentences! 
    // so be very wary if using OUTPUT_ALLDATA and trytng to print out data
    //Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived() flag to false
  
    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another
  }

  // if millis() or timer wraps around, we'll just reset it
  if (timer > millis())  timer = millis();

  // approximately every x seconds or so, print out the current stats
  if (millis() - timer > 1000) { 
    timer = millis(); // reset the timer
    
    
    if (GPS.fix) {
       buttonState = digitalRead(buttonPin);
        
     
          Serial.print(buttonState);
          Serial.print(","); 
          Serial.print(GPS.latitudeDegrees, 3);
          
          Serial.print(","); 
          Serial.print(GPS.longitudeDegrees, 3);

          Serial.print(","); 
          Serial.print(bme280.getHumidity());
          Serial.print(","); 
          Serial.println(bme280.getTemperature());
          
         
          
          }
          else {
          Serial.print("");
          }
    }
  }

Processing



import processing.serial.*;
  
int s = second();
int m = minute();
int h = hour();
int d = day();
int mo = month();
int y = year();       // For saving a unique file name

float butt = 0;       // button pressed
float lat = 0;        // latitude value
float lon = 0;        // longitude value
float humi = 0;       // humididy in %
float temp = 0;       // temp in degrees C

int color1 = 0;
int color2 = 0;
int color3 = 0;
int color4 = 0;
        
//int middle;
//int edge;
float inter;
  
Serial mySerial;
PFont myFont;
int lf = 10;
String inString;
  
  
  void setup() {
  size(640, 360);
  background(255);
  noStroke();
  ellipseMode(RADIUS);

  //col1 = color(color1, color2, color4);
  //col2 = color(color3, color4, color4);
    mySerial = new Serial(this, Serial.list()[23], 115200);
    // don't generate a serialEvent() unless you get a newline character:
    mySerial.bufferUntil(lf);
  }


  void draw() {
  background(255);
  noStroke();
  
rectMode(RADIUS);  // Set ellipseMode to RADIUS
fill(color2,color3,color4);  // Set fill to white
rect(320, 180, 100, 100);  // Draw white ellipse using RADIUS mode

ellipseMode(CENTER);  // Set ellipseMode to CENTER
fill(color1,color2,0);  // Set fill to gray
ellipse(320, 182, 50, 50);  // Draw gray ellipse using CENTER mode


  textAlign(RIGHT);
  textSize(10);
  fill(color1,color2,0);
  text(lat + "°", 200, 270);
  text(abs(lon) + "°", 200, 280);
  
  textAlign(LEFT);
  textSize(10);
  fill(color2,color3,color4);
  text(humi + "%", 440, 270);
  text(temp + "°C", 440, 280);


textAlign(CENTER);
textSize(10);
fill(0);
text(y + "-" + mo + "-" + d + " " + h + ":" + m + ":" + s, 320, 310);

 if (butt == 1){
 save("/Users/elikahn/Desktop/autoprint/"+("test"+y+"-"+mo+"-"+d+"-"+h+"-"+m+"-"+s+".png"));    //Send to designated file on computer, Automator picks up slack
  delay(10000);
}
}

  void serialEvent(Serial mySerial) {
    // get the ASCII string:
    String inString = mySerial.readStringUntil(lf);

    if (inString != null) {
      // trim off any whitespace:
      inString = trim(inString);
      // split the string on the commas and convert the resulting substrings
      // into an integer array:
      float[] value = float(split(inString, ","));
      // if the array has at least four elements, you know you got the whole
      // thing.  Put the numbers in the color variables:
      if (value.length >= 5) {
        butt = value[0];
        lat = value[1];
        lon = value[2];
        humi = value[3];
        temp = value[4];
        
        color1 = int(map(lat, -90, 90, 0, 255));
        color2 = int(map(lon, -180, 180, 0, 255));
        color3 = int(map(humi, 0, 80, 0, 255));
        color4 = int(map(temp, 0, 40, 0, 255));
        
       } 
    } 
  }
  /*
  void drawGradient(float x, float y) {
  int radius = 150;
  
  for (int r = radius; r > 0; --r) {
    inter = map(r, 0, 150, 0, 1); 
    color c = lerpColor(col1, col2, inter); 
    fill(c);
    ellipse(x, y, r, r);
  }
}
*/
         

Luna – the relaxation pillow


Luna is an intelligent pillow that senses your stress by analyzing your pulse and helps you relax and even fall asleep by showing you a relaxing breathing pattern.







Background and user experience
The specific breathing pattern demonstrated by Luna is called the 4-7-8 breathing technique. Studies found that exercises aimed at controlling breath movement have a positive impact on heart rate variability, which correlates with stress (Chandla et al., 2013). Another review found that deep breathing led to better stress management, decreased fatigue and anxiety (Varvogli& Darviri, 2011). There are various devices available who guide your breathing through light display like the meditation lamp Breathe and apps like The Breathing App.

However, none of these devices register the user’s stress level and turn off automatically after the stress has subsided. This feature as implemented in Luna has multiple advantages for the user’s experience with the product. By using the pulse as indicator for the user’s stress level and varying the length of the exercise on the pulse, the user gets immediate feedback on how stressed their body actually is. This can be helpful in making the user aware of the hidden type of stress that can become chronic. As the user interacts with Luna as a ritual before going to bed, relaxing and deep breathing will become easier and the exercises will be shorter, resulting in a feeling of success and increased control and awareness of the user’s own body.

Electronics
Luna consists of only 5 electronic parts:

Additionally, we used power plugs, wires, a board and solder to connect all the parts together.
Then, we assembled everything and taped the components to a slim board to be put inside the pillow. We called it the “backbone”:

Backbone of the pillow


For the code, we used the pulse sensor library called “PulseSensorPlayground”.

The pseudo code looks like this (actual code can be found below):

If the sensor picks up a heart rate of above 60, the breathing pattern will start. When the pillow lights up, the user should breathe in. Then, the LEDs stay at their brightest intensity, which means the user has to hold their breath. When the LEDs fade from bright to dark, the user can exhale. Once this pattern ends, the sensor will pick up the next heart rate. If the heart rates drops under 60, the LEDs will fade quickly three times, signalling the end of the breathing exercise.

Form factor
We decided to use a light, soft beige pillow case. To make the pillow soft and comfortable enough to fall asleep on, we stuffed it with polyester between the electronics and the pillow cover, so the user does not feel the electronics while hugging the pillow and concentrating on relaxing. 

Polyester inside the pillow to cover LEDs and backbone


The LEDs shine through the pillow case, making it easy for the users to sense the fading lights even with their eyes closed. We aimed to provide users with a comfortable, fluffy experience fitting to the relaxation experienced through breathing, without the pillow being perceived as “cute” so users with many different characteristics, male, female, old, young people feel invited to use it.



We wanted the heart rate sensor to feel just as comfortable as the pillow itself rather than clinical, so we sowed a blue fabric over the Velcro strap that came with the pulse sensor. The sensor is placed in a corner of the pillow, which makes it comfortable for right and left-handed users to hug the pillow while laying on their side on a bed.


Conclusion
During this project, we learned some practical lessons on electronics and material, like how building the circuit on a breadboard first and soldering only after the circuit is confirmed to work might save valuable time. Moreover, diffusing LED light with polyester works, however stitching it firmly to the LEDs and pillow is important and strategic placement rather than quantity of the filling is crucial.

Finally, what we learned was that even with a basic understanding of electronics we could still create a compelling first prototype of a product, that does not only look good but also works based on a fairly simple code and few electronic parts.



Actual code

#define USE_ARDUINO_INTERRUPTS true  // Set-up low-level interrupts for most accurate BPM.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library. 

//  Variables
const int PulseWire = 2;       // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
                               // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
                               // Otherwise leave the default "550" value.
int delayEnd= 20;
int delayBTD = 64;
int delayDTB= 40;
int delayB= 1000;
int delayShort = 4;
long previousMillis = 0;
                             
PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
int led = 3;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is


void setup() { 

  Serial.begin(9600);          // For Serial Monitor
    pinMode(led, OUTPUT);

  // Configure the PulseSensor object, by assigning our variables to it.
  pulseSensor.analogInput(PulseWire); 
  pulseSensor.setThreshold(Threshold); 

  // Double-check the "pulseSensor" object was created and "began" seeing a signal.
  if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.
  }
}



void loop() {

 int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".
                                               // "myBPM" hold this BPM value now.

 Serial.println("We created a pulseSensor Object !");

 
   if (pulseSensor.sawStartOfBeat()) {            // Constantly test to see if "a beat happened".

          if (myBPM > 60 && myBPM < 120) {                   
                                        analogWrite(led, brightness);
                                        while (brightness <240) {
                                              brightness++;
                                              analogWrite(led, brightness);
                                              unsigned long startTime = millis();
                                              unsigned long currentTime = millis();
                                              while(currentTime - startTime < delayDTB) {
                                                // save the last time you blinked the LED
                                                currentTime = millis();
                                              }
                                        }
                                   
                                        while (brightness >0) {
                                              // dim bright to dark for 8 seconds
                                              brightness--;
                                              analogWrite(led, brightness);
                                              unsigned long startTime = millis();
                                              unsigned long currentTime = millis();
                                              while(currentTime - startTime < delayBTD) {
                                                 // save the last time you blinked the LED
                                                 currentTime = millis();
                                              }     
                                   
                                        }
                                   
          } 
       
          if (myBPM < 60 && myBPM > 40) {
                                for (int i=0;i<3; i++) {
                                        analogWrite(led, brightness);
                                        while (brightness <240) {
                                              brightness++;
                                              analogWrite(led, brightness);
                                              unsigned long startTime = millis();
                                              unsigned long currentTime = millis();
                                              while(currentTime - startTime < delayShort) {
                                                // save the last time you blinked the LED
                                                currentTime = millis();
                                              }
                                        }
                                   
                                        while (brightness >0) {
                                              // dim bright to dark for 8 seconds
                                              brightness--;
                                              analogWrite(led, brightness);
                                              unsigned long startTime = millis();
                                              unsigned long currentTime = millis();
                                              while(currentTime - startTime < delayShort) {
                                                 // save the last time you blinked the LED
                                                 currentTime = millis();
                                              }     
                                   
                                        }
                                }
              while(true) {}
          }
   }


}

Thursday, June 13, 2019

Dama— The Smart Plant Translator

Designed and Coded by Ian Yu and Emma Switzer





Overview:  

We began our process hoping to notify the plant owner in some way when and how to care for their plant. Our goal is to translate complex information outputs from the plants to simple light visualizations that humans can easily understand. This smart planter uses an Arduino and various sensors to improve the relationship between plants and their caretakers.


Soil Moisture Sensor— Brightness control

Soil moisture sensor monitors the soil moisture level and notifies the user when the soil is dry and the plant needs to be watered. The sensor directly affects the brightness of the NeoPixel lights. When the soil moisture level drops below a certain level, the sensor will “turn on” the flash function to make the NeoPixel flash. The flashing NeoPixel Light is designed to better capture caretakers attention to remind them to water their plant.


Temperature and Humidity Sensor— Color and light visuals control

The Temperature and Humidity sensor monitors the room temperature and humidity level in the atmosphere. Based on the data input, the sensor then determines the color output of the NeoPixels. In normal room temperature, the Neopixel will display a natural light pattern (yellow-ish). However, it also responds differently when the room temperature is too hot and the Neopixels will display cooler colors ( blue and aqua). If the room is too cold, the Neopixels will display warmer colors (red and orange). This function is designed with the intention that the planter provides visual comforters for the caretaker in an uncomfortable environment. (Too hot or too cold)


Capacitive Sensor— Motion control

The capacitive sensor mainly monitors the proximity of the caretaker to the planter. When the caretaker is close to the planter, the Neopixel light speeds up the current light animation to make it more lively. This function is designed to make the planter truly interactive and bring the plant to life by communicating back to the user and acknowledging the presence of the caretaker.   





The Design and Making of the Physical Planter:

The base and shell of dama is made from an Elm tree. The wood was acquired at Second Use, a local salvage shop, and was cut and glued to make a cube. After drying, the cube was rounded to become a cylinder and mounted on a lathe. The interior and exterior were both done on the lathe and was later sanded, cut, and finished. The lights are projected through ¼” cast acrylic that has been sanded to give a cloudy appearance and diffuse the light.


Process Photo:

Planter with all sensor and Arduino installed.

Making the planter 

laser cut acrylic

sanding the acrylic 

Hero Shot

Hero Shot





Libraries Used:
#include <FastLED.h>  // this is the library for LED lights
#include <dht.h>           // this is the library for DHT Temperature and Humidity Sensor
#include <CapacitiveSensor.h> // this is the library for Capcitive sensing.




Code:

// this is the set up for the LED
#include <FastLED.h>

#define LED_PIN     6 //digital read number
#define NUM_LEDS    10 // number of LEDS
#define BRIGHTNESS  200 // brightness from 0-256
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 50

CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;

//this the set up is for temperature and humidity sensor

#include <dht.h>
#define dht_apin A0
dht DHT;

// this is the set up is for soil moisture sensor
const int AirValue = 582;   //you need to replace this value with Value_1
const int WaterValue = 333;  //you need to replace this value with Value_2
int intervals = (AirValue - WaterValue)/3;
int soilMoistureValue = 0;

// this is the set up for cap sensor
#include <CapacitiveSensor.h>
CapacitiveSensor cs_7_8 = CapacitiveSensor(7,8); //10M Resistor between pins x and y
unsigned long csSum;

int speedS = 2;

//-------------------------------------------------------------------------------

void setup() {
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );

  

}

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
   uint8_t brightness = 200;
   
   for( int i = 0; i < NUM_LEDS; i++) {
       leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
       colorIndex += 3;
       
   }
}

//----------------------------------------

void loop() {

//this section is for the LED light
  currentBlending = LINEARBLEND; //cause the light to fade.
  CRGB yellow = CHSV( 60,255, 255);
  //CRGB green  = CHSV( HUE_GREEN, 255, 255);
  CRGB black  = CRGB::Black;
  CRGB orange = CHSV(70,255,200);
  CRGB red = CHSV(35,255,200);
  CRGB redish = CHSV(45,255,200);
  CRGB blue = CHSV(130,255,200);
  CRGB aqua = CHSV(118,255,200);
  


//   
 currentPalette = CRGBPalette16( orange,  orange, black, black,
                                yellow, yellow, black, black,
                               orange, orange, black, black,
                                yellow, yellow, black, black );


     //declare the sensors
     DHT.read11(dht_apin);
     soilMoistureValue = analogRead(A1); //put Sensor insert into soil
        // this is to check if the sensor works or not
                 DHT.read11(dht_apin);
//                    Serial.print(DHT.humidity);
//                    Serial.print("% ");
//                    Serial.print( DHT.temperature);
//                    Serial.println("C ");
//                    //delay(500);

    // for temperature and humidity of the lamp.
     if ( DHT.humidity > 75  || DHT.temperature > 30) {
     // insert LED color function
                 currentPalette = CRGBPalette16( blue,  blue, black, black,
                                      aqua, aqua, black, black,
                                     blue, blue, black, black,
                                     aqua, aqua, black, black );

                       
         
             static uint8_t startIndex = 0;
             startIndex = startIndex + speedS ; /* motion speed */
             
             FillLEDsFromPaletteColors(startIndex);
             FastLED.delay(3000/ UPDATES_PER_SECOND);

     }

           
     else if (DHT.humidity < 45 || DHT.temperature < 15 ) {
       currentPalette = CRGBPalette16( red,  red, black, black,
                                              redish, redish, black, black,
                                             red, red, black, black,
                                             redish, redish, black, black );
       
                                     
                   static uint8_t startIndex = 0;
                   startIndex = startIndex + speedS; /* motion speed */
                   
                   FillLEDsFromPaletteColors(startIndex);
                   FastLED.delay(3000 / UPDATES_PER_SECOND);  

       
     }
     
     
     
     
     else {

          currentPalette = CRGBPalette16( orange,  orange, black, black,
                                  yellow, yellow, black, black,
                                 orange, orange, black, black,
                                 yellow, yellow, black, black );

                         
           static uint8_t startIndex = 0;
           startIndex = startIndex + speedS; /* motion speed */
           
           FillLEDsFromPaletteColors(startIndex);
           FastLED.delay(3000 / UPDATES_PER_SECOND);    
                                     
     
     }

     

//for soil misoture sensors
    if(soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
    {
      // This means the plant is VERY WET, so the LED will be really bright for a sec
      FastLED.setBrightness(255);
      }

      else if(soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
      {
       // ths means the soil is Wet, so the LED is normal bright.
       FastLED.setBrightness(200);
       }

       else
       {
        //This means the soil is DRY, so the LED will flash to reminder the user to water the plant.
         FastLED.setBrightness(150);
            FastLED.show();
            delay(150);
            
            FastLED.setBrightness(50);
            FastLED.show();
            delay(150);

        }
           
         
 CSread();
      
      FastLED.show();
     }


void CSread() {
 
   long cs = cs_7_8.capacitiveSensor(100); //a: Sensor resolution is set to 80
 if (cs > 100) { //b: Arbitrary number  
   csSum += cs;
  
   if (csSum >= 20000) //c: This value is the threshold, a High value means it takes longer to trigger
   {
     speedS = 12;
    
     //if (csSum > 0) { csSum = 0; } //Reset
     //cs_7_8.reset_CS_AutoCal(); //Stops readings
   }
 } else {
   csSum = 0; //Timeout caused by bad readings
   speedS = 2;
 }
}
 

//---------------------------------------------------------------