Changing pin of servo - Printable Version

+- JJRobots COMMUNITY (http://forums.jjrobots.com)
+-- Forum: JJrobots (/forumdisplay.php?fid=1)
+--- Forum: B-Robot (/forumdisplay.php?fid=2)
+--- Thread: Changing pin of servo (/showthread.php?tid=1850)

Changing pin of servo - shukmeister - 12-17-2018 01:43 AM


I want to modify the servo code of the B-Robot EVO2 to work from the 32u4's Analog Pin 2 instead of Digital Pin 10: https://github.com/jjrobots/B-ROBOT_EVO2/blob/master/Arduino/BROBOT_EVO2/Servos.ino#L72

There seems to be a lot of complicated bit register logic, which I don't understand well.

According to https://www.arduino.cc/en/Hacking/PinMapping32u4, analog pin 2 is (ADC5/TMS) PF5, and digital pin 10 is (PCINT6/OC1B/OC4B/ADC13) PB6.

I tried changing OC4B (pin 10) to ADC5, TMS, and PF5, but the sketch wouldn't compile.

Does anyone know how to switch the pins?

RE: Changing pin of servo - shukmeister - 12-17-2018 04:09 AM

Alternatively, I can just use the Servo arduino library, but the brobot uses timer 1 and that conflicts with the Servo library. Is there any way to get the BROBOT to use another time for steppers instead of timer 1?

RE: Changing pin of servo - JJrobots JP - 12-21-2018 10:12 AM

The thing is: The B-robot uses almost the 99% of the 32u4 processor. And both TIMERs to precisely control the Wheels in order to keep the balance. Changing the PIN is not straightforward as it will conflict with... timers.