Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Evelyn ShenDarren Shen
Published

Too Turnt Party Shirt

Are you ice cold or burning hot? Show off your drip and impress everyone at the function with a temperature adaptive color changing t-shirt!

BeginnerProtip20 hours61
Too Turnt Party Shirt

Things used in this project

Hardware components

FireBeetle ESP32-E IoT Microcontroller with Header (Supports Wi-Fi & Bluetooth)
DFRobot FireBeetle ESP32-E IoT Microcontroller with Header (Supports Wi-Fi & Bluetooth)
×1
Gravity: IO Shield for FireBeetle 2 (ESP32-E/M0)
DFRobot Gravity: IO Shield for FireBeetle 2 (ESP32-E/M0)
×1
Fermion: Multifunctional Environmental Sensor
DFRobot Fermion: Multifunctional Environmental Sensor
×1
distance sensor
×1
3V relay
×1
DC 12V Waterproof 1Ft Blue LED Strip
×1
DC 12V Waterproof 1Ft Red LED Strip
×1
Solder Seal Wire Connectors
×1
Wire Connectors
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Party shirt

Code

Party shirt

Arduino
Turn on/off LED depends on temperature sensor and distance sensor
#include "DFRobot_EnvironmentalSensor.h"

DFRobot_EnvironmentalSensor environment(/*addr = */SEN050X_DEFAULT_DEVICE_ADDRESS, /*pWire = */&Wire);

// defines variables
long duration;
int distance;

#define bluePin D7
#define redPin  D2
#define trigPin D12
#define echoPin D13

void setup()
{
  pinMode(bluePin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  
  Serial.begin(115200);
  while(environment.begin() != 0){
    Serial.println(" Sensor initialize failed!!");
    delay(1000);
  }
  Serial.println(" Sensor  initialize success!!");
}

void loop()
{
  //Print the data obtained from sensor
  Serial.println("-------------------------------");
  Serial.print("Temp: ");
  Serial.print(environment.getTemperature(TEMP_F));
  Serial.println(" ℉");
  
  Serial.println("-------------------------------");
  
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);

  //100.4
  if (environment.getTemperature(TEMP_F) < 100.4)
  { 
    //turn off red led and trun on blue led
    digitalWrite(redPin, LOW);
    digitalWrite(bluePin, HIGH);
    //blink the LED when people around you
    if (distance <= 50)
    {
      delay(100);
      digitalWrite(bluePin, LOW);
    }
  }
  else
  {
    //turn off blue led and turn on red led
    digitalWrite(bluePin, LOW); 
    digitalWrite(redPin, HIGH);
     //blink the LED when people around you
    if (distance <= 50)
    {
      delay(100);
      digitalWrite(redPin, LOW);
    }
  }
  
  delay(100);
}

Credits

Evelyn Shen
2 projects • 2 followers
i love coding! coding is awesome!
Contact
Darren Shen
4 projects • 3 followers
Pro Coder
Contact

Comments

Please log in or sign up to comment.