# H-bridge-dc-motor

**URL:** <https://forum.xod.io/t/h-bridge-dc-motor/1572>\
**Category:** Uncategorized\
**Created:** [December 17, 2018, 8:02pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572 "2018-12-17T20:02:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarzeon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/aarzeon/32/299_2.png) [@aarzeon](https://forum.xod.io/u/aarzeon)\
**Post date:** [December 17, 2018, 8:02pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/1 "2018-12-17T20:02:20Z")

</div>

Hi, I’m trying to use h-bridge-dc-motor but the directions for clockwise (1) and counterclockwise (-1) is wrong.  
1 = clockwise fullspeed, -1 = stop, 0= stop and -0.01 = counterclockwise fullspeed. Is that a known issue?

Can somebody fix that or am I doing something wrong?

Thank you

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [December 18, 2018, 1:21am UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/2 "2018-12-18T01:21:53Z")

</div>

Easiest fix is to swap the wires from your motor to the controller.

---

<div class="post-metadata">

**Author:** ![aarzeon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/aarzeon/32/299_2.png) [@aarzeon](https://forum.xod.io/u/aarzeon)\
**Post date:** [December 18, 2018, 6:02pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/3 "2018-12-18T18:02:05Z")

</div>

I tried it but it is still 0 or -1 = Stop, 0.1 = Counterclockwise fullspeed and 1 = clockwise fullspeed

Programm that Im using

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/70b45c38b525c7db0f50d72f3d9e94bbb17b7953.png)

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 18, 2018, 7:22pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/4 "2018-12-18T19:22:19Z")

</div>

hi, `fade` work with -1? you do not need to map?

---

<div class="post-metadata">

**Author:** ![aarzeon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/aarzeon/32/299_2.png) [@aarzeon](https://forum.xod.io/u/aarzeon)\
**Post date:** [December 18, 2018, 9:19pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/6 "2018-12-18T21:19:29Z")

</div>

What do you mean with map and yes the fade is working properly even in the negativ range.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 18, 2018, 9:48pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/7 "2018-12-18T21:48:01Z")

</div>

Yes, I had not used `fader`, see if it works for you, so as not to use two counters

[count-up-down.xodball](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/0e06d57775892f04190cf047ab459c3d8e07b7aa.xodball) (4.1 KB)

In library [nkrkv/encoder](https://xod.io/libs/nkrkv/encoder) It is also count up-down [https://xod.io/libs/nkrkv/encoder/count/](https://xod.io/libs/nkrkv/encoder/count/)

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 19, 2018, 1:14am UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/8 "2018-12-19T01:14:09Z")

</div>

It has happened to me that by mistake I leave D0 and D1 in a node and those pins are used by the serial.  
I upload a patch, which works well, I do not know if it’s what you want to do  
[motor.xodball](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/ef333a909e86c65d59b90647b791d6226305d04c.xodball) (10.4 KB)

---

<div class="post-metadata">

**Author:** ![evgenykochetkov](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/evgenykochetkov/32/14_2.png) [@evgenykochetkov](https://forum.xod.io/u/evgenykochetkov)\
**Post date:** [December 19, 2018, 2:35pm UTC](https://forum.xod.io/t/h-bridge-dc-motor/1572/9 "2018-12-19T14:35:49Z")

</div>

Hi! I checked implementation of `h-bridge-dc-motor`, it is fine. Your patch looks correct as well. Maybe values of DIR and PWM pins on `h-bridge-dc-motor` must be swapped?
