Week 19

Project development


For my final project I’m planning to make a Smart clock that shows both the local time (Indian Standard Time, IST) and the time where my sister lives, New Jersey(Eastern Standard Time, EST). My idea is to give it to my mother who always has trouble calculating what time it is at my sister’s house, so she can call them. During the course of the academy I have done some parts of the project in a spiral model, just like what Neil asks us to do.

My Project Plan


Given above was my original project plan, However none of it worked out the way I wanted it to. COVID 19 lockdowns disrupted all the schedules and I got hardly a week to finish the projects while doing other weekly assignments. So I had to come up with a new plan. Before going into remade plan, Here is a recap of everything that worked out related to project over the weeks.

Here is the work I have done so far:

Week 1: Principles and Practices

This week I proposed my project idea - Smart Clock and decided a rough idea of the features that needs to be included. As I plan to give it to my mother I also considered some features that might be helpful for her like a night lamp. The switching between time zones is controlled by movement which is also for the ease of use for my mom.
My local instructors gave me an idea that I might have to get the real time through a wifi module.



Know more ->
Did it work: Yes
I defined my project idea which was useful for me later on to choose the assignments.

Week 3: Computer Aided Design

This week I learned 2D designing and made a logo for my clock using the free software, Krita.
I learned 3D designing and made a rough design of my smart clock using the education license of Autodesk Fusion 360.



Know more ->
Did it work: Yes
Although I did not use the logo as I changed the name later, I used the same base design and expanded on it.

Week 10: Input Devices

In my initial idea of the smart clock, it shows local time and changes to EST when a hand gesture is detected by the clock. So I need a sensor that detects the movement. I considered various sensors like PIR sensor, Ultrasonic Sensor, LIDAR etc and decided that Ultrasonic sensor is the best suited for my project.


Know more ->
Did it work: Yes
I tested the Ultrasonic sensor and it was successful in detecting the movement and measuring the distance from the object. I created a program that shows the presence of humans at various distances. So now I can use this program to swap the time zone when the distance of the movement is within 10 cm(ie, considering it to be a hand gesture to control the clock) otherwise it simply switches on the night light.

Week 11: Applications and Implications

This week, I checked out all previous projects related to clocks and timing done by fab academy students. I also checked Kickstarter projects and found two that interested me. I was able to further define my project and considered all the materials that I might require like the size of the plywood sheet and the electronic components available in the inventory and those that needed to be bought from the shop outside.
Know more ->
Did it work: Yes
I got a better understanding of the parts required for my clock and the processes that will be involved in making it. I realised that I will need a stepper motor to control the movement of the arms of the clock, and that I need the control of the light based on the presence of humans.

Week 12: Output Devices

This week I used a stepper motor, NEMA 17 and controlled it using a stepper motor driver, Pololu A4988. I tried out multiple programs that can help in my final project like moving the motor clockwise, moving it anticlockwise, changing direction using the limit switch.






Know more ->
Did it work: Partially
I learned the working of the stepper motor and I also learned how to control it using a stepper motor driver. However, I realised that I needed a smaller Stepper Motor that fits into my clock rather than the bulky NEMA 17. But I was successfully able to code various programs that might come in handy for my final project.

Week 14: Embedded Networking and Communications

This week, I tried working on the controlling of light using the input from the ultrasonic sensor. I used I2C communication for this. I used the same board from my input week.


Know more ->
Did it work: No
Although the assignment was successful, it is not useful in terms of my final project as I’m planning to use just one board only for the smart clock.

Week 18: Invention, Intellectual Property and Business Models

This week I learned about various project licenses and decided on one that matches my requirement. I chose Creative commons License and used it on the project slide that I prepared in GIMP. I also learned openshot and made a rough cut of my project video.

Creative Commons License
Time Keeper by Anooj Jacob is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


Know more ->
Did it work: Yes
I could make a rough cut of my project video.


My Plan to finish the project:

I plan to present the project before Neil on July 22. I have hardly 1 week left to finish the project. Now my plan is to finish the design first . While designing I will finish the mechanism first so I can give it for 3D printing overnight and then do the Clock design. This will give me ample time to redo the 3D printing in case it doesn’t work. and cut the 12mm thick plywood for Clock Face on ShopBot. I already bought most of the necessary electronic components and the only one remaining is the mini Stepper Motor, which I’m planning to buy during the weekend. Next I have to finish the electronic design, and which should be fairly simple as I have already tested out most of the parts. Once the PCB is designed I can mill it on Roland Modela. Next I have to assemble the clock and test out the programming part.

New Project Plan


I used a Gantt chart to visually display the schedule of my tasks, as it clearly shows parallel and serial tasks



Project Development Week

This section is about designing, manufacturing, electronics and programming of the smart clock the "TIME KEEPER"

DESIGNING

I had two options in front of me, Either make a digital clock or an analog one. Even though the making side of a digital clock is easy, I chose the analog type because my parents are used to analog clocks and also it'll be a unique one.

First of all I designed the front face and the casing for the mechanism.


I then placed the mini stepper motor for the hour needle, and then designed and postioned the spur gears to link the hour needle to the motor.


I designed a pin that can travel through the hour gear, so that I can fix the minute gear and minute needle to this pin.


Gave slots to the hour and minute pins for fixing the needles tightly.


Then I designed and positioned the minute gears and the minute motor.


Placed the limit switches for the hour and minute gears.


Found a place for the ciruit board and desinged it, also gave legs to hold the pcb.


Placed the ultrasonic sensor module and made holes for the transmitter and the reciever.



Made a lock, so that the whole mechanism will be firmly held in position.


My mother used to wake up nigth for water or to go to toilet, so I thought of adding a night light on the clock. Made a grove for neopixel strips and placed acrylic around it. This light can also be used for showing the daylight.


Added the numbers on the clock face and placed the needles.


Final design of the clock





ELECTRONICS

Soc / Microcontroller Module

As per my requirement I wanted WiFi connectivity and 16 pins for connecting all the components of the clock. ESP32-WROOM-32 satisfied all my needs and it was available in our lab inventory. Moreover ESP32 have Dual-Core processor so that I can run program for fetching and setting the time using 1st core and the program for sensing and lighting using the 2nd core. The advantage of doing so is that the Time will be always correct because the processing time of one program doesnt interfere the other.
Click the link to know more about ESP-32 https://randomnerdtutorials.com/getting-started-with-esp32/


Motor Driver

I used A4988 Pololu as the stepper motor driver. This module is cheap and efficient enough to serve my needs and it was available in our lab invetory.
I have used this module for the assignment in the OUTPUT DEVICES week.
Click on the link to know more about A4988 Pololu https://www.pololu.com/product/1182.


Stepper Motor

I used 28BJY-48 unipolar mini stepper motor. This stepper is small so that I can place it in my clock's casing and have enough torque to rotate the needle. Click on the link to know more about the stepper motor https://components101.com/motors/28byj-48-stepper-motor.


28BJY-48 mini stepper motor is a Unipolar stepper motor and the A4988 Pololu motor driver only support Bipolar stepper motor. so I converted this motor to Bipolar motor. Watch the tutorial video.


Sensing Module

I used a HCSR04 Ultrasonic Sensor as the sensing module. It is a cheap and commonly used type of ultrasonic sensor.
I have used this sensor for my INPUT DEVICES week assignment.


Power Supply

I used a 9V-2amps smps adapter to power the clock. Why I chose 9V supply is because the stepper motor requires 9V to function properly. I used a 5V voltage regulator to step down the voltage to 5V for powering up the motor driver, ultrasonic sensor and the neopixel strip. I also used a 3.3V voltage regulator to step down the voltage to 3.3V to power up the ESP32 microcontroller.


PCB DESIGNING

I used Autodesk Eagle for designing the circuit board. First I designed the circuit for power distribution.

POWER SUPPLY UNIT

The VCC line carry 9V and it is supplied to the motors. The VCC_5V line carry 5V and it is supplied to the motordrivers, ultrasonic sensor and neopixel strip. The VCC_3.3V line carry 3.3V and it is supplied to the ESP32 microcontroller.

Each pin of the ESP32 have some dedicated functions. Click on the link to understand more about the ESP32 pins https://randomnerdtutorials.com/esp32-pinout-reference-gpios/

After understanding the functions of each pins, I made a schematic design of the circuit board.

PCB SCHEMATIC


I made the board desing by placing all the components and routed all the connection.

PCB BOARD


PCB MILLING AND SOLDERING

I used 1/64 bit for milling the traces and 1/32 bit for milling the holes and the outline of the board. You can find more details about PCB milling in my ELECTRONICS PRODUCTION week.


Then I soldered all the components on to the board.


MANUFACTURING

Manufacturing processes involved in this project are:
  • 3D Printing
  • Laser cutting
  • Sand Blasting
  • CNC Milling

3D PRINTING

The following are the parts to be 3D printed.








LASER CUTTING

The following are the parts to be Laser cut.


SAND BLASTING

The acrylic strip placed around the neopixel need to be sand blasted to get a brushed texture, so that the light passing throung it will get disperssed.


After sand blasting


CNC MILLING

The face of the clock is to be milled using the CNC router.


I used a 3mm end mill on the ShopBot for milling. But using the 3mm end mill, I can't mill out the numbers around the clock as pockets, for that I require a smaller diameter end mill. Since a smaller diameter end mill was not available I milled out the outline of the numbers



ASSEMBLING

After manufacturing all the required parts, I assembled all the parts together.


Glued the neopixel strip around the clock


Connected all the wires to the board.


Screwed the Circuit Board on to the casing.


Now the clock is ready to be programmed.


PROGRAMMING

Programming the clock was not an easy task because the clock has to do lot of functions and all these functions requires specific programs.
Initially I had to figure out 3 things for the basic functioning of the clock.
  • Fetching Indian Standard Time (IST) and Eastern Standard Time (EST) from the internet.
  • Find the number of steps required by the motor to turn for 1 minute and 1 hour.

1) Fetching Time from internet
I searched on the Internet and found out about NTP SERVER.

An NTP stands for Network Time Protocol. It’s a standard Internet Protocol (IP) for synchronizing the computer clocks to some reference over a network. The protocol can be used to synchronize all networked devices to Coordinated Universal Time (UTC) within a few milliseconds. Coordinated Universal Time (UTC) is a world-wide time standard, closely related to GMT (Greenwich Mean Time). UTC does not vary, it is the same world wide. NTP sets the clocks of computers to UTC, any local time zone offset or day light saving time offset is applied by the client. In this manner clients can synchronize to servers regardless of location and time zone differences.
To know more about NTP Server click on the link https://lastminuteengineers.com/esp8266-ntp-server-date-time-tutorial/, This page also have a sample program for fetching time from the internet, and I decided to use this program to get the IST and EST from the internet.

2) Number of steps required by the motor to turn for 1 minute and 1 hour
I have to find out the the number of steps the minute hand motor and the hour hand motor should turn for 1 minute and 1 hour respectively. I googled about 28BYJ-48 mini stepper motor and found that the shaft of the motor completes 1 full rotation in 2048 steps. Now its time for some calculations.



Now I figured out the solutions for the 3 problems I mentioned above and now I can start programming using Arduino. So I have add the ESP32 Board Manager to arduino. For the board manager I searched on GitHub and found this link https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Open Arduino and go to File -> Preferences and paste the above json link.


Go to Tools -> Board -> Board Manager search for ESP32 and install the esp32 board manager.


Go to Tools -> Board and find esp32 Dev Module


Arduino Code:
                  #include <NTPClient.h>
                  #include <WiFi.h>
                  #include <WiFiUdp.h>
                  #include <time.h>
                  #include <Adafruit_NeoPixel.h>
                  
                  #define WiFi_led 4
                  #define dir1 15
                  #define step1 13
                  #define dir2 12
                  #define step2 14
                  #define MS1 32
                  #define MS2 33
                  #define MS3 25
                  #define lms1 4
                  #define lms2 2
                  #define neo 18
                  #define trigPin 16
                  #define echoPin 17
                  
                  Adafruit_NeoPixel pixels = Adafruit_NeoPixel(19, neo, NEO_GRB + NEO_KHZ800);
                  
                  int HR = 0, MIN = 0, SEC = 0;
                  int HR_P = 0, MIN_P = 0;
                  int USHr = 0, USMin = 0, USSec = 0;
                  
                  const char *ssid     = "panakkal";
                  const char *password = "JacOb123";
                  
                  WiFiClient client;
                  
                  const char* ntpServer   = "pool.ntp.org";
                  
                  int  gmtOffset_sec_US      = -18000;
                  int  gmtOffset_sec_IN      = 19800;
                  
                  char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
                  
                  WiFiUDP ntpUDP;
                  NTPClient timeClientIN(ntpUDP, "pool.ntp.org", gmtOffset_sec_IN);
                  NTPClient timeClientUS(ntpUDP, "pool.ntp.org", gmtOffset_sec_US);
                  
                  void setup()
                  {
                    pinMode(WiFi_led, OUTPUT);
                    pinMode(step1, OUTPUT);
                    pinMode(dir1, OUTPUT);
                    pinMode(step2, OUTPUT);
                    pinMode(dir2, OUTPUT);
                    pinMode(MS1, OUTPUT);
                    pinMode(MS2, OUTPUT);
                    pinMode(MS2, OUTPUT);
                    pinMode(neo, OUTPUT);
                    pinMode(trigPin, OUTPUT);
                    pinMode(echoPin, INPUT);
                    pinMode(lms1, INPUT_PULLUP);
                    pinMode(lms2, INPUT_PULLUP);
                    
                    Serial.begin(115200);
                  
                    WiFi.begin(ssid, password);
                  
                    Serial.println();
                    Serial.println("Connecting to WiFi");
                  
                    while ( WiFi.status() != WL_CONNECTED ) 
                    {
                      digitalWrite(WiFi_led, HIGH);
                      Serial.print( "." );
                      delay ( 250 );
                  
                      digitalWrite(WiFi_led, LOW);
                      Serial.print( "." );
                      delay ( 250 );
                    }
                    
                    digitalWrite(WiFi_led, HIGH);
                    Serial.println();
                    Serial.println("WiFi Connected, Fetching Time from web"); 
                    pixels.begin();
                    rotate_zero();
                    timeClientIN.begin();
                    timeClientUS.begin();
                    Set_Needle();
                  }  
                  
                  void loop() 
                  {
                    UpdateINTime();
                    Change_INTime();
                    Neo_IN();
                    Presence();
                    delay(500);
                  }
                  
                  void rotate_zero()                                  //Function to set the needles to zero position
                  {
                    int limit1 = digitalRead(lms1);
                    int limit2 = digitalRead(lms2);
                    digitalWrite(MS1, LOW);
                    digitalWrite(MS2, LOW);
                    digitalWrite(MS3, LOW);
                    digitalWrite(dir1, LOW);
                    digitalWrite(dir2, LOW);
                  
                    for(int x = 0; x < 3500 && limit1 == 1; x++)
                    {
                      digitalWrite(step1, HIGH);
                      delayMicroseconds(1000);
                      digitalWrite(step1, LOW);
                      delayMicroseconds(1000);
                      limit1 = digitalRead(lms1);
                    }
                    
                    for(int x = 0; x < 3500 && limit2 == 1; x++)
                    {
                      digitalWrite(step2, HIGH);
                      delayMicroseconds(1000);
                      digitalWrite(step2, LOW);
                      delayMicroseconds(1000);
                      limit2 = digitalRead(lms2);
                    }  
                  }
                  
                  void Set_Needle()                                        //Function to set the needles to the current IST
                  {
                    rotate_zero();
                    
                    UpdateINTime();
                    Serial.print("INDIA      : ");
                    Serial.print(daysOfTheWeek[timeClientIN.getDay()]);
                    Serial.print(", ");
                    Serial.print(HR); 
                    Serial.print(":"); 
                    Serial.print(MIN);
                    Serial.print(":"); 
                    Serial.println(SEC);
                  
                    UpdateUSTime();
                  
                    int stephr = 0;
                    int stepmin = 0;
                  
                    if(stepmin != MIN)
                    {
                      digitalWrite(MS1, LOW);
                      digitalWrite(MS2, LOW);
                      digitalWrite(MS3, LOW);
                      
                      if(MIN <= 30)
                      {
                        digitalWrite(dir1, HIGH);
                        for(int x = 0; x < (51.2*MIN); x++)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                        }
                      }  
                  
                      if(MIN > 30)
                      {
                        digitalWrite(dir1, LOW);
                        for(int x = 0; x < (51.2*(60-MIN)); x++)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                        }  
                      }
                      stepmin = MIN;
                    }
                  
                    if(stephr != HR)
                    {
                      digitalWrite(MS1, LOW);
                      digitalWrite(MS2, LOW);
                      digitalWrite(MS3, LOW);
                  
                      if((HR > 0 && HR <= 6) || (HR > 12 && HR <= 18))
                      {
                        digitalWrite(dir2, HIGH);
                        if(HR > 0 && HR <= 6)
                        {
                          for(int x = 0; x < (256*HR); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }
                        }
                        else
                        {
                          for(int x = 0; x < (256*(HR-12)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }  
                        }
                      }
                  
                      if((HR > 6 && HR < 12) || (HR > 18 && HR < 24))
                      {
                        digitalWrite(dir2, LOW);
                        if(HR > 6 && HR < 12)
                        {
                          for(int x = 0; x < (256*(12-HR)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }
                        }
                        else
                        {
                          for(int x = 0; x < (256*(24-HR)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }  
                        }
                      }  
                      stephr = HR;
                    }
                  
                    MIN_P = MIN;
                    HR_P = HR;
                  }
                  
                  void UpdateINTime()                                            //Function to fetch IST from internet
                  {
                    timeClientIN.update();
                    HR = timeClientIN.getHours();
                    MIN = timeClientIN.getMinutes();
                    SEC = timeClientIN.getSeconds();   
                  }
                  
                  void UpdateUSTime()                                            //Function to fetch EST from internet
                  {
                    timeClientUS.update();
                    USHr = timeClientUS.getHours();
                    USMin = timeClientUS.getMinutes();
                    USSec = timeClientUS.getSeconds();   
                  
                    Serial.print("NEW JERSEY : ");
                    Serial.print(daysOfTheWeek[timeClientUS.getDay()]);
                    Serial.print(", ");
                    Serial.print(USHr); 
                    Serial.print(":"); 
                    Serial.print(USMin);
                    Serial.print(":"); 
                    Serial.println(USSec);
                  }
                  
                  void Change_INTime()                                             //Function to move the needles every minute
                  {
                    int limit1 = digitalRead(lms1);
                    int limit2 = digitalRead(lms2);
                    
                    if(MIN_P != MIN)
                    {
                      Serial.print("INDIA      : ");
                      Serial.print(daysOfTheWeek[timeClientIN.getDay()]);
                      Serial.print(", ");
                      Serial.print(HR); 
                      Serial.print(":"); 
                      Serial.print(MIN);
                      Serial.print(":"); 
                      Serial.println(SEC);
                  
                      UpdateUSTime();
                      
                      digitalWrite(dir1, HIGH);
                      if(MIN == 0)
                      {
                        for(int x = 0; x < 3500 && limit1 == 1; x++)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                          limit1 = digitalRead(lms1);
                        }  
                      }
                      else
                      {
                        for(int x = 0; x < (51.2*(MIN-MIN_P)); ++x)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                        }
                      
                        MIN_P = MIN;
                      }
                    }  
                  
                    if(HR_P != HR)
                    {
                      digitalWrite(dir2, HIGH);
                      if(HR == 0 || HR == 12)
                      {
                        for(int x = 0; x < 3500 && limit2 == 1; x++)
                        {
                          digitalWrite(step2, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step2, LOW);
                          delayMicroseconds(1000);
                          limit2 = digitalRead(lms2);
                        }
                      }
                      else
                      {
                        for(int x = 0; x < (256*(HR-HR_P)); ++x)
                        {
                          digitalWrite(step2, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step2, LOW);
                          delayMicroseconds(1000);
                        }
                      }  
                  
                      HR_P = HR;
                    }  
                  }
                  
                  void Show_USTime()                                               //Function to move the needles to show the EST
                  {
                    rotate_zero();
                    UpdateUSTime();
                  
                    int stephr = 0;
                    int stepmin = 0;
                  
                    if(stepmin != USMin)
                    {
                      digitalWrite(MS1, LOW);
                      digitalWrite(MS2, LOW);
                      digitalWrite(MS3, LOW);
                      
                      if(USMin <= 30)
                      {
                        digitalWrite(dir1, HIGH);
                        for(int x = 0; x < (51.2*USMin); x++)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                        }
                      }  
                  
                      if(USMin > 30)
                      {
                        digitalWrite(dir1, LOW);
                        for(int x = 0; x < (51.2*(60-USMin)); x++)
                        {
                          digitalWrite(step1, HIGH);
                          delayMicroseconds(1000);
                          digitalWrite(step1, LOW);
                          delayMicroseconds(1000);
                        }  
                      }
                      stepmin = USMin;
                    }
                  
                    if(stephr != USHr)
                    {
                      digitalWrite(MS1, LOW);
                      digitalWrite(MS2, LOW);
                      digitalWrite(MS3, LOW);
                  
                      if((USHr > 0 && USHr <= 6) || (USHr > 12 && USHr <= 18))
                      {
                        digitalWrite(dir2, HIGH);
                        if(USHr > 0 && USHr <= 6)
                        {
                          for(int x = 0; x < (256*USHr); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }
                        }
                        else
                        {
                          for(int x = 0; x < (256*(USHr-12)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }  
                        }
                      }
                  
                      if((USHr > 6 && USHr < 12) || (USHr > 18 && USHr < 24))
                      {
                        digitalWrite(dir2, LOW);
                        if(USHr > 6 && USHr < 12)
                        {
                          for(int x = 0; x < (256*(12-USHr)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }
                        }
                        else
                        {
                          for(int x = 0; x < (256*(24-USHr)); x++)
                          {
                            digitalWrite(step2, HIGH);
                            delayMicroseconds(1000);
                            digitalWrite(step2, LOW);
                            delayMicroseconds(1000);
                          }  
                        }
                      }  
                      stephr = USHr;
                    }
                  }
                  
                  void Neo_IN()                                                 //Function for the neopixel to show the daylight
                  {
                    if(HR >=6 && HR <= 9)
                    {
                      for(int i=0;i<19;i++)
                      {
                        pixels.setPixelColor(i, pixels.Color( 174, 214, 241 )); // Light blue color.
                        pixels.show(); // This sends the updated pixel color to the hardware.
                      }
                    }
                    
                    if(HR >=10 && HR <= 12)
                    {
                      for(int i=0;i<19;i++)
                      {
                        pixels.setPixelColor(i, pixels.Color( 249, 231, 159 )); // Yellow color.
                        pixels.show(); // This sends the updated pixel color to the hardware.
                      }
                    
                    }  
                  
                    if(HR >=13 && HR <= 16)
                    {
                      for(int i=0;i<19;i++)
                      {
                        pixels.setPixelColor(i, pixels.Color( 250, 215, 160 )); // Orange color.
                        pixels.show(); // This sends the updated pixel color to the hardware.
                      }
                    }  
                  
                    if(HR >=17 && HR <= 19)
                    {
                      for(int i=0;i<19;i++)
                      {
                        pixels.setPixelColor(i, pixels.Color(247,220,143)); // Moderately dark blue color.
                        pixels.show(); // This sends the updated pixel color to the hardware.
                      }
                    }  
                  
                    if(HR >=20 && HR <= 22)
                    {
                      for(int i=0;i<19;i++)
                      {
                        pixels.setPixelColor(i, pixels.Color( 36, 113, 163 )); // Dark blue color.
                        pixels.show(); // This sends the updated pixel color to the hardware.
                      }
                    }
                    
                    else
                    {
                      pixels.clear();  
                    }
                  }
                  
                  void Presence()                                               //Function for the ultrasonic sensor
                  {
                    long duration, distance;
                  
                    digitalWrite(trigPin, LOW);
                    delayMicroseconds(2);
                    digitalWrite(trigPin, HIGH);
                    delayMicroseconds(10);
                    duration = pulseIn(echoPin, HIGH);
                    distance = (duration/2) / 29.1;
                    Serial.println(distance);
                    delay(1000);
                    
                    if(distance > 20 && distance <=50)
                    {
                      Serial.println("Human within 10cm");
                      Show_USTime();
                      delay(10000);
                      Set_Needle(); 
                    }
                  
                    else if(distance > 100)
                    {
                      if(HR < 6 && HR >= 23)
                      {
                        Serial.println("Human within 30cm");
                        Night_light();   
                      }
                    }  
                  }
                  
                  void Night_light()                                         //Function to turn ON the night light
                  {
                    for(int i=0;i<19;i++)
                    {
                      pixels.setPixelColor(i, pixels.Color(255, 244, 229)); // warm light color.
                      pixels.show(); // This sends the updated pixel color to the hardware.
                    }
                    delay(10000);
                    pixels.clear();
                  }
                


I uploaded the program on to the board, and powered up the board using external supply. The clock started working.

The clock worked perfectly with all the functions smoothly. I tested it to its core, and after 30 minutes of continuos working I found that the circuit board started heating up, and immediatly the board got over-heated and the clock ceased. I believe there was some problem with the power supply design I made and the whole electronics board had to scraped. I was very dissapointed and now I have to redesign my board. But due to time constrain caused by the COVID-19 lockdown I could'nt redesign my board.

This smart clock is a dream project of mine because I have spent a lot of time and effort to make it this much and moreover it was something I made for my mother. This will be a future project of mine and I will complete it even after my academy and I will document my progress in this page.



Evaluate the project

Did I make the must have features: Yes
I made an analog clock which can be controlled by the gesture made by the human in its close proximity. The light behind the clock changes from white to yellow to orange to red to blue as the day progresses to night. I was able to add a night light that switches on when a movement is detected in its vicinity.

What are the features that I could not include
I was unable to create a program that automatically updates time according to the Daylight saving time in New Jersey. I would like to include this later on. Presently, it is a limitation of my project and I have to manually code it to get the correct time.

Further Steps

My board crashed and I plan to redo it. I will add the changes in programming while doing this. As I’m using ESP32 which is capable of dual core processing, I would like to program it utilising this and increase the speed and processing time of the clock.