Created
September 13, 2018 06:48
-
-
Save atifahsuad/41f92d51ce9c87aa5f7c2170078e9d16 to your computer and use it in GitHub Desktop.
This example code is for Auto Gate's Tutorial.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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