Controlling a 5V PWM controlled fan causing errors in my HC 04 ultrasonic sensor

Hi

First time posting to this forum for help.

I am building a project to control the height of a ping pong ball in a tube.

Ive designed this to be powered solely buy an Arduino Uno (I hope)

I have a 5v (180ma) PWM controlled fan
And a HC 04 ultrasonic sensor 5v (15ma)

My connections are as follows
Fan
Power is from the 5v & Gnd on the Uno power rail
Control is from the Digital rail PWM pin 3

Sensor HC 04
Power is from the other 5v & Gnd on the Uno power rail
Control from pins 7 & 8 for echo and trigger.

Control is through LinX (Makerhub add-on) to Labview

At this point my fan is running and lifting the ball and my sensor is reading back. All good

The issue I am noticing is that the sensor reading is becoming erratic and unsettled when the fan is running from 30% to full power on and this is going to have an effect on my control system.

My first thought is that the Arduino can't provide enough power. but it should be capable of 500 ma power and 40 ma per pin which I am well within.

Am I right in saying the PWM pin to control the fan uses almost no current and is only a voltage control between 0-5 Volts and that the power / current to run the fan is from the power rail.

Or is it the case I have this wrong and require a mosfet to control the fan. but if so I would nt be getting the fan to run on full power at present.

Any help on this is much appreciated, Thanks

What I am noticing now is that my

Maybe it's a problem with electrical noise.

Try using two separate sources. one for sensor + arduino and one for fan, GND commom, or use optocoupler preferably. If the sensor stops receiving interference then it may be possible to use a filter (LC, RLC) to isolate the fan power if the use of two power supplies cannot be used in the final design.

Ref.: Don’t be the victim of electrical noise and EMI

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks… Tom… :slight_smile: