summaryrefslogtreecommitdiff
path: root/Origin/user-code/servo/scilab/servo-pot.sce
blob: 721bc25615248e5dfd9e657934f1ff5bbcc5d758 (plain)
1
2
3
4
5
6
7
8
9
10
11
ok = open_serial(1, 2, 115200) // At port 2 with baud rate of 115200
if ok ~= 0 error('Check the serial port and try again'); end
cmd_servo_attach(1, 1) // Attach the motor to pin 5
for i=1:50              // 5,000 itterations
    val = cmd_analog_in(1, 2)  // Read potntiometer value
    val = floor(val*(180/1023)) // Scale Potentiometer value to 0-180
    cmd_servo_move(1, 1, val) // Command the servo motor
    sleep(500)            // sleep for 500 milliseconds
end
cmd_servo_detach(1, 1)// Detach the motor
close_serial(1)