Spark Core RC Car Kit with Motor Shild and US-020 Ultrasonic Ranging Sensor

I built the Spark Core RC Car Kit and it works fine. Then I decided to add an ultrasonic ranging sensor (US-020) and I’m having some problems.
The motor shield, according to its manual, is using pins D1, D3, D4, A7 that correspond to arduinos pins 5, 4, 7, 6.
To trigger the ultrasonic sensor I’m using D5, that corresponds to arduinos pin 8.
My problem is that when I activate the motors (D1 and A7 HIGH), the D5 output have some pulses from time to time, I can see them in the oscilloscope. I’m using the RC Car sample code.
Anyone has seen this kind of problem?
Thanks in advance,

I think it is the motor shield that is introducing some noise / instability. If I take it out the signal looks much better. Anyone is experiencing this kind of problem?

Some good news, I’m using an interrupt to save the time and calculate the length of the ultrasonic data line pulse and it works great! I get similar results on the application side and oscilloscope. I’m using the micros() function and despite the manual saying its not implemented yet, it works great.
Now I just need to fix the noise / instability issue. Any help will be appreciated :slight_smile:

1 Like

Hi @pedro_nf,

Sounds like a fun project! I haven’t tested this code myself, but @jeffp (I think?) posted an example here

Good luck!

His code is similar to mine :slight_smile:
But I still have to figure out the instability on the trigger pin. I don’t have time to do it now, I’ll post some info on that later.

Sounds like you have either some ground bounce, or potentially the EM field of the motors are coupling into your sensor wiring. You can try shielding your sensor wires and terminating the shield on one end at one of the ground pins of the Core. You could also twisting your sensor feedback wire together with the return ground wire to reduce the size of the loop antenna.

How have you wired up your sensor? Is it going directly to the Core?

Also have you seen this pulseIn() library?

1 Like

Hi Pedro,

How do you control the car? I stranded there :wink:
Requesting through the cloud API gave a too high delay I think…


I had some problems with a sonar detector so I didn’t finish the car.
Effectively the communication speed is too slow for a real time control of the car.
So I decided to add the sonar and make an autonomous car with just some basic user control. But for now I don’t have time to finish it

I think @will had a nice locally controlled RC car demo at Shenzhen Maker Faire, @will, do you have that code to share?