Pcomp: Week 4

LABS

ezgif.com-video-to-gif-8
Enter a caption

Makeup Machine

(Big thanks to Yuguang for letting me try the machine on him!)

ezgif.com-video-to-gif-7.gif

My first plan was to make an omelette making machine but I couldn’t manage to make a video for that in time so I’ll just get back to it later.

Here’s a video with my servo motor trying to apply blush on my face.

#include

int reading;

int prevReading = 0;

int counter = 0;

Servo servoMotor;

int servoPin = 7;

int buttonPin = 3;

void setup() {

Serial.begin(9600);

servoMotor.attach(servoPin);

pinMode(buttonPin,INPUT);

}

void loop() {

reading = digitalRead(buttonPin);

Serial.println(counter);

if (reading == 1) {

if (prevReading == 0) {

prevReading = 1;

}

}

if (reading == 0) {

if (prevReading == 1) {

counter++;

prevReading =0;

}

}

if (counter == 1) {

servoMotor.write(70);

delay(200);

servoMotor.write(120);

delay(200);

} if (counter == 2) {

counter = 0;

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s