<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ndukwu Pius Onyema</title>
    <description>The latest articles on DEV Community by Ndukwu Pius Onyema (@ndukwu_pius).</description>
    <link>https://dev.to/ndukwu_pius</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F536252%2F25d00eed-b002-4ece-ae6b-a0def6a746e4.jpg</url>
      <title>DEV Community: Ndukwu Pius Onyema</title>
      <link>https://dev.to/ndukwu_pius</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ndukwu_pius"/>
    <language>en</language>
    <item>
      <title>What is Micropython????</title>
      <dc:creator>Ndukwu Pius Onyema</dc:creator>
      <pubDate>Fri, 15 Jan 2021 18:09:30 +0000</pubDate>
      <link>https://dev.to/ndukwu_pius/what-is-micropython-3dkh</link>
      <guid>https://dev.to/ndukwu_pius/what-is-micropython-3dkh</guid>
      <description>&lt;p&gt;Finding how to task my python skills with hardware has not been easy, because I had only microcontrollers. The issue with using a microcontroller to run python is its limited memory to run  python, the only viable option was to get a raspberry pi, but the cost of getting a computer like raspberry pi was way out of my league, but luckily for me, I heard a guy named &lt;strong&gt;Damien George&lt;/strong&gt; created a new version of python that can run on very little memory and is great for microcontrollers.&lt;/p&gt;

&lt;h6&gt;
  
  
  Why Micropython?
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt; Easy to learn: Python,itself is an easy language to learn, so micropython will not be an exception. Compared to the conventional c++ used for microcontrollers, micropython is easier to write. For example to toggle an led in C++ Arduino ,the code should look something like this
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const int LED_PIN=2;
const int BUTTON_PIN;
int ledState=HIGH;
void setup(){
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN,INPUT_PULLUP);
digitalWrite(LED_PIN,LOW);
}

void loop(){
ledState=digitalRead(BUTTON_PIN);

if(digitalRead(BUTTON_PIN)==1){
// if button was pressed
digitalWrite(LED_PIN,!ledState);
delay(500); // wait for half a sec
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But for micropython it is a simple as this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// this example is for a pyboard
import pyb
button = pyb.Switch()

while true:
      sw.callback(lambda:pyb.LED(1).toggle())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes it that simple&lt;/p&gt;

&lt;p&gt;Also when it comes to quoting long strings micro python is way easier.&lt;br&gt;
let assume this is our text&lt;/p&gt;

&lt;p&gt;&lt;em&gt;hjdbkhfknbjkHBKDVDdkdbkbdkbkjkjBJBKDBjkbdkhdbKDBJDBJKFBJDBkjbdkbfjkbJKBJKBbkbfkBFJKBDJBJdbbdjbnLUkegkdbfkbKD,N kdkdkjd KHDHDVNM hhJHbkeBK VDJKvj dljkdbjbbJbhdkavKBFKAdhbkjbfuhfKJBFJBfkBJKDBKbkjkbjBHBDKdhkndjagdfkjadhdbfkhjbdkhfvhvakhbidghfbkbadbjbafhjbvhvhfbkhabahdgyetkfrhfiabfhfkjksbkjf&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To quote this in C++ i will have to quote each line, like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"hjdbkhfknbjkHBKDVDdkdbkbdkbkjkjBJBKDBjkbdkhdbKDB"
"JDBJKFBJDBkjbdkbfjkbJKBJKBbkbfkBFJKBDJBJdbbdjbnL"
"UkegkdbfkbKD,N kdkdkjd KHDHDVNM hJH bkBK VDJKvj" 
"dljkdbjbbJbhdkavKBFKAdhbkjbfuhfKJBFJBfkBJKDBKbkj"
"kbjBHBDKdhkndjagdfkjadhdbfkhjbdkhfvhvakhbidghfbk"
"badbjbafhjbvhvhfbkhabahdgyetkfrhfiabfhfkjksbkjf"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But for micropython i just have to "triple quote"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""hjdbkhfknbjkHBKDVDdkdbkbdkbkjkjBJBKDBjkbdkhdbKD
BJDBJKFBJDBkjbdkbfjkbJKBJKBbkbfkBFJKBDJBJdbbdjbnLU
kegkdbfkbKD,N kdkdkjd KHDHDVNM hhJHbkeBK VDJKvj        dljkdbjbbJbhdkavKBFKAdhbkjbfuhfKJBFJBfkBJKDBKbkjkb   jBHBDKdhkndjagdfkjadhdbfkhjbdkhfvhvakhbidghfbkbadb     
 jbafhjbvhvhfbkhabahdgyetkfrhfiabfhfkjksbkjf"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you are interested in learning micropython, you can visit &lt;a href="https://micropython.org"&gt;micropython.org&lt;/a&gt; there are documentations for the most common micro python boards. The most common and cheapest boards that can handle micropython in Nigeria are the  ESP8266 12E and ESP32 boards. &lt;br&gt;
To learn more about ESP8266 with micro-python click &lt;a href="https://docs.micropython.org/en/latest/esp8266/tutorial/intro.html"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn more about ESP32 with micro-python click &lt;a href="https://docs.micropython.org/en/latest/esp32/tutorial/intro.html"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Although micro-python is very easy to write, I would not recommend in for beginners because it is still a new language and doesn't have a lot of resources to help beginners unlike arduino that has been around for a long time, beginner friendly and has unlimited resources to help both pro's and beginners. In arduino there is a library for almost anything you can think of. so for newbies in the embedded system world I would advice you start with arduino.&lt;/p&gt;

&lt;p&gt;If you are a Nigerian and you are interested with learning micropython you can buy the ESP8266 board &lt;a href="https://wa.me/p/3998717593578631/2349047076406"&gt;here&lt;/a&gt;&lt;br&gt;
or the ESP32 &lt;a href="https://wa.me/p/3632806690107149/2349047076406"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>micropython</category>
      <category>python</category>
      <category>esp8266</category>
      <category>esp32</category>
    </item>
  </channel>
</rss>
