Kaiya Kedzierski
Published © GPL3+

Lane Tech HS-PCL-Smart Hair Straightener

A Hair Straightener with motion detection that will turn off after no movement for 5 minutes

IntermediateFull instructions provided3 hours38
Lane Tech HS-PCL-Smart Hair Straightener

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Single Channel 5V Relay Module
×1
Gravity: Digital Tilt Sensor for Arduino / Raspberry Pi
DFRobot Gravity: Digital Tilt Sensor for Arduino / Raspberry Pi
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1

Story

Read more

Schematics

Schematics

Code

Smart Hair Straightener Code

C/C++
This is the code that actually makes the straightener work
// Include Particle Device OS APIs
int led=7;
int tilt=2;
int currentValue=0;
int lastValue=0;
static int count = 0;
int relay=4;

//Timer:
SerialLogHandler logHandler;

Timer timer(1000, print_every_second);

void print_every_second()
{
    
    Log.info("count=%d", count++);
}


//https://build.particle.io/build/68e5bdb4dd3eb100dc2ea75a#verify
// setup() runs once, when the device is first turned on
void setup() {
    pinMode(led, OUTPUT);
    pinMode(tilt, INPUT);
    pinMode(relay,OUTPUT);
    Serial.begin(9600);
    timer.start();
    digitalWrite(relay, LOW);//relay ON at start
   
    
  // Put initialization like pinMode and begin functions here
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
    if(count<300)
    {
    currentValue=digitalRead(tilt);
    if (currentValue != lastValue) 
        {
       
        digitalWrite(led, HIGH);
        count=0;
        // Movement detected
        } 
    else 
        {
        digitalWrite(led, LOW); 
        
        // No movement
        }
        
    lastValue = currentValue;
    //delay(50); 
  
    }
    else
    {
    digitalWrite(relay, HIGH);//relay off
    Serial.print("Relay off");
    //count=0;
    }
}

Credits

Kaiya Kedzierski
1 project • 0 followers

Comments