What is the best way to control ground signal trigger

Hello experts of the forum

I have a stepper motor controller (YF-20 is the model if this helps) that takes the ground as a trigger signal. i.e. 5V = 0, 0V = 1. The motor controller has two inputs, one for clockwise rotation and the other for counterclockwise. So What I did was to set the digitalWrite to high when I want the motor to be stationary and low if I want the motor to turn. This works if I only have 1 Arduino pin output connected to the motor controller. If I have two outputs for some unknown reason whenever I set one pin to low the other pin will also go low.

Are there some settings on the arduino I should be aware of when a trigger requires shorting the ground?

Thanks for any help.

Edit: I should elaborate further that the motor controller senses a signal when the input terminal is shorted to the ground. So in the off state, the input terminal is at 5V. I want the Arduino to perform something similar, i.e. open circuit -- no trigger, closed circuit -- trigger

Nope, not at all. So I suspect a bug in the (not shown) code. If you would like more help, be sure to check out How to get the most out of this forum before you reply :slight_smile:

void setup ()

Serial.begin(9600);
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
digitalWrite (2, 1);
digitalWrite (3, 1);

void loop ()
if (Serial.available () > 0){
char temp = Serial.read();

if (temp = '1') {
digitalWrite (2, 0);
delay(100);
digitalWrite (2, 1);
}

if (temp = '2') {
digitalWrite (3, 0);
delay(100);
digitalWrite(3,1);
}
}

Thanks for your help septillion. The codes pretty much look like the above. When the serial port receives '1' pin 2 goes low for 100ms then back to the high state, the same thing happens for pin 3 when '2' is received.

"Pretty much" is not exactly. And the devil is in the detail. As this code does not compile, did you actually test it with such a simplified program?

And while you're at it editing, you may want to fix the = vs == bug :wink:

Aha! I think that's where I screwed up! XD Such an amateur mistake! Thanks a lot septillion!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.