hardware isn't match with code.

I use Arduino DUE.
The code is used to control a DC motor. When code uploaded, a DC motor should be rotated. But the DC motor isn’t rotated until I press the pressure sensor. Which is weird is that I didn’t contain any pressure sensor code in the code I upload. And I already change another DUE board, but it still can’t work.

Here is the video link:


int val = 200;//forward speed
int VAL = 200;
int delaytime = 250;
int i;
void setup() 
 Serial.begin(9600); // setup serial 

void loop() 
   for( i=1; i<=10; i++)
//  digitalWrite(10,LOW);
//  digitalWrite(11,HIGH);
//  analogWrite(12,VAL);


You have not told us what motor driver you are using.

Please post a diagram showing how you have everything connected - and please DO NOT use Fritzing, a photo of a simple pencil drawing will be great. See this Simple Image Guide


Have you sorted out the problem of strange Serial monitor output in your other thread ?

Here is the file of the hardware connection.

Hi, UKHeliBob. I already answer it in that question. The problem arises because I set analogWrite value wrong. Thanks for your attention.

Sorry, but that photo is practically useless in determining how things are connected.

You say that the motors do not run until you touch the pressure sensor yest the code has no reference to any inputs. You obviously have the pressure sensor connected for some reason.

Are you sure that the code you posted is actually being uploaded to the Due and that it is not running a different program ?

Yes, I'm sure, I even try another DUE board.
The hardware is for my whole project. The code is just for testing motor movement.
I just try separate the unrelated modules connected to the DUE. The motor STILL can't rotate.

First try removing that for loop If you want to test motors just write to them once and put a delay in to give the motor time to get started. Writing many times a few microseconds apart is pointless and you may be doing it so often that the PWM output never gets established well enough for the driver to react.

If that doesn't do it check the wiring. If the motor really runs when you press the pressure sensor then maybe moving the pressure sensor wires affects some of the other wiring. Maybe something is shorted or poorly connected and moving the sensor wiring changes that. Look for damaged or broken wires in the motor circuitry.