Project tutorial
Sitting Sensor

Sitting Sensor © GPL3+

A pocket worn device that alerts you after staying sedentary for too long!

  • 8 respects

Components and supplies

Ard lilusb
Arduino LilyPad USB
98y9917 40
Battery, 3.7 V
Adafruit industries ada640 image 75px
Sewable Conductive Thread
Non-Conductive Thread
Non-Conductive Fabric
Pocket Clip
Find at local Michael's or Joann Fabrics
Adafruit industries ada1008 image 75px
Alligator Clips
For testing purposes.

Necessary tools and machines

Sewing Needle

Apps and online services

About this project


This project was created using the Lilypad USB Protosnap Plus as an introductory exploration into wearables and the capacities of the Lilypad board. I wanted to create something simple, but that could still have a beneficial function for a user. Because of trying to maintain simplicity, all of the parts used in this device are included in the original board, with no need to purchase other outside components.

The device is pocket worn, so the main board component goes inside the pocket, while the light sensor and LED(optional) sit on a flap on the outside of the pocket. When a user sits down, the light sensor is covered and will alert the user if they have not moved in a given period of time. The current code is set to 10 seconds, but this is just for testing purposes as it can easily be adjusted to 10-15 minutes or however long is desired. The benefits of a pocket worn device rather than incorporating the tech into one specific pocket is the versatility it allows and the fact that it can be worn on any pair of pants that has back pockets.

How To:

  • Coding the board.
  • Constructing the wearable.
  • Coding the Board

    The first step is properly coding the board before splitting it apart to make the wearable. The LED used in the code is mostly for testing purposes and gives you pretty clear feedback that the device is working properly, though it would work just fine if the lines regarding the LED are taken out or changed to a different LED.

    Important Notes: The code uses a time based check point (millis())so that the Lilypad board can multitask, rather than just relying on the delay() function. To learn more about millis() check out the Arduino reference page.

    Code Overview: The code itself starts by defining all of the integers. A few of the integers used can be changed for preference, including: the tone of the alarm note, the LED used, and the length of the sitPeriod time.

    After noting the inputs and outputs in the setup() the first chunk of code is meant to set up the Serial Monitor to read both the light sensor value and the currentTime, this helps with troubleshooting later in the process.

    In order for the code to work and recognize when to start counting time, a boolean was created to register if the user was sitting down. When the light sensor is reading a value of less than 80, the board understands the user to be sitting down and will appropriately change the boolean. To ensure that the sensor is working, when the light sensor value is greater than 80 the LED will be dimly lit giving clear feedback that the board is working.

    When the light sensor registers a value below 80, not only is the boolean sittingDown changed to true, but the current time is remembered as the SitPeriodStart to reference later in the code to know how long a user has been sitting. When a user has been sitting for longer than the assigned sit period designated in the beginning, an alarm() will sound (shown as the last function in the code). This alarm could be altered to any song or alert noise that can be created by the Lilypad buzzer.

    The if loops allow for the board to continually check if the user is sitting or not and maintain a track of how long they have been sitting for. This accounts for if a user stands up before the given sit period has gone by.

    Below is an example of the board working:

    Constructing the Wearable

    After the board has been properly coded, it's time to integrate it into a wearable. The example shown was just created with scrap fabric I had; I used denim for the pocket insert because it was stiff and sturdy providing a good base for the Lilypad board.

    The first step was to attach the main hub to the fabric using non-conductive thread. I used four small tacks to ensure it was secure on the fabric.

    After the hub was attached, I went through using conductive thread and sewed the LED, light sensor, and buzzer to the fabric connecting them to the appropriate ports and following the circuit schematics. It’s important to make sure none of the threads cross each other, otherwise the device will short circuit, make sure to plan out where each part will sit so there are no intersecting paths.

    Before closing the wearable, the battery was inserted to check if it was working and charged.

    This step is optional, but once everything was sewn, I added a back panel to enclose all of the tech and ensure the wires would intersect each other when the device was bent over the pocket.

    Here you can see the LED turning on an off as the light sensor is covered as well as how the alarm goes off when it has been covered a given period of time.

    The device can pretty simply be worn over the pocket as shown, so when choosing fabric, be sure to take into account which fabric will be visible outside of the pocket.


    Sitting SensorArduino
    This code is meant to send a buzzing alert if there hasn't been light for a given period of time;
    if there is light shining in the sensor, the alert will not go off.
    The intention is for someone who is sitting down to get alerts to move every so often.
    const int buzzer = A3;             //assigning buzzer pin
    const int lightSensor = A2;       //assigning light sensor pin
    int NOTE = 5000;                  //creating alarm buzzer tone
    const int sitPeriod = 10000;       //defining period allowed sitting before alert
    boolean sittingDown = false;      //setting up boolean to check sitting down condition
    unsigned long SitPeriodStart;  //creating value for start of sitting period
    unsigned long currentTime;
    void setup() {
      pinMode(lightSensor, INPUT);
      pinMode(buzzer, OUTPUT);
      pinMode(A7, OUTPUT);            //LED is used to check conditions and that code is working
    void loop() {
      int sensorValue;
      sensorValue = analogRead(lightSensor);      //defining and reading Light Sensor
      Serial.print("sensor value: ");             //setting up Serial Monitor to check light sensor value
      currentTime = millis();       //starting time
        if (sensorValue<80 && !sittingDown)
        sittingDown = true;
        SitPeriodStart = currentTime;
        digitalWrite(A7, LOW);
        else if (sensorValue>=80)
        sittingDown = false;
        analogWrite(A7, 1);
        if (sittingDown && (currentTime - SitPeriodStart >= sitPeriod))
        sittingDown = false;
    void alarm() {
        tone(buzzer, NOTE);
        tone(buzzer, NOTE);


    Screen shot 2019 10 21 at 11 gwhs9cpygu


    Similar projects you might like

    How to Make FLEX Sensor at Home | DIY Flex Sensor

    Project tutorial by Tech Nuttiez

    • 1 comment
    • 10 respects

    Automatic Fan with PIR Sensor and LM35 Sensor

    by Jamaluddin

    • 22 respects

    Touch Sensor and Sound Sensor Controlling AC/DC Lights

    Project showcase by Anbumachi

    • 8 respects

    Push-up Counter using Arduino and Ultrasonic Sensor

    Project tutorial by herolivechannel

    • 1 comment
    • 6 respects


    Project tutorial by SURYATEJA

    • 1 respect

    Tubolar Stretch Sensor Tutorial

    by Arduino_Scuola

    • 7 respects
    Add projectSign up / Login