Introduction: Green Tea Maker
#include Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position const
int buttonPin = 4; //variables will change
int buttonState = 0;
int flag = 0;
void setup()
{
myservo.attach(3); // attaches the servo on pin 9 to the servo object pinMode(buttonPin, INPUT); }
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
//check if the pushbutton is pressed
flag = 1;
for(int i=0; i <= 45; i++){
myservo.write(120); // tell servo to go to position in variable 'pos'
delay(1500);
myservo.write(0);
delay(1500); }
} else {
flag =0; //
digitalWrite(ledPin, LOW); // turn LED off
// Serial.println("LED OFF -------"); }
}
Comments
4 years ago
Nice design. If I had one of these maybe I wouldn't over steep my tea for once.