Group Members:
Yuki Chavez, Erica Young, Pin Chen, Wook Lee
Description:
Our cuckoo clock consists of wire for the joints, various types of cardboard for the main body and the components, and string and dental floss for the strings to attach the parts to the motor.
Video:
https://vimeo.com/78706099
Code:
#include <Servo.h>
Servo myservo;
String comBuf;
void setup() {
myservo.attach(7);
myservo.write(0); // set servo to beginning-point
Serial.begin(9600); // connect to the serial port
Serial.flush();
Serial.println("Servo control program ready");
}
void loop() {
int i=0;
char commandbuffer[100];
if(Serial.available()){
delay(100);
while( Serial.available() && i< 99) {
commandbuffer[i++] = Serial.read();
}
commandbuffer[i++]='\0';
}
if(i>0) {
comBuf = String(commandbuffer);
}
if (comBuf == "12:00" || comBuf == "11:00" || comBuf == "10:00" || comBuf == "9:00" || comBuf == "8:00" || comBuf == "7:00"
|| comBuf == "6:00" || comBuf == "5:00" || comBuf == "4:00" || comBuf == "3:00" || comBuf == "2:00" || comBuf == "1:00"
||comBuf == "1" || comBuf == "2" || comBuf == "3" || comBuf == "4" || comBuf == "5" || comBuf == "6" || comBuf == "7"
|| comBuf == "8" || comBuf == "9" || comBuf == "10" || comBuf == "11" || comBuf == "12") {
myservo.write(180);
analogWrite(motorPin, num); // analogWrite can be between 0-255
delay(3000);
myservo.write(0);
Serial.println("Time!");
comBuf = String();
}
}
- Login to post comments