Programming Hexy with C through Arduino IDE


#1

How can I move the motors on the Hexy in C using the Servotor32 library?
Thanks.


#2

Hello,

There’s some examples that come in the default example:
github.com/ArcBotics/Servotor32 … efault.ino

Once you define the following:

#include "Servotor32.h" // call the servotor32 Library
Servotor32 hexy; // create a servotor32 object

void setup() {
  hexy.begin();
}

You can make the following commands:

hexy.changeServo(0,1500); // move servo zero to 1500uS. 1500us is center, 2500 is 90 degrees right, and 500 is 90 degrees left
hexy.ping() // returns an integer in centimeters of the distance hexy's ultrasonic distance-measuring head is measuring

We also have a demo arduino code generator in our PoMoCo 2.0 Beta software:
github.com/ArcBotics/PoMoCo-2


#3

Hello and thanks for your response
Whenever i try the following code,

#include "Servotor32.h" // call the servotor32 Library
Servotor32 hexy; // create a servotor32 object

void setup() {
  hexy.begin();
}

void loop(){
  while(true){
    hexy.changeServo(0,2500);
    hexy.delay_ms(1000);
    hexy.changeServo(0,500);
    hexy.delay_ms(1000);
  }
}  

The Hexy does not move at all, and the compiler does not give any errors. However, whenever I upload the default firmware and use PoMoCo, Hexy works as expected. Any ideas?


#4

The code works perfectly for me. Are you sure you have your servo in port 0, and that the servos have power?


#5

Ah I see I got my pins confused thanks.