# Motors reset() not consistently clearingCounts

**URL:** https://forum.makecode.com/t/motors-reset-not-consistently-clearingcounts/873
**Category:** EV3
**Created:** [December 8, 2019, 9:51pm UTC](https://forum.makecode.com/t/motors-reset-not-consistently-clearingcounts/873 "2019-12-08T21:51:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jeff](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jeff](https://forum.makecode.com/u/Jeff)
#### Post date: [December 8, 2019, 9:51pm UTC](https://forum.makecode.com/t/motors-reset-not-consistently-clearingcounts/873/1 "2019-12-08T21:51:37Z")

</div>

We were having issues calling some custom gyro code in a series of calls where it seemed like the code was just being skipped some times. This was very frustrating to the students. I reviewed the code and then did some testing

example (simplified down this is normally like a gyroFollow type code pattern):  
function Steer(heading: number, speed: number, maxAngle: number) {  
motors.largeBC.reset()  
while(Math.abs(motors.largeB.angle()) \< Math.abs(maxAngle) && Math.abs(motors.largeC.angle()) \<  
Math.abs(maxAngle)){  
motors.largeBC.steer(heading, speed);  
}  
}

Steer(10, 10, 500)  
Steer(20, -20, 500)  
Steer(20, 40, 300)  
Steer(20, 40, 300)

The problem is that reset() some times clears the counts and sometimes it doesn’t. There seems to be an odd timing issue the above code might only work for a couple of the calls to Steer. Now if you  
do this:  
Steer(10, 10, 500)  
pause(50)  
Steer(20, -20, 500)  
pause(50)  
Steer(20, 40, 300)  
pause(50)  
Steer(20, 40, 300)  
All of the calls work as expected. I took a quick look at output.ts and I do see it issuing motorBC.reset() does do a writePWM(mkCmd(out, DAL.opOutputClearCount, 0)) however if you look at the code for clearCounts() there is additional code.

What I found is that it is better to call  
motors.LargeB.clearCounts()  
motors.LargeC.clearCounts()

calling clearCounts() seems to be very consistent in clearing the counts where reset() is not.

---

<div class="post-metadata">

### Author: ![THEb0nny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theb0nny/32/3500_2.png) [@THEb0nny](https://forum.makecode.com/u/THEb0nny)
#### Post date: [September 1, 2026, 8:33pm UTC](https://forum.makecode.com/t/motors-reset-not-consistently-clearingcounts/873/2 "2026-09-01T20:33:11Z")

</div>

If possible, take a look at the MakeCode fork - BrickCode. If this happens again, I’ll take care of it.
