it's me again, I still have problems with the book's example. This time with project 10 about the H-bridge =(

I am basically in the same situation than ludossin in this topic: I made the book's circuit, but when I press the buttons, nothing happens.

So, I've decided to make a simpler circuit first.I read this page http://itp.nyu.edu/physcomp/Labs/DCMotorControl and tried to reproduce this last circuit, and modified it a bit so that it basically runs the motor when you press the button (forgetting, for the moment, the idea of making it spin in both directions).

But here again, nothing happens. The motor doesn't spin at all. I tried to connect directly the 9v battery and the motor and it works, so I don't think the problem comes from them.

The only problem I can think about is that the first time I tried the circuit, I noticed afterwards that I had put the H-bridge the wrong way around, so absolutely ALL the H-bridge's pins were connected to the wrong wire...

What would you say ? Could it damage the H-bridge so bad it simply doesn't work anymore ? I'd like to know what's your opinion on this problem before going and buy a new H-bridge... I use the H-bridge shipped with the starter kit and it's the only one...

I attached a photograph of my circuit. It is actually meant to be the same than the picture, except I've put the switch on the other side.

Here's also my code, although it is so simple there's probably no problem with it:

Actually i also had problems with their instructions, although schematic and code were exactly the same. i started suspecting about damaged H bridge but with multimeter i realized that enablePin(output) was not getting power and so Hbridge was not getting power. i got rid of their code and started new one based on theirs step by step.First i wanted to make sure that H bridge was working and so i used this code:

And it worked, and then step by step i started adding toggle switch (lot cooler!! :b), direction of motor and finally speed and it the end all was working!! try this code (its a bit messy to understand but its working), i think pins are the same but check it! i used the same schematic as they say ofcourse. hope i helped

Hi !well basically we had the same idea (to try with a simpler circuit), but even your first example doesn't work for me (after replacing the pins numbers by mine of course)

I tried a lot of things like using digitalWrite instead of analogWrite, without setting the enablePin to HIGH in the setup, setting only the first control pin to OUTPUT (like you did in your example), but nothing makes it work ! :0 I even tried to change the place of everything on the breadboard, but no luck...

By looking at the photograph, can you see any obvious error that I may be missing ? I also wish I had a multimeter, but where I work people aren't really into electronics, so wey lack even of the fundamental tools... =( I'm probably going to buy one tomorrow morning, I'll tell you what are the results...

hmm..very strange, that code is simple as you can get and worked for me. but if you get multimeter try to see if you have voltage in output pin 9 and also in 2 and 7 pins or just in one of them. these last two as to do with current direction.. they cant be both high or low or motor will not spin.if both are getting voltage ,schematic is like in arduino book and code is that one i showed you,you might consider damaged H bridge. cumps

So I've been measuring at some points on the circuit and it seems that the H-bridge is eventually broken :~

I've joined once again some photos of my measurements with the multimeter to be clearer but, as I understand the situation:- 5v power flows through pin 9 of the Arduino, which is suppposed to power pin 1 of the H bridge- 5v power flows through the wire between Arduino's pin 9 and H-bridge's pin 1- but in the meantime almost no power is measured through pin 1 of the H-bridge.

I haven't enough experience in H-bridges to be sure (it's the first time I use one !), but I think it means it's broken (why would it measure near to zero then ?).

I should receive a new h-bridge on Monday, so we'll can figure out if the problem really comes from it (although if it doesn't solve the problem, I'll really be at a loss )

Pin 1 one H bridge is the enable pin, or like the H bridge switch, when it gets voltage it starts running.So if you can measure voltage coming out from pin 9 of arduino 1st stage is checked. After what H bridge will do is compare voltage in pin 2 and 7 (they cant be both HIGH or LOW at same time). if pin 2 as voltage and 7 doesnt it will spin in one direction; if 2 doesnt have voltage and 7 does have it will spin in the other direction; if both pins have voltage or if both pins dont have voltage it will not spin at all. So this is your next step,check the voltage on both pins...

Hello, some news about my problem...Yes, I know that if both digital pins for motor control are high or low, it stops the motor. So I checked the voltage of motor pins 1 and 2 on the Arduino and eventually the values are right : 0 for, say, motorpin1 if it's LOW, and 5v on the other, which is HIGH.

What I've found quite funny is that I measured the pins on the Hbridge and I had some surprises. For example I expected to find 0v and 5v on to the pins related to the Arduino's motorPins respectively LOW and HIGH, but instead, it measures about 1 volt or so on the two pins of the h-bridge connected to the motorPins.

So, to resume I measured: 0.85 volt on the hbridge pin connected to Arduino's enablePin (HIGH so measures 5v)~1v on the hbridge pin connected to Arduino's motorPin2 which is LOW (so measures 0vand ~1.42v on the hbridge pin connected to Arduino's motorPin1 (HIGH and measures 5v).

Apart from it, the 2 hbridge pins connected to the motor both measure 9v as expected.I don't think so, but are such measurements normal with a h bridge? :~

I had the same problem. The H bridge pins do not fit well into the starter kit bread board and without special effort you get only one side of the HB connected to the breadboard. With power wired into the same row as HBr pin 16, nothing happened. With the wire and pin 16 in the same hole, and a little more pushing the bridge down, everything worked fine.

My name is Gergely Takács and I am a research scientist. I am a very curious person: I like good ideas and I am fascinated by technology. I also like simple solutions and creating things that have never existed before.

As others have said already, I too can confirm the problem being the breadboard included with the starter kit (as of Dec. 2013). The H-Bridge does not fit very well into the breadboard: which either caused the circuit not to work at all or the motor spinning into only one direction when pushing the direction button (but not the on off button). A workaround for me was to move the H-Bridge to another position and slightly pushing it down with a finger, while testing the circuit.

Hi, thanks for the good answers. The solution jad1715 posted worked for me pretty well.When I first changed the code to the code posted by kaning it suddenly worked.At least for a short while. But after turning the Potentiometer a while the motor stopped moving. I read the new code carefully. It turned out to be the same as the code from the book with different variable names.

The 2nd version is prefered, as it uses one pot to go from 255->0 on the left & then directly goes on the right from speed 0->255 I used the ternary operator here for clean & quick code while maintaining readability, but you could do the same with "if .. else .." statements ( .. ).

For the question part:

Is it possible that I may not be able to PWM the speed if the motor I'm using ( the Arduino starter kit DC motor ) requires much power than I provide it ? ( currently using 5v batteries instead of 9v in the tutorial .. ):

--> I checked, re-checked, & re-rechecked and my code for the direction & speed is working fine, but the motor only spins once arrived to the value 255 :/ :| !

-> I 'll try as soon as I can to check what's going on, but I've ran several tests and all goes the same: directions OK, but motor only spinning while having the "motorSpeed" value to 255, not below ...

Thanks in advance for the anwser(s), I hope my code may be useful for some of us, and sorry for not finding your problem :/