HELP ME

hello I wanted to ask for your help on solving a problem,
I have realized this scheme to control the speed and direction of a motor dchttp://pietrolodi.altervista.org/wp-content/uploads/2015/01/schema_bb1-e1422476636739.jpgI mounted on the bread board all components WORKING but I can not understand why the circuit is not working. I checked the sketch to see if there are errors but to my untrained eye from neophyte who does not understand anything did not detect anything but I saw that in a video with the same pattern and the same sketch using a comb potentiometer I use a potentiometer such as the one in the picture. Help me is a major project following the sketch sorry for my english :

const int controlPin1 = 2;
const int controlPin2 = 3;
const int enablePin = 9;
const int directionSwitchPin = 4;
const int onOffSwitchStateSwitchPin = 5;
const int potPin = A0;

onOffSwitchState int = 0;
previousOnOffSwitchState int = 0;
directionSwitchState int = 0;
previousDirectionSwitchState int = 0;

motorEnabled int = 0;
Motorspeed int = 0;
int motorDirection = 1;

void setup ()
{
pinMode (directionSwitchPin, INPUT);
pinMode (onOffSwitchStateSwitchPin, INPUT);
pinMode (controlPin1, OUTPUT);
pinMode (controlPin2, OUTPUT);
pinMode (enablePin, OUTPUT);

digitalWrite (enablePin, LOW);
}

void loop ()
{
onOffSwitchState = digitalRead (onOffSwitchStateSwitchPin);
delay (1);
directionSwitchState = digitalRead (directionSwitchPin);
Motorspeed = analogRead (potPin) 0 <1023;
if (onOffSwitchState! = previousOnOffSwitchState)
{
if (onOffSwitchState == HIGH)
{
motorEnabled =! motorEnabled;
}
}

if (directionSwitchState! = previousDirectionSwitchState)
{
if (directionSwitchState == HIGH)
{
motorDirection =! motorDirection;
}
}

if (motorDirection == 1)
{
digitalWrite (controlPin1, HIGH);
digitalWrite (controlPin2, LOW);
}
else
{
digitalWrite (controlPin1, LOW);
digitalWrite (controlPin2, HIGH);
}

if (motorEnabled == 1)
{
analogWrite (enablePin, Motorspeed);
}
else
{
analogWrite (enablePin, 0);
}

previousDirectionSwitchState = directionSwitchState;
previousOnOffSwitchState = onOffSwitchState;
}

According to the diagram, you have the 5V and Gnd from the Arduino to the breadboard backwards.....

Here's the pic for others....

Please post your sketch properly, but first format it with CTRL T
Attach your code using the </> icon on the left side of the posting menu.

Post a good picture of your actual wiring.

Your PULLUP resistors need +5V or if they are pull downs you need INPUT_PULLUP
Or you need a common ground, but who knows ? ? ?

A schematic is really needed!
.

JimboZA:
According to the diagram, you have the 5V and Gnd from the Arduino to the breadboard backwards.....

Here's the pic for others....

You do realize the two power buss (top red/black, bottom red/black) have NO internal connections? You HAVE to run two jumpers from the top buss to the bottom buss, AND some breadboards BREAK these top and bottom buss's in half. So you can end up with FOUR power busses, a top left, top right, bottom left, bottom right.

Connect Power and Ground to one of the buss segments, verify that you have power were you expect it.

It looks to me that you have connected the UNO's power to the top right bus and are NOT delivering the power to your chip, switches, and variable resistor.

Also, you do not have a common ground between your 9V bus and the 5V bus.

Chuck.

I got the impression that the UNO was providing 5V to the upper +ve breadboard rail then to Vcc1 on the chip, (the logic supply), and that the 9V battery was providing power to the lower +ve breadboard rail then to Vcc2 on the chip for a motor supply.

The ground pins on the chip, pins 4,5 and 12,13, (assuming they’re internally connected in the chip), should provide a common ground, since 12, 13 connect to the upper breadboard ground rail from the UNO and pins 4, 5 connect to the lower breadboard ground rail from the 9V battery.

As mentioned, the +5V and GND wires from the UNO to the breadboard are shown with polarity reversed, but hopefully that’s only in the Fritzing and not in the real-world circuit.
(Man I hate these horrible Fritzing diagrams. Too hard to decipher, and too easy for people to make silly mistakes.)

Assuming that 5V is coming from the UNO, (and the polarity is really correct in the actual circuit), the switches and pot are connected correctly and should be working, as I see it.


Not so sure about the code. I don’t like the look of these for starters:-

onOffSwitchState int = 0;
previousOnOffSwitchState int = 0;
directionSwitchState int = 0;
previousDirectionSwitchState int = 0;

motorEnabled int = 0;
Motorspeed int = 0;

I don’t know what this is supposed to do either:-

Motorspeed = analogRead (potPin) 0 <1023;

The code can’t possibly compile. (Not in my IDE, anyway.)

I haven’t bothered looking any deeper. That’ll be easier when the code is fixed and posted between code tags. And life will be much easier for us if we can look at a real schematic diagram instead of a @#$%& Fritzing diagram.

Edit: And incidentally, why is this thread posted in the “Sensors” section of the forum?

OldSteve:
I got the impression that the UNO was providing 5V to the upper +ve breadboard rail then to Vcc1 on the chip, (the logic supply), and that the 9V battery was providing power to the lower +ve breadboard rail then to Vcc2 on the chip for a motor supply.

I still question the continuity of his Vcc and GND rail. Many of the breadboards I have split those power rails.

Chuck.

I think the OP is all gone.
.

chucktodd:
I still question the continuity of his Vcc and GND rail. Many of the breadboards I have split those power rails.
Chuck.

Yeah, I have one of those here. I have permanent links in it to make each rail continuous. As you said in your earlier post, he needs to check that he has power where he wants it. I didn't bother repeating this point, since it's a given.

LarryD:
I think the OP is all gone.

Looks like it, Larry. Hate it when people do that, after we put in the effort trying to help.