<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gabriel Contreras Delgado on Medium]]></title>
        <description><![CDATA[Stories by Gabriel Contreras Delgado on Medium]]></description>
        <link>https://medium.com/@gabriel.contreras06d?source=rss-47fdf02e03d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p6_smrc5suyda7qb</url>
            <title>Stories by Gabriel Contreras Delgado on Medium</title>
            <link>https://medium.com/@gabriel.contreras06d?source=rss-47fdf02e03d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:43:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gabriel.contreras06d/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python vs Arduino IDE Within RC System Controls]]></title>
            <link>https://medium.com/@gabriel.contreras06d/python-vs-arduino-ide-within-rc-system-controls-820bc97b2fb9?source=rss-47fdf02e03d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/820bc97b2fb9</guid>
            <category><![CDATA[rc-cars]]></category>
            <category><![CDATA[microcontrollers]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[hardware-programming]]></category>
            <category><![CDATA[arduino-ide]]></category>
            <dc:creator><![CDATA[Gabriel Contreras Delgado]]></dc:creator>
            <pubDate>Fri, 19 Sep 2025 08:50:05 GMT</pubDate>
            <atom:updated>2025-09-19T08:50:05.807Z</atom:updated>
            <content:encoded><![CDATA[<p>Last year, during my freshman year as an undergraduate Manufacturing Engineering student at Cal Poly Pomona, I got involved in a technical project offered by CPP’s SHPE (Society of Hispanic Professional Engineers) chapter. The project was a complete design and construction of a 1/12 scale RC car. Working in a small group of two other members, we carried this project through both semesters that year. Our group, composed of a mechanical engineer, an industrial engineer, and myself, had little experience with electrical systems and the coding required to operate such systems.</p><p>As the project progressed mechanically, our group overlooked the electronics and coding for the majority of its duration. This issue manifested itself once the deadline was upon us. Aside from several mechanical issues we were still short of resolving due to time constraints, as often happens with engineering projects, we were ultimately unsuccessful in integrating the electrical system with the mechanical design.</p><p>Reflecting back on this project in which I contributed mainly as the mechanical lead, it is clear that assigning my groupmate, a mechanical engineer, the electrical systems and coding aspect assuming it would be simple was a big mistake. While we were able to get motors and servos to move individually, the coding required to fully execute the demands of a fully integrated RC car was far more complex than we had expected.</p><p>Now, as a second-year student taking a Python coding class, I can’t help but wonder what implications this new knowledge and skill set could have had on my previous project. The entire project’s electrical system was coded using Arduino IDE, which runs off a version of C++. After doing some research, I discovered that Arduino microcontrollers are in fact compatible with Python coding, specifically through the use of MicroPython, a separate implementation of Python designed to work with microcontrollers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*e1BjCT0HHmY83nJpF-6iGA.png" /></figure><p>As someone who thoroughly enjoyed the project last year and who is planning on redesigning and adding to it as part of my own personal project this year, I now know not to overlook the electrical and coding side of it. For this task I decided to start by considering the foundation on which the entire system would be built: the coding program. By comparing the use of MicroPython to Arduino within RC system control applications, I hope to set myself up for success by using the program most compatible with the project’s needs, which I will further explore here.</p><p>One of the aspects we overlooked previously was the use of velocity control for the motors. The drivetrain we used was a 3D-printed belt drive system that blew apart immediately upon use. The force needed to overcome the system’s inertia was already very high, and without velocity control, the 3D-printed chain stood no chance against the powerful DC motors. If I had known how to code this at the time, I would have implemented it then. Since I am still in the process of refining my coding skills, I turned to an increasingly popular resource within the coding community, ChatGPT. I prompted it to write the code required for velocity control of a single motor using Arduino IDE (C++). Below are the results</p><pre>// Pin assignments<br>const int motorPin = 9;   // PWM pin connected to motor driver (Enable pin)<br>const int dirPin1  = 7;   // Direction pin 1<br>const int dirPin2  = 8;   // Direction pin 2<br><br>// Velocity variable (0 - 255)<br>int motorSpeed = 0;<br><br>void setup() {<br>  pinMode(motorPin, OUTPUT);<br>  pinMode(dirPin1, OUTPUT);<br>  pinMode(dirPin2, OUTPUT);<br><br>  // Set initial direction (forward)<br>  digitalWrite(dirPin1, HIGH);<br>  digitalWrite(dirPin2, LOW);<br><br>  // Start with motor stopped<br>  analogWrite(motorPin, motorSpeed);<br>}<br><br>void loop() {<br>  // Example: ramp speed up<br>  for (motorSpeed = 0; motorSpeed &lt;= 255; motorSpeed += 5) {<br>    analogWrite(motorPin, motorSpeed);<br>    delay(100);  // small delay so you can see the speed ramp<br>  }<br><br>  delay(1000);  // hold at max speed<br><br>  // Ramp speed down<br>  for (motorSpeed = 255; motorSpeed &gt;= 0; motorSpeed -= 5) {<br>    analogWrite(motorPin, motorSpeed);<br>    delay(100);<br>  }<br><br>  delay(1000);  // hold stopped<br>}</pre><p>After doing some more research, I will attempt to explain this code as best as I can. The pin assignments at the top are each assigned to different outputs. There are two outputs that send direction control, in this case dirPin1 and dirPin2. The difference between the high and low voltage outputs between the two pins tells the motor which way to go. For example, if the voltage on dirPin1 is high while dirPin2 is low, the motor will move forward. The third pin, motorPin, uses PWM (Pulse Width Modulation) output to control the speed of the motor. To explain it simply, PWM is a rapidly oscillating &quot;on/off&quot; switch. The intervals in which the switch is on and off are called the &quot;duty cycle.&quot; The motor then uses this and takes the average power delivered within the duty cycle to determine velocity.</p><p>I then asked it to perform the same coding task, only this time using MicroPython instead of Arduino IDE. It came up with this.</p><pre>from machine import Pin, PWM<br>from time import sleep<br><br># Pin assignments (adjust as needed)<br>motor_pwm = PWM(Pin(15))   # PWM pin connected to motor driver enable<br>dir1 = Pin(13, Pin.OUT)    # Direction pin 1<br>dir2 = Pin(14, Pin.OUT)    # Direction pin 2<br><br># Configure PWM frequency (typical ~1 kHz for motor control)<br>motor_pwm.freq(1000)<br><br>def set_motor(speed):<br>    &quot;&quot;&quot;<br>    Set motor speed and direction.<br>    speed: -100 to 100 (negative = reverse, positive = forward)<br>    &quot;&quot;&quot;<br>    if speed &gt; 0:<br>        dir1.value(1)<br>        dir2.value(0)<br>    elif speed &lt; 0:<br>        dir1.value(0)<br>        dir2.value(1)<br>    else:<br>        dir1.value(0)<br>        dir2.value(0)  # brake / stop<br><br>    duty = min(abs(speed), 100)  # clamp speed to 0–100<br>    motor_pwm.duty_u16(int(duty * 65535 / 100))  # scale to 16-bit PWM<br><br><br># Example: ramp up and down<br>while True:<br>    # Ramp forward<br>    for s in range(0, 101, 10):<br>        set_motor(s)<br>        sleep(0.2)<br><br>    sleep(1)<br><br>    # Ramp backward<br>    for s in range(0, -101, -10):<br>        set_motor(s)<br>        sleep(0.2)<br><br>    sleep(1)</pre><p>After reviewing this code and comparing it to the code used for the same task written with Arduino IDE, I realized that the process in which they work is primarily the same, but the formatting and logical processing are vastly different. Both codes use the previously described PWM system to determine velocity. Both codes use two pin values to determine direction. The way this information is processed and interpreted, however, is quite different.</p><p>Arduino IDE runs its setup() code once and then uses a loop to continuously run through the program indefinitely. This means that the entire system is locked into place as soon as the code is compiled and uploaded. The code is stored directly on the hardware, and any changes require new iterations of the code to be recompiled and reuploaded to the system.</p><p>Python, however, works a little differently for this application. The code is interpreted directly on the hardware instead of being compiled beforehand and then shared. This means that changes and adjustments in the code will yield immediate results. The drawback to this approach is that some latency issues are possible as a result of live interpretation.</p><p>As a language, Python is also known to have a very straightforward “top-down” approach to code interpretation. As someone who currently possesses only a limited understanding of JavaScript and is just beginning to learn Python, coding as a whole is not second nature. For the applications of this project that I will be embarking on this year, I believe the ability to quickly edit and immediately run new code can be a game changer in the testing process. This flexibility will be especially crucial since I will lack the support of a larger team and time as a whole will be significantly more critical.</p><p>Given the research and comparison I have done today, I find myself leaning more and more towards MicroPython when considering the language I will invest my time into. While every language has its benefits and drawbacks, I find that Python might be the most forgiving choice for a very busy undergraduate who needs the freedom and simplicity it provides.</p><p>Work Cited:</p><p><a href="https://chatgpt.com/">https://chatgpt.com/</a></p><p><a href="https://www.arduino.cc/en/software/">https://www.arduino.cc/en/software/</a></p><p><a href="https://www.geeksforgeeks.org/electronics-engineering/arduino-coding-basics/">https://www.geeksforgeeks.org/electronics-engineering/arduino-coding-basics/</a></p><p><a href="https://realpython.com/micropython/">https://realpython.com/micropython/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820bc97b2fb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>