Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new example Random Rotate #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions examples/Random_Rotate/Random_Rotate/Random_Rotate.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Rotate
KAbhijeet2105 marked this conversation as resolved.
Show resolved Hide resolved
by K.Abhijeet
This example code rotates the servo motor at random angle.

Circuit:-
Arduino Uno
Micro Servo Motor connected at pin no 9

KAbhijeet2105 marked this conversation as resolved.
Show resolved Hide resolved
*/

#include<Servo.h>
KAbhijeet2105 marked this conversation as resolved.
Show resolved Hide resolved

Servo Smotor; // Servo motor object
int pos=0;


void setup() {
Serial.begin(9600);
Smotor.attach(9); //Servo Motor connected at pin no 9

Smotor.write(0);
}

void loop() {

KAbhijeet2105 marked this conversation as resolved.
Show resolved Hide resolved
pos= random(0,180); //calculates random angle
Smotor.write(pos);
Serial.print("Current Motor position is:");
Serial.println(pos); //prints motor angle
delay(1000); //Wait for 1 second
}