A tutoriel to control DC motors with Esus board.
Your need :
- 1x Esus board,
- 2 or 1 DC motors
- Power supply or battery
Control DC motors
To control DC motors, it is necessary to use the following functions:
void motors1_set(unsigned int speed, boolean direction); void motors2_set(unsigned int speed, boolean direction);
- speed : motor speed between 0 to 1024.
- direction: motor direction (DIR_FORWARD or DIR_BACK)
Exemple, for control two DC motors :
#include <esusBoard.h>
void setup()
{
// init esus board
initEsusBoard();
}
void loop()
{
// control motor 1, direction = forward
motors1_set(1024, DIR_FORWARD);
// control motor 2, direction = forward
motors2_set(1024, DIR_FORWARD);
// 1 second delay
delay(1000);
// control motor 1,direction = back
motors1_set(1024, DIR_BACK);
// control motor 2,direction = back
motors2_set(1024, DIR_BACK);
delay(1000);
}
