Introduction: Green Tea Maker

About: Since 2018, Electronics & Arduino Hobby has been committed to helping the world achieve electronics literacy. No matter your vision or skill level, our products and resources are designed to make electroni…

#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 -------"); }

}