daily pastebin goal
56%
SHARE
TWEET

Arduino Servo Tutorial

a guest Jan 22nd, 2018 394 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2.  
  3. #define btnPin 4
  4. #define serPin 2
  5.  
  6. Servo servo;  
  7.  
  8. int randomN;
  9.  
  10. void setup() {
  11.   pinMode(btnPin, INPUT);
  12.   servo.attach(serPin);
  13. }
  14.  
  15. void loop() {
  16.   if (digitalRead(btnPin) == HIGH) {
  17.     randomN = random(1, 180);
  18.     servo.write(randomN);  
  19.   }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top