<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[AtomMotion + PS4 Gamepad]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I'm trying to build a RC car with PS4 Gamepad as controller.<br />
If I connect the servo directly to the AtomLite and Pin25, it is working like a charm, with the following example:</p>
<pre><code>#include &lt;ESP32Servo.h&gt; 
#include &lt;PS4Controller.h&gt;

Servo myservo;
int servoPos = 0;
int servoPin = 25;

void setup(){
   ESP32PWM::allocateTimer(0);
   ESP32PWM::allocateTimer(1);
   ESP32PWM::allocateTimer(2);
   ESP32PWM::allocateTimer(3);
   myservo.setPeriodHertz(50);    // standard 50 hz servo
   myservo.attach(servoPin, 500, 2400);

  PS4.begin("4C:75:25:AD:78:7A");
  Serial.println("Ready.");
}

void loop() {

if (PS4.isConnected()) {
  servoPos =  (PS4.R2Value()) / 2;
  }

 myservo.write(servoPos);
 delay(100);
}
</code></pre>
<p dir="auto">but if I change to MotionBase it is very laggy.</p>
<pre><code>#include &lt;M5Atom.h&gt; 
#include "AtomMotion.h"
#include &lt;PS4Controller.h&gt;

AtomMotion Atom;
int servoPos;

void setup(){ 
  M5.begin(true, false, true);
  Atom.Init();

  PS4.begin("4C:75:25:AD:78:7A");
  Serial.println("Ready.");
}

void loop() {

     if (PS4.isConnected()) {
        servoPos =  (PS4.R2Value()) / 2;
     }
 
     Atom.SetServoAngle(1,servoPos);
     delay(100);
}
</code></pre>
<p dir="auto">What I'm doing wrong?</p>
]]></description><link>https://community.m5stack.com/topic/4408/atommotion-ps4-gamepad</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 21:00:05 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4408.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Jun 2022 12:15:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to AtomMotion + PS4 Gamepad on Thu, 14 Jul 2022 06:51:30 GMT]]></title><description><![CDATA[<p dir="auto">My board was defect, I changed the MotionBase , now it is working perfectly.</p>
]]></description><link>https://community.m5stack.com/post/17994</link><guid isPermaLink="true">https://community.m5stack.com/post/17994</guid><dc:creator><![CDATA[Cakedrinker]]></dc:creator><pubDate>Thu, 14 Jul 2022 06:51:30 GMT</pubDate></item><item><title><![CDATA[Reply to AtomMotion + PS4 Gamepad on Fri, 01 Jul 2022 09:53:41 GMT]]></title><description><![CDATA[<p dir="auto">I played a little bit with the sorce code and tried to write the register of the STM32 direclty over I2C.</p>
<pre><code>#include &lt;Wire.h&gt;
#include &lt;PS4Controller.h&gt;

#define SERVO_ADDRESS  0X38

int servoPos;

void setup() {
  Wire.begin (25, 21);
  PS4.begin("4C:75:25:AD:78:7A");
  Serial.println("Ready.");
}

uint8_t SetServoAngle(uint8_t angle)
{
  Write1Byte(SERVO_ADDRESS,0,angle);
  return 0;
}

void Write1Byte(uint8_t address,uint8_t Register_address,uint8_t data)
{
  Wire.beginTransmission(address);
  Wire.write(Register_address);
  Wire.write(data);
  Wire.endTransmission();
}

void loop() {
  if (PS4.isConnected()) {
     servoPos =  (PS4.R2Value()) / 2;
  }
  SetServoAngle(servoPos);
  delay(100);
}
</code></pre>
<p dir="auto">But the problems still exists, so maybe the problem is the FW of the STM32F030F4.</p>
]]></description><link>https://community.m5stack.com/post/17863</link><guid isPermaLink="true">https://community.m5stack.com/post/17863</guid><dc:creator><![CDATA[Cakedrinker]]></dc:creator><pubDate>Fri, 01 Jul 2022 09:53:41 GMT</pubDate></item></channel></rss>