SkillDev4 - Rahul Jha

Made by Rahul Jha

to create an interesting notification using a servo.

Created: December 4th, 2021

0

The video for the demonstration is below:

0

Outcome

    • Created a drink water notification using servo which triggers from google calender event using IFTTT. Once the user is notified of the signal, the indicator can be reset using a push button.
0

Process

1. Created circuit where connected argon board with servo and push button. 

2. Set up events on google calendar to trigger drink water notification every one or two hours as advised.

3. Using IFTTT connected the calendar trigger to particle function

Code for the project is below:

0
//SkillDev-4

int servoPin = A3;
int servoPos = 0;
int pushButton = D2;
int buttonState;        //store the reading from the button

bool calAlert_Status = false;       //to check if the calender alert occured
unsigned long lastUpdate = 0;       //to check track the time usin millis()
unsigned long now =0;           //to check track the time usin millis()

Servo myServo;

void setup() {
    //attaching servo Pin 'A3' to Servo object
    myServo.attach(A3);
    
    Particle.function("DrinkWater", setCalAlert);
    
    pinMode (pushButton, INPUT_PULLUP);

}

void loop() {
    
    buttonState = digitalRead( pushButton );
    if (buttonState == LOW){
       
        calAlert_Status = false;
        servoPos = 0;
        myServo.write(servoPos);
    }
    

    
    if (calAlert_Status == true){
        
     
        
        now = millis();
    
        if ((now - lastUpdate) < 2500) {
    
            servoPos = map ((now - lastUpdate), 0, 2500, 0, 90);
            myServo.write(servoPos);
        }else{
            
            if ((now - lastUpdate) < 5000) {
    
                servoPos = map ((now - lastUpdate), 2500, 5000, 0, 90);
                myServo.write((90 - servoPos));
                
            }else{
                delay(200);
                lastUpdate = millis();
            }
        }
    }
}

int setCalAlert(String command){
    
    if(command == "True") {
        calAlert_Status = true;
        //servoStart = 1;
        lastUpdate = millis();
        return 1;
    }
    return -1;
}
Click to Expand
0
SkillDev4
rahuljha89 - https://youtu.be/NzmU1yDiGEs
0

Reflection

1. Learned the implementation of servo and creating notifications using cloud triggers.
2. Definitely it's a simple project but it has been of great use for me since I often missed getting up to drink water for long durations while studying.

3. Due to time constraints could not look for more interesting notifications. However, in the future, I plan to connect the servo to some analog data to indicate cool effects happening over the internet.

x
Share this Project

Courses

About

to create an interesting notification using a servo.