Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- #define btnPin 4
- #define serPin 2
- Servo servo;
- int randomN;
- void setup() {
- pinMode(btnPin, INPUT);
- servo.attach(serPin);
- }
- void loop() {
- if (digitalRead(btnPin) == HIGH) {
- randomN = random(1, 180);
- servo.write(randomN);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement