Skip to content

Instantly share code, notes, and snippets.

@atifahsuad
Created September 13, 2018 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atifahsuad/41f92d51ce9c87aa5f7c2170078e9d16 to your computer and use it in GitHub Desktop.
Save atifahsuad/41f92d51ce9c87aa5f7c2170078e9d16 to your computer and use it in GitHub Desktop.
This example code is for Auto Gate's Tutorial.
/*
This example code is for Auto Gate tutorial.
Product page:
Maker UNO : https://www.cytron.io/p-maker-uno
Flame Sensor : https://www.cytron.io/p-sn-flame-mod
Created by:
13/09/18 Suad Anwar, Cytron Technologies
*/
#include <Servo.h> // Include the library for the servo
Servo myservo; // Create servo object to control a servo
int button = 2;
int ButtonState = 0;
void setup() {
myservo.attach(11); // Digital pin for the servo
pinMode(button,INPUT_PULLUP);
}
void loop() {
ButtonState = digitalRead(button);
if(ButtonState == LOW){
myservo.write(90); // The servo is at the 90 degree position
delay(3000);
}
else
myservo.write(0); // The servo is at the 0 degree position
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment