<?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[Simple PWM example does not work]]></title><description><![CDATA[<p dir="auto">I found a simple PWM example for the esp32 using Arduino IDE. This does not seem to work for and Atom Lite. Do I need to use another controller? Or something else missing.<br />
This is the example:<br />
const int ledPin = 22;<br />
const int freq = 5000;<br />
const int ledChannel = 0;<br />
const int resolution = 8;</p>
<p dir="auto">void setup() {<br />
Serial.println();<br />
ledcSetup(ledChannel, freq, resolution);<br />
ledcAttachPin(ledPin, ledChannel);<br />
}</p>
<p dir="auto">void loop() {<br />
for (int dutyCycle = 0; dutyCycle &lt;= 255; dutyCycle++) {<br />
ledcWrite(ledChannel, dutyCycle);<br />
delay(25);<br />
}<br />
for (int dutyCycle = 255; dutyCycle &gt;= 0; dutyCycle--) {<br />
ledcWrite(ledChannel, dutyCycle);<br />
delay(25);<br />
}<br />
Serial.print(".");<br />
}</p>
]]></description><link>https://community.m5stack.com/topic/6527/simple-pwm-example-does-not-work</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 04:47:56 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6527.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Jun 2024 15:32:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Simple PWM example does not work on Tue, 18 Jun 2024 16:05:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> The above finally worked with the M5StackSimpleServo library. However it turned out that I could only control speed and direction. Using degrees 0-90 for retraction and 90 - 180 for extending. It is not possible to position, this was finally confirmed by the seller. Again searching for actuators that can position.</p>
]]></description><link>https://community.m5stack.com/post/25598</link><guid isPermaLink="true">https://community.m5stack.com/post/25598</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Tue, 18 Jun 2024 16:05:18 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Thu, 06 Jun 2024 12:57:25 GMT]]></title><description><![CDATA[<p dir="auto">Tried to upload a small video to show both at work at once (with wrong extending). No privilege, not possible.</p>
]]></description><link>https://community.m5stack.com/post/25514</link><guid isPermaLink="true">https://community.m5stack.com/post/25514</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Thu, 06 Jun 2024 12:57:25 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Thu, 06 Jun 2024 12:52:06 GMT]]></title><description><![CDATA[<p dir="auto">For some reason it does something now. Not really sure what made it work. It did however change the frequency to 200. Somewhere I read that that was necessary for ESP32. It seems to be working.<br />
However, I can not position it the way I want and need it. It extracts not to the complete length of the rod (it should extract 12cm, it does about 7cm) and when retracting it keeps spinning as though it expects to retract more (that is in accordance to the not fully extending. So, anyone an idea? Something about the initial zero position and how to set this up?<br />
Below the current 'simple' code.</p>
<p dir="auto">#include &lt;M5Atom.h&gt;</p>
<p dir="auto">const int8_t linActPin1 = 33;<br />
const int8_t linActPin2 = 23;<br />
const int linActChannel1 = 1;<br />
const int linActChannel2 = 2;<br />
const int linActFreq = 200;<br />
const int linActResolution = 8;</p>
<p dir="auto">uint8_t method;</p>
<p dir="auto">void setup() {<br />
Serial.println();<br />
ledcSetup(linActChannel1, linActFreq, linActResolution);<br />
ledcAttachPin(linActPin1, linActChannel1);<br />
ledcSetup(linActChannel2, linActFreq, linActResolution);<br />
ledcAttachPin(linActPin2, linActChannel2);<br />
}</p>
<p dir="auto">void setServoPos(int8_t pos) {<br />
ledcWrite(linActChannel1, pos);<br />
ledcWrite(linActChannel2, pos);<br />
}</p>
<p dir="auto">void loop() {<br />
method = 1;<br />
Serial.print("O");<br />
for (int posDegrees = 0; posDegrees &lt;= 180; posDegrees++) {<br />
setServoPos(posDegrees);<br />
delay(50);<br />
}<br />
Serial.print("I");<br />
for (int posDegrees = 180; posDegrees &gt;= 0; posDegrees--) {<br />
setServoPos(posDegrees);<br />
delay(20);<br />
}<br />
Serial.print("-");<br />
}</p>
]]></description><link>https://community.m5stack.com/post/25513</link><guid isPermaLink="true">https://community.m5stack.com/post/25513</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Thu, 06 Jun 2024 12:52:06 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Thu, 06 Jun 2024 00:26:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a> Thanks. I asked the supplier for information, but what I posted earlier was what I got. With the help you gave, some help from ChatGTP and a lot of trying and experimenting I hope to find an answer. I'll let it now here. Thanks again for the help, it is much appreciated!</p>
]]></description><link>https://community.m5stack.com/post/25508</link><guid isPermaLink="true">https://community.m5stack.com/post/25508</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Thu, 06 Jun 2024 00:26:12 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 23:47:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> Here is the official M5Stack servo example:<br />
<a href="https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Hat/servo-hat/Arduino/SERVO/servo/servo.ino" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Hat/servo-hat/Arduino/SERVO/servo/servo.ino</a><br />
I mentioned earlier that the ledc library is difficult to set up the first time.<br />
But we don't know what signal the rod driver is looking for.<br />
ledc is used for LED dimming and RC servo motor control.<br />
But the setups are different.<br />
I wish you knew more about the rods and the tiny drivers.<br />
I looked for the rods on Google and they only had two wires. I did not know about the tiny drivers.</p>
<p dir="auto">-best of luck.</p>
]]></description><link>https://community.m5stack.com/post/25506</link><guid isPermaLink="true">https://community.m5stack.com/post/25506</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Wed, 05 Jun 2024 23:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 23:25:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a> Two wires go to the rod, but it seems they come from a PWM module (in the specs you can see that that is a tiny device). And that module has three wires, brown (ground I think), red (+5V perhaps), and orange (PWM wire?). I have tried different sketches also with the Arduino Library (not the right type). I did not try and did not find the ESP32 Servo Library yet.<br />
But perhaps I blew up the rods already. I do not know how vulnerable they are. Hope to find some sign of life in it.</p>
]]></description><link>https://community.m5stack.com/post/25505</link><guid isPermaLink="true">https://community.m5stack.com/post/25505</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Wed, 05 Jun 2024 23:25:18 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 17:14:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> These rods only appear to have 2 wires, not three.<br />
Therefore they need LM298 style motor drivers and will damage the output of the Atom.<br />
M5Stack similar product:<br />
<a href="https://docs.m5stack.com/en/unit/Hbridge%20Unit" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/unit/Hbridge Unit</a></p>
]]></description><link>https://community.m5stack.com/post/25500</link><guid isPermaLink="true">https://community.m5stack.com/post/25500</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Wed, 05 Jun 2024 17:14:47 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 10:21:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a> Thanks. A few questions. The  first ledcAttachPin does not apply here I presume. The math is not clear to me. 180 probably has to do with degrees, 2.000 perhaps frequency, then a 20.000.0 I do not understand, the 65536 is probably a 2 byte shift and then another number (16340 I do not understand. Perhaps you have a link to a site with some information about this.</p>
<p dir="auto">The rods I can not reposition by hand; or actually, I do not want to use force, it does not shift easily.</p>
<p dir="auto"><img src="/assets/uploads/files/1717582615087-actuators.jpg" alt="actuators.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">The coming few days I have less time, so maybe I do not respond, this not a lack of interest, but just other things that require my attention and or time.</p>
<p dir="auto">Thanks anyway, much appreciated.</p>
]]></description><link>https://community.m5stack.com/post/25495</link><guid isPermaLink="true">https://community.m5stack.com/post/25495</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Wed, 05 Jun 2024 10:21:01 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 01:20:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> Can you take a picture of it?<br />
It may be a RC servo motor rotating to power the screw.<br />
In which case you would use the cryptic 'ledc' library or a newer ESP32 Servo library.<br />
See M5Stack servo products.<br />
You should gingerly retract the rod and then control its position with ledc set for servo applications and select, program for smaller movements.</p>
<pre><code>#include &lt;esp32-hal-ledc.h&gt;
//in setup
ledcAttachPin(25, 1);

void SetServoPos(int pos) {
  ledcAttachPin(26, 1);
  delay(100);
  uint32_t duty = (((servoWritePos / 180.0)
                      * 2000)
                     / 20000.0 * 65536.0)
                    + 1634;
    ledcWrite(1, duty);
    delay(100);
    
  //ledcDetachPin(26);
  delay(100);
  posOld = pos;
}
</code></pre>
<p dir="auto">some samples that may not work for you, but to give you the idea</p>
]]></description><link>https://community.m5stack.com/post/25490</link><guid isPermaLink="true">https://community.m5stack.com/post/25490</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Wed, 05 Jun 2024 01:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Wed, 05 Jun 2024 00:12:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a> On the controllers it says Atom Lite, nothing more. Is there another way to distinguish them, does is otherwise say Atom Lite S3?<br />
I applied a separate power supply. This what the specs tell:</p>
<ol>
<li>The mini electric push actuator is equivalent to a linear motor : through the red and black two power lines to provide DC power supply DC 6-7.4V to the motor rotation, and drive the telescopic rod to achieve expansion, and stroke in any position can stop, can be self-locking.<br />
2.With PWM electric control : can be controlled by the receiver, can adjust the speed and direction.<br />
3.PWM module parameters :<br />
Weight:0.4g<br />
Size:12x8.5mm<br />
Voltage:3.5-6v<br />
Continuing current:1A ，The biggest current: 1.5A<br />
PWM range:1000~2000US<br />
BEC output: No<br />
Running direction: two-way, can be forward and reverse.<br />
Applicable motor:Brush motor.</li>
</ol>
<p dir="auto">Maybe this is enough. I could not get it working. Except for one moment it completely expanded, however I not reverse it or achieve another position. Hope you have some advice for me.</p>
]]></description><link>https://community.m5stack.com/post/25487</link><guid isPermaLink="true">https://community.m5stack.com/post/25487</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Wed, 05 Jun 2024 00:12:38 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Tue, 04 Jun 2024 18:20:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> The outputs are rated 20mA, so I always use a resistor, 330 - 1k Ohm.<br />
Is it Atom Lite or Atom Lite S3, makes a difference.<br />
The linear actuator will require a separate power supply, at minimum.<br />
What facts do you know about the 'linear actuator'?</p>
]]></description><link>https://community.m5stack.com/post/25483</link><guid isPermaLink="true">https://community.m5stack.com/post/25483</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Tue, 04 Jun 2024 18:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Mon, 03 Jun 2024 14:12:31 GMT]]></title><description><![CDATA[<p dir="auto">@All I finally added a second LED that I controlled with a digitalWrite and that worked fine (even better without the resistor used in the schematic). After playing with the connections (again) finally I saw the light (literally). I believe the contact of the pin in the Atom Lite does not make good contact (have to find something that does, otherwise quite unreliable). So this seem to work. Thank you guys for that.</p>
<p dir="auto">However I still have a question about using it for the linear actuator. It has a three wire input. A brown one, probably ground, a red one (5V? (document states Voltage 3.5 - 6V) and an orange one (control signal). I can not find much information about connecting such a device. Tried several setups with different frequencies (1000-2000), but nothing seems to work. Maybe an external adapter is needed. Any idea how to connect it?</p>
]]></description><link>https://community.m5stack.com/post/25471</link><guid isPermaLink="true">https://community.m5stack.com/post/25471</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Mon, 03 Jun 2024 14:12:31 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Mon, 03 Jun 2024 04:50:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> you did change the LED PIN number to match the atom did you?</p>
]]></description><link>https://community.m5stack.com/post/25467</link><guid isPermaLink="true">https://community.m5stack.com/post/25467</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Mon, 03 Jun 2024 04:50:58 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Sun, 02 Jun 2024 18:03:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> The Voltmeter measures the peak voltage and so pulses of 3.3 would measure as 3.3V despite the pulse width.</p>
]]></description><link>https://community.m5stack.com/post/25465</link><guid isPermaLink="true">https://community.m5stack.com/post/25465</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Sun, 02 Jun 2024 18:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Sun, 02 Jun 2024 16:27:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a><br />
The LED won't light up. However I did measure about 3.3V on the output pin before. I expected this to increase and decrease. It did not.<br />
Now I don't have time anymore, but when have another suggestion I will try it tomorrow.<br />
Thanks!</p>
]]></description><link>https://community.m5stack.com/post/25464</link><guid isPermaLink="true">https://community.m5stack.com/post/25464</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Sun, 02 Jun 2024 16:27:29 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Sun, 02 Jun 2024 16:16:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> Well, your code as supplied worked on a similar board that I have, an AtomS3. (I used pin 5) Your supplied code should work on your Atom Lite (non-S3 version).<br />
My observation is that the tiny decal on the back showing the pins is hard to read. It is easy to offset one pin.<br />
Does the LED light when across 3.3v to G ?</p>
]]></description><link>https://community.m5stack.com/post/25463</link><guid isPermaLink="true">https://community.m5stack.com/post/25463</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Sun, 02 Jun 2024 16:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Sun, 02 Jun 2024 15:52:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/teastain" aria-label="Profile: teastain">@<bdi>teastain</bdi></a></p>
<p dir="auto">For now a LED (but finally I hope to control a 5V linear actuator. The LED example is to experiment.</p>
]]></description><link>https://community.m5stack.com/post/25462</link><guid isPermaLink="true">https://community.m5stack.com/post/25462</guid><dc:creator><![CDATA[Kees]]></dc:creator><pubDate>Sun, 02 Jun 2024 15:52:25 GMT</pubDate></item><item><title><![CDATA[Reply to Simple PWM example does not work on Sun, 02 Jun 2024 15:44:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kees" aria-label="Profile: Kees">@<bdi>Kees</bdi></a> Atom Lite or Atom S3 Lite?</p>
<p dir="auto">What are you controlling with PWM?</p>
]]></description><link>https://community.m5stack.com/post/25461</link><guid isPermaLink="true">https://community.m5stack.com/post/25461</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Sun, 02 Jun 2024 15:44:40 GMT</pubDate></item></channel></rss>