Skill Dev4 - Yang Bai

Made by yangb ·

This is skill dev 4.

Created: December 13th, 2020

0

Intention

The intention of this exercise is to create a material interaction with a motor, as well as to use the particle cloud to control the device. 

0

Process

Basically I want use the sero to make a device which is a timer. This timer can represent the left time of an set event. For example, I want to use it to when I need to finish a task within 15mins. Then the timer will change the angle every 5 mins. 

I use a servo to do this, also a Particle cloud function to control it.

0
int servoPin = A3;
Servo servo;
bool servoPositionUpdated = false;
int servoPos = 0;

void setup() {
    
    servo.attach(servoPin);
    Particle.function("position", setPosition);
}

void loop() {
    
    if (servoPositionUpdated == true){
        servo.write(servoPos);
        servoPositionUpdated = false;
    }
    
}


int setPosition (String cmd) {
    
    int input = cmd.toInt(); 
    if (input > 180) {
        return -1;
    }
    if (input < 0) {
        return -1;
    }
    int angle = map(input, 15, 0, 0, 90); // map the input value to rotaton angle
    servoPos = angle;
    servoPositionUpdated = true;
    return 1;
}
Click to Expand
0
0

Reflection

From this task, I learn how to control a motor and a servo. Also, connecting these devices with Particle cloud functions helps me build the data flow. I think it is quite inspring. It makes me think about how to represent the data flow in the real world

x
Share this Project

This project is only accessible by signed in users. Be considerate and think twice before sharing.


Courses

About

This is skill dev 4.