Testing Cytron motorcontroller with Arduino

I bought four motor contollers from the net, and I tested them with an Arduino. Here is the list of the electrics:
Arduino, Cytron , mercedes screen-wiper motor, potentialmeter.

We made an repositioning device as you can see in this video:

Don’t listen to the backgroundsound, he is trying to comment what you can see but … at least he tried it 🙂

Here you can see the code running on the Arduino:

int sensorValue = 0; 
const int analogInPin = A0; 
const int PwmPin = 5;
const int Direction = 2; 
int pos = 60;    // variable to store the servo position 
void setup() 
    pinMode(PwmPin, OUTPUT);
    pinMode(Direction, OUTPUT);
void loop() 
  if (Serial.available() > 0) {
    Serial.print("pos: ");
  sensorValue = analogRead(analogInPin)/4;
  Serial.print("sensorValue: ");
  byte dataToWrite=0;
  if (pos>sensorValue){
  Serial.print("dataToWrite: ");
  if (dataToWrite>245)dataToWrite=245;
  else if (dataToWrite<10) dataToWrite=0;
  analogWrite(PwmPin,dataToWrite );

What’s happening?

You can send an position from 0 to 240, and if you try to move the object it will return it is original position after some beep. The Arduino is connected with the motor controller through PWM, and with the potentiometer. There is a shield on the Arduino, originaly it was made for servos, communicating with PWM so it is not necessary to be this complex.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.