Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- clc;
- % connect the board
- a=arduino('COM8');
- % a.digitalWrite(13,1);
- % prints the status of both servos
- a.servoStatus(1);
- % attach servo #1
- a.servoAttach(1);
- % prints the status of both servos
- a.servoStatus;
- % move servo #1 to 5 degrees position
- a.servoWrite(1,90);
- val1 = a.servoRead(1);
- pause(2)
- % move servo #1 to 175 degrees position
- a.servoWrite(1,20);
- val2 = a.servoRead(1);
- pause(2)
- % move servo #1 to 50 degrees position
- a.servoWrite(1,30);
- pause(2)
- % reads angle from servo #1
- val=a.servoRead(1);
- % attach servo #1
- a.servoDetach(1);
- % close session
- delete(a)
- % Copyright 2011 The MathWorks, Inc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement