Go Down

Topic: Auto gate (Read 308 times) previous topic - next topic


I understand how to.. I am using my mobile phone so the options are limited and whenever I post the code that way it give me "characters limited"
Many of us started out knowing nothing


The 12v dc motor is connected to a 2 channel relay which is connected to pin 8, 9 of arduino uno. I am not an arduino programmer so I can't versed out where I think this error is. The problem I am having is that if I plug the relay on the power supply the motor starts in one direction and won't respond to the RF receiver or the ultrasonic sensors. The only way to stop the motor is to unplug it from the power supply. I have searched on google for a fix and found nothing. The ultrasonic sensors are pin A0 - A3 and the RF receiver is pin 12, 13. I exhausted my options and I refuse to put this problem down. Maybe I am not asking the right question but an expert can easily help with a solution instead of filling this thread teaching about how to post.
Many of us started out knowing nothing


Hmm.. Im no programmer, but i might have a clue..

Is the motor a "normal" motor, a stepper motor or what? (these behave differently).

if youre using a motor controller, you might have a controller that can run in both directions.

If that is the case, you might need a ANALOG output to control the motor controller.
Or possibly pulse position modulation (PWM/PPM), this is normal for RC motor controllers.

So when youre setting your motor to STOP, you might be setting it to GO (in one direction).

Sometimes the signals are inverted too, that your logical 1 is HIGH, while the motor controller expects logic 1 to be LOW.

In other words, if you put voltage on the motor ON pin, and it stays on, try connecting ground to the pin instead.

Adding the relays on top of the motor makes it harder to identify correct signals, since you need 2x correct signals to successfully control the motor.
The first signal is between the arduino and the relay, the second is between the relay and the motor.

So you might be disabling the relay when you think you just activated it, and the activated relay may disable your motor, depending on the specifics in your case.

So my suggestion is to remove the arduino completely and try to get your circuit to work with a couple of buttons.
When your hardware is working as expected, then add the arduino and the bare essentials of a code snippet, slowly adding functions one at a time instead of uploading the whole project in one go, then try to debug.

As i said, im no programmer or electrical engineer, this is just my two cents regarding troubleshooting. :)

Good luck m8, may the force be with you!


Thanks very much.. I will try that solution
Many of us started out knowing nothing


The motor I am using is capable of bi direction.. I was using a syren 10 motor driver but it wasn't turning the motor and when I change the dip switch to analog it ran the motor as the problem I am having now
Many of us started out knowing nothing


But try to invert the motor control signal from the arduino, if HIGH is ON, turn it LOW for ON.

I dont know anything regarding your motor nor your controller, switching between digital and analog inputs is nothing ive seen possible on any motor controller ive seen.. :/

It COULD be that you need to have both directions in the same signal, like 0V=ON1, 2.5v=OFF, 5v= ON2, given that your input is 5v.

On a somewhat unrelated note, ive been having some SERIOUS issues debugging my codes, since i often fail to use the correct signal polarity (if high is on or off).

I solved that by defining a constant variable, bON and bOFF, witch are short for buttonON/OFF.
Since i use pull-up resistors, a pressed button is logical LOW, witch is the main reason for my confusion.
And therefore i declared in config: const int bON= LOW; const int bOFF= HIGH;

i can then use "if button1 == bON{ // enable whatever feature controlled by that specific button.};"

Im not saying that its the best way of dealing with such issues, but its a very simple way to work around the shortcomings of your (and my) brain.


This is a similar and simply setup of the parts with similar wiring
Many of us started out knowing nothing


I dont know why single output relay card would require two input channels..

It might be that you must set one pin to low and the other to high, that you define each motor connector polarity by its corresponding input pin.

So if dpin9 is high, dpin 10 is low, the motor turns in left direction,
if dpin 9 is low, dpin 10 high, the motor turns in right direction,
if both pins low (or high), the motor is stopped.

the motor on the picture is a DC motor, so if you switch the red and black cables, the motor turns in the other direction.

So its possible that your two digital pins are simply to controll witch motor cable is ground and witch has current.

Still, just guessing here.. :)


http://store.amequipment.com/206-series-gearhead-motor--12v-right-hand-p-195.html This is the motor I am using
Many of us started out knowing nothing


Well, i read the manual for the syren driver card, and it turns out that you only need one analog wire.

as written in the manual:
Mode 1: Analog Input
Analog input mode takes one or two analog inputs an
d uses those to set the speed and direction
of the motor. The valid input range is 0v to 5v. Th
is makes the SyRen easy to control using a
potentiometer, the PWM output of a microcontroller
(with an R-C filter) or an analog circuit.
Major uses include joystick or foot-pedal controlle
d vehicles, speed and direction control for
pumps and machines and analog feedback loops. There
 is also a Diff-Drive mixing mode which
takes two analog inputs for "tank style" steering.

The problem is that you cannot write a analog value to any pin on the arduino, the closest you get is duty-cycle.

You could use the mode2, pwm to control your motor, but that would require you to sort out the pulse width modulation, or use a library, in any way, a somewhat cumbersome route.

But i would use mode 3, serial.
Mode 3: Simplified serial. 
Simplified serial mode uses TTL level RS-232 serial
 data to set the speed and direction of the
motor. This is used to interface the SyRen to a PC
or microcontroller. If using a PC, a level
converter such as a MAX232 chip must be used. The b
aud rate is set via DIP switches.
Commands are single-byte, with 0 representing full
reverse and 255 representing full forward.
There is also a Slave Select mode which allows the
use of multiple motors from a single
microcontroller serial port. 

Depending on wether youre using the USB port or not, you could connect the serial wire from the TX pin (1) to S1 on the relay board.

Remember that you have to connect ground as well as the serial wire in order to get serial working.. :)

Have a look at pages 7 and 14 in the linked pdf.

Go Up