<?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>Forem: Halldor Stefansson</title>
    <description>The latest articles on Forem by Halldor Stefansson (@halldorstefans).</description>
    <link>https://forem.com/halldorstefans</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%2F113085%2F01dec832-ff88-4f65-84f6-064139ebeec9.jpeg</url>
      <title>Forem: Halldor Stefansson</title>
      <link>https://forem.com/halldorstefans</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/halldorstefans"/>
    <language>en</language>
    <item>
      <title>Smartphone Controlled Arduino Car via Bluetooth</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Tue, 08 Feb 2022 21:27:02 +0000</pubDate>
      <link>https://forem.com/halldorstefans/smartphone-controlled-arduino-car-via-bluetooth-49d5</link>
      <guid>https://forem.com/halldorstefans/smartphone-controlled-arduino-car-via-bluetooth-49d5</guid>
      <description>&lt;h2&gt;
  
  
  Required Components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A chassis&lt;/li&gt;
&lt;li&gt;Arduino Uno&lt;/li&gt;
&lt;li&gt;Maker Drive driver&lt;/li&gt;
&lt;li&gt;Adafruit Bluefruit LE UART Friend&lt;/li&gt;
&lt;li&gt;Smartphone (Android or iPhone)&lt;/li&gt;
&lt;li&gt;Batteries (Example: 1 x 9V and 4 x AAA (1.5V))&lt;/li&gt;
&lt;li&gt;Servo Motor&lt;/li&gt;
&lt;li&gt;2 x DC Motors&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Circuit Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2MUXKWs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hbazs0z3vhisqnxmu7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2MUXKWs3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hbazs0z3vhisqnxmu7n.png" alt="Circuit Diagram" width="880" height="695"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The software is based on the &lt;a href="https://github.com/adafruit/Adafruit_BluefruitLE_nRF51"&gt;Adafruit Bluefruit&lt;/a&gt; and &lt;a href="https://github.com/CytronTechnologies/CytronMotorDriver"&gt;Cytron Motor Driver&lt;/a&gt; libraries.&lt;/p&gt;

&lt;p&gt;You can check out the code &lt;a href="https://github.com/halldorstefans/Bluetooth-Arduino-Car"&gt;here at GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Chassis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You could use most chassis with this tutorial. However, you might need to make some changes to the code where relevant. For example, if you only have two wheels, you need to change the servo code to make the motors turn the robot. &lt;/p&gt;

&lt;p&gt;The chassis I used is based on &lt;a href="https://thepihut.com/products/adafruit-mini-3-layer-round-robot-chassis-kit-2wd-with-dc-motors"&gt;this Robot Chassis Kit&lt;/a&gt;. I took the top plate and connected it with the bottom, sort of like an extension. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e5A9_RWh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mli8e83y1zfcmgkdgg8p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e5A9_RWh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mli8e83y1zfcmgkdgg8p.jpg" alt="Connection under chassis" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I built a custom steering system and joined that with the chassis. The steering system is not particularly good, but it does the job for now. I’m planning on building a better one later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gPmaqram--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uaqc9w3tvw7aqh7ox465.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gPmaqram--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uaqc9w3tvw7aqh7ox465.jpg" alt="Front-Wheel Steering" width="880" height="1173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;9V Battery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I used a 9V battery to power some of the peripherals in this project. The 9V battery seems to be a perfect power source for Arduino projects. But, &lt;a href="https://cybergibbons.com/arduino/arduino-misconceptions-6-a-9v-battery-is-a-good-power-source/"&gt;reading a bit upon&lt;/a&gt; power source uses for Arduino, the battery is OK to use but inefficient. I recommend researching the subject if you want to use a 9V battery in your projects. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setting up Bluefruit LE UART Friend
&lt;/h2&gt;

&lt;p&gt;These steps are based on the &lt;a href="https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/introduction"&gt;official documentation&lt;/a&gt;, and I recommend going through those as well.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Download the app&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start by downloading the Bluefruit &lt;a href="https://learn.adafruit.com/bluefruit-le-connect-for-ios"&gt;iOS App&lt;/a&gt; or &lt;a href="https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect&amp;amp;hl=en"&gt;Android App&lt;/a&gt;. Easily and quickly done.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Solder the pins - IMPORTANT!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The module comes with pins to make it easier to connect with a breadboard. I highly recommend soldering those pins to the module. The connection can be flaky otherwise and cause the module to be unreliable. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Wiring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I suggest starting with the default pinout in the &lt;a href="https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/wiring"&gt;documentation&lt;/a&gt;. That’s to make sure it works as intended. Then later, when adding peripherals to the project, test out other pins if needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Software Configurations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The code I used is built on the &lt;a href="https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/software"&gt;supplied Adafruit code&lt;/a&gt;. There are a few code changes that are needed for this project. &lt;/p&gt;

&lt;p&gt;First, make sure to uncomment this part in the &lt;code&gt;controller.ino&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create the bluefruit object, either software serial...uncomment these lines
SoftwareSerial bluefruitSS = SoftwareSerial(BLUEFRUIT_SWUART_TXD_PIN, BLUEFRUIT_SWUART_RXD_PIN);

Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                      BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;To match the wiring setup, you must adjust the PIN variables in &lt;code&gt;BluefruitConfig.h&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Default setup:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SOFTWARE UART SETTINGS
#define BLUEFRUIT_SWUART_RXD_PIN       9    // Required for software serial!
#define BLUEFRUIT_SWUART_TXD_PIN       10   // Required for software serial!
#define BLUEFRUIT_UART_CTS_PIN         11   // Required for software serial!
#define BLUEFRUIT_UART_RTS_PIN         8   // Optional, set to -1 if unused
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Final setup for the project:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SOFTWARE UART SETTINGS
#define BLUEFRUIT_SWUART_RXD_PIN       2   // Required for software serial!
#define BLUEFRUIT_SWUART_TXD_PIN       7   // Required for software serial!
#define BLUEFRUIT_UART_CTS_PIN         4   // Required for software serial!
#define BLUEFRUIT_UART_RTS_PIN         5   // Optional, set to -1 if unused
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hardware Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This simple step is also critical and can easily be missed. &lt;/p&gt;

&lt;p&gt;Set the MODE switch on the module to &lt;strong&gt;CMD&lt;/strong&gt; mode.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MihISZNY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsokj76y8zha4955sslw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MihISZNY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsokj76y8zha4955sslw.jpg" alt="CMD mode for Bluefruit" width="880" height="1173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Upload (and Update)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once everything has been connected and configured, it’s time to upload the code to the Arduino.&lt;/p&gt;

&lt;p&gt;When you first connect to the module, it will most likely need &lt;a href="https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/dfu-updates"&gt;updating&lt;/a&gt;. An update notification will pop automatically up in the app when you connect to it, and it won’t take long.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Control servo motor (for Front Wheel Steering)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I used a servo motor to control the front-wheel steering in this project. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The DC motors can steer the car if you’re not using front-wheel steering. See &lt;a href="https://tutorial.cytron.io/2019/03/28/line-following-robot-using-arduino-maker-drive/"&gt;this tutorial&lt;/a&gt; as an example.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Connecting the servo motor and adding relevant code changes is relatively straightforward. &lt;/p&gt;

&lt;p&gt;Before fastening the servo motor down, double-check everything works and what angles to use. Finding the correct angles for the servo motor to work well with the steering can be a bit of trial and error. &lt;/p&gt;

&lt;p&gt;These are the variables I added in  &lt;code&gt;BluefruitConfig.h&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SERVO SETTINGS
#define SERVO_PIN                     6
#define DEFAULT_ANGLE                 90
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;A servo motor object needs to be added to the main &lt;code&gt;.imo&lt;/code&gt; file, just under the Bluefruit object is good:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a new servo object:
Servo servoSteering;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;In the &lt;code&gt;setup(void)&lt;/code&gt; method, we need to initialise it:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Attach the Servo variable to a pin:
  servoSteering.attach(SERVO_PIN);
  servoSteering.write(DEFAULT_ANGLE);
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Finally, we can add the code to change the angle of the motor, for steering, based on which buttons are pressed in the app, for example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (pressed) {
      Serial.println(" pressed");
      if (buttnum == 7) {
        servoSteering.write(45);
      }
      if (buttnum == 8) {
        servoSteering.write(120);
      }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Warning!&lt;/strong&gt; - Be aware that when using the &lt;a href="https://www.arduino.cc/reference/en/libraries/servo/"&gt;Servo Arduino library&lt;/a&gt;, it disables &lt;code&gt;analogWrite()&lt;/code&gt;&lt;br&gt;
 (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. This took me a bit of time to figure out. ☹️&lt;/p&gt;
&lt;h2&gt;
  
  
  Running Servo Motor, Two DC Motors &amp;amp; Bluetooth Module At The Same Time
&lt;/h2&gt;

&lt;p&gt;Now to the fun part. Make the car drive.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Connect motors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.cytron.io/p-maker-drive-simplifying-h-bridge-motor-driver-for-beginner"&gt;documentation&lt;/a&gt; for the Maker Drive motor driver is also superb. In addition, it has &lt;a href="https://tutorial.cytron.io/2019/03/28/line-following-robot-using-arduino-maker-drive/"&gt;this tutorial&lt;/a&gt; that can be helpful as a guideline to connect everything correctly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modify software&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to add a few bits to our code to get the motors to run. We can use the &lt;a href="https://github.com/CytronTechnologies/CytronMotorDriver"&gt;Cytron Motor Driver&lt;/a&gt; library to help us with that.&lt;/p&gt;

&lt;p&gt;Similarly, as before, we add some settings for the pins in  &lt;code&gt;BluefruitConfig.h&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// MAKER DRIVE MOTOR SETTINGS
#define DRIVE_MOTOR_MODE              PWM_DIR
#define 1A_PIN                        11
#define 1B_PIN                        10
#define 2A_PIN                        3
#define 2B_PIN                        9
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We also create the motor objects at a similar place we added the servo object:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Configure the motor driver.
CytronMD motor1(DRIVE_MOTOR_MODE, 1A_PIN, 1B_PIN);
CytronMD motor2(DRIVE_MOTOR_MODE, 2A_PIN, 2B_PIN);
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;We then add a few methods to change the speed and directions of the motors:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void robotStop()
{
  motor1.setSpeed(0);
  motor2.setSpeed(0);
}

void robotForward()
{
  motor2.setSpeed(100);
  motor1.setSpeed(100);
}

void robotReverse()
{
  motor1.setSpeed(-100);
  motor2.setSpeed(-100);
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;And finally, we update the &lt;code&gt;loop(void)&lt;/code&gt; method where the buttons are pressed with the servo code changes:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (pressed) {
      Serial.println(" pressed");
      if (buttnum == 7) {
        servoSteering.write(45);
      }
      if (buttnum == 8) {
        servoSteering.write(120);
      }
      if (buttnum == 5) {
        robotForward();
      }
      if (buttnum == 6) {        
        robotReverse();
      }
    } else {
      Serial.println(" released");
      if (buttnum == 7 || buttnum == 8) {
        servoSteering.write(DEFAULT_ANGLE);
      }

      if (buttnum == 5 || buttnum == 6) {
        robotStop();
      }
    }
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Once that’s set up, built and uploaded, we’re almost ready to start driving around.&lt;/p&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Have multiple power sources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to make sure everything runs simultaneously alongside the Arduino. At first, I only had the 4 x AA batteries, but every time I tried to make a turn, the car just froze. &lt;/p&gt;

&lt;p&gt;That was because we have many peripherals and not enough power to supply them all. &lt;/p&gt;

&lt;p&gt;So I added a 9V battery to run the servo motor and Bluetooth module, while the AA batteries ran the DC motors, motor driver and the Arduino. &lt;/p&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Voila!
&lt;/h2&gt;

&lt;p&gt;It drives and turns 😃&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T5wTUE7j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1491148049686614021/pu/img/GQim-VcB39rQ5yhf.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--JAF6K7Q1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1484830994893058048/yO6WhR3s_normal.jpg" alt="Engineer-A-Car profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Engineer-A-Car
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @engineer_a_car
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/cytrontech"&gt;@cytrontech&lt;/a&gt; And voila! &lt;br&gt;It drives and steers through Bluetooth 🥳 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      20:35 PM - 08 Feb 2022
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1491148750475177987" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1491148750475177987" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1491148750475177987" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;





&lt;p&gt;I enjoyed working on this project, and I'm excited to start on the next one.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

&lt;p&gt;If you have any suggestions on improving, please don't hesitate to get in touch. I'm always keen on learning what can be done better.&lt;/p&gt;

</description>
      <category>arduino</category>
    </item>
    <item>
      <title>How to Design REST API Guidelines for Your Team (For the First Time)</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 23 Nov 2020 19:32:09 +0000</pubDate>
      <link>https://forem.com/halldorstefans/creating-the-company-s-api-guidelines-5g3</link>
      <guid>https://forem.com/halldorstefans/creating-the-company-s-api-guidelines-5g3</guid>
      <description>&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@barkiple?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;John Barkiple&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/connect?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;I recently took part in creating API guidelines for the company I work for. Even though I had little experience in working with APIs, I was trusted to lead the work. I want to share with you how that worked out.&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't have to be an expert to join
&lt;/h2&gt;

&lt;p&gt;Less than two months after joining &lt;a href="https://muddyboots.com/"&gt;Muddy Boots&lt;/a&gt;, I got an email saying there was a piece of work kicking off around designing the company's API guidelines, and if anyone was interested in joining that work.&lt;/p&gt;

&lt;p&gt;Even though I was new to the company, and with minimal knowledge on APIs, I expressed my interest immediately.&lt;br&gt;
I had worked on integrations before and was educating myself more and more on APIs. I thought that being part of this work and learning from others within that group would help me increase my knowledge of APIs.&lt;/p&gt;

&lt;p&gt;However, I had my doubts about whether I would be able to contribute anything instead of just sitting there and taking space.&lt;/p&gt;

&lt;p&gt;To calm those doubts, I started researching APIs as much as I could in my free time. Both by reading articles and &lt;a href="https://www.halldorstefans.com/building-my-first-api-from-scratch/"&gt;creating a new API from scratch&lt;/a&gt; to get some hands-on experience.&lt;/p&gt;

&lt;p&gt;So at least I would be able to understand what was being talked about and occasionally be able to add in some comments or ideas.&lt;/p&gt;

&lt;h2&gt;
  
  
  Taking the lead
&lt;/h2&gt;

&lt;p&gt;The initial working group included around nine people, mostly either architects or team/tech leads or representatives. And me.&lt;/p&gt;

&lt;p&gt;In the first few meetings, we worked on the scope, expected outcome and some basic definitions. We also started going through the first couple sections of the &lt;a href="https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md"&gt;Microsoft API Guidelines&lt;/a&gt;, since we were going to be using that as our base.&lt;/p&gt;

&lt;p&gt;I was pleased that I was able to contribute and bring in some thoughts in those initial meeting, mainly just based on some things that I had recently read.&lt;/p&gt;

&lt;p&gt;Then after a few meetings, I was approached by one of the architects, who lead the work, and asked if I wanted to take the lead of it.&lt;/p&gt;

&lt;p&gt;It was a big surprise to me.&lt;/p&gt;

&lt;p&gt;I initially had doubts about whether I should be taking part in this work at all initial, but now I was being asked to lead the work - Hello, imposter syndrome!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Who am I to lead a group of creating API guidelines for the company?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The architect currently had a lot on his plate, and based on the contributing I had made in the first meetings; he was confident that I would be able to step up.&lt;/p&gt;

&lt;p&gt;I was delighted with being trusted with this assignment and took the challenge. Thankfully I knew I had good people around me that would be able to help me.&lt;/p&gt;

&lt;h2&gt;
  
  
  10 steps to defining API guidelines for a company
&lt;/h2&gt;

&lt;p&gt;Now that I was in the lead of defining the API guidelines, I needed to figure out how to do just that.&lt;/p&gt;

&lt;p&gt;So, of to Google/Bing/DuckDuckGo - "How to design API guidelines for a company."&lt;/p&gt;

&lt;p&gt;And what do you know, &lt;a href="https://www.citrix.com/blogs/2019/07/11/defining-api-guidelines-for-a-company-what-works/"&gt;"Defining API guidelines for a company: What works?"&lt;/a&gt;, popped up, thankfully.&lt;/p&gt;

&lt;p&gt;So I decided I could use this guide as my cornerstone on how to define the API guidelines.&lt;/p&gt;

&lt;p&gt;Stepping through each step of the guide, here's how we did it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start with one API style and add more&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our case, it made the most sense to start creating a REST-ish (without hyperlinks) API guidelines.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gather a small working group&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After I took the lead, I brought this idea to the working group that we would minimize the group to create the first draft and then get that draft to the broader group for a review.&lt;br&gt;
The group accepted that idea, and we ended up a small core team of three.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stand on the shoulders of giants&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As mentioned, we used the Microsoft API Guidelines as our base. We had meetings every week, where we would go through the section(s) and modify for our purpose.&lt;br&gt;
Along with that, we had a small backlog where we would note down ideas, thoughts or concepts that we would need to discuss later on.&lt;br&gt;
Once we finished going through the Microsoft guidelines, we went through the backlog and added/modified sections based on our discussions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Take an open-source approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Confluence stored the guidelines because that's our collaboration tool. So anyone could have a look and review if interested.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Review and debate with a broad audience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once we finished our initial draft, we brought it to the broader group, that included architects and team leads or representatives, to review and discuss the draft.&lt;br&gt;
There were a few things that needed a bit of ironing out, but all in all, it was well-received.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Get formal sign-off&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the wider group was happy and signed it off, we brought it to an even wider group that included, for example, the head of production and head of technology, and more senior developers to get a formal sign-off.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Disseminate widely&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After the guidelines were signed-off, we distributed the guidelines in all of the relevant Teams channels, with a small summary.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a Slack/Teams channel for support&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There previously did exist a channel within Teams for APIs, so we were able to use that.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Make the guidelines available in PDF format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We didn't create a PDF of the guidelines since our guidelines live in Confluence and are easily accessible, and you're able to see the history of changes.&lt;br&gt;
But we did restructure the guidelines a bit better, so it would be easier to consume and find relevant sections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Train and socialize&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Work in progress. We have yet to work out how to do this, but it might be a small workshop or something.&lt;/p&gt;

&lt;p&gt;We still need to increase awareness and drive adoption of it. Hopefully, automated tools and processes can help with that.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'm delighted with how well this went and that we were able to deliver.&lt;/p&gt;

&lt;p&gt;I'm grateful for the opportunity to take part in and lead this work. I had great people around me who were able to help me, and I didn't feel uncomfortable when I thought my questions were stupid.&lt;br&gt;
Thanks to all who contributed to this work.&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>documentation</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Using pyboard to control two DC motors</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 09 Nov 2020 19:24:05 +0000</pubDate>
      <link>https://forem.com/halldorstefans/using-pyboard-to-control-two-dc-motors-5c9l</link>
      <guid>https://forem.com/halldorstefans/using-pyboard-to-control-two-dc-motors-5c9l</guid>
      <description>&lt;p&gt;This is part three in my series of building a small robot car. You can find the previous articles below:&lt;/p&gt;

&lt;p&gt;Part One: &lt;a href="https://www.halldorstefans.com/first-steps-creating-a-robot-with-micropython-and-pyboard/" rel="noopener noreferrer"&gt;First Steps Creating a Robot with MicroPython and Pyboard&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part Two: &lt;a href="https://www.halldorstefans.com/first-arduino-build-robot-car/" rel="noopener noreferrer"&gt;My First Arduino Built Robot Car&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I ended the last part wondering whether I should add some sensors to my robot, or replace the Arduino controller for a pyboard controller.&lt;/p&gt;

&lt;p&gt;Because my initial idea for this project was to use the pyboard, I decided I would start by replacing the controller and then later I could add some sensors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating pyboard firmware
&lt;/h2&gt;

&lt;p&gt;I've owned the pyboard for a few years now, but I've never really done much with it. I, therefore, suspected that the firmware might be out of date. So, the first item on the list was to update the firmware.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/micropython/micropython/wiki/Pyboard-Firmware-Update" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; for this is excellent, but I did run into a minor problem because I kept downloading the &lt;a href="https://micropython.org/download/pybv1/c" rel="noopener noreferrer"&gt;firmware for pyboard v1.0, but I had v1.1&lt;/a&gt;. Once I figured that out, it was quick and easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running one motor
&lt;/h2&gt;

&lt;p&gt;Once the pyboard was up to date, it was time to find out how to control one of the DC motors with it.&lt;/p&gt;

&lt;p&gt;After a bit of research, I found &lt;a href="https://rk.edu.pl/en/updating-pyboard-firmware-latest-micropython-features-and-fixes/#3" rel="noopener noreferrer"&gt;this article&lt;/a&gt;. Using that and the &lt;a href="http://docs.micropython.org/en/latest/pyboard/quickref.html#pwm-pulse-width-modulation" rel="noopener noreferrer"&gt;offical documentation for PWM&lt;/a&gt;, my initial code in &lt;a href="https://micropython.org/" rel="noopener noreferrer"&gt;micropython&lt;/a&gt; looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pyb&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt;

&lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tim2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;freq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tim2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PWM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pulse_width_percent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is how I connected it together, with the Maker Drive:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhsblogimages.blob.core.windows.net%2Fghost%2FmakerDrivePyboardOneMotor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fhsblogimages.blob.core.windows.net%2Fghost%2FmakerDrivePyboardOneMotor.png" alt="Maker-Drive and pyboard layout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/HalldorStefans/status/1323372242705764354" rel="noopener noreferrer"&gt;And this worked perfectly!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the second motor
&lt;/h2&gt;

&lt;p&gt;Based on the fact that I was using the X1 and X2 pins to run the first motor, and &lt;a href="https://micropython.org/resources/pybv11-pinout.jpg" rel="noopener noreferrer"&gt;the layout&lt;/a&gt;, I reckoned I could use the X3 and X4 pins for the second motor.&lt;/p&gt;

&lt;p&gt;So after adding the second motor, I made some changes to the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pyb&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt;

&lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tim2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;freq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tim2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PWM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pulse_width_percent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;p3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;X3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tim2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PWM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;p3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pulse_width_percent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila! Both motors were running. &lt;a href="https://twitter.com/HalldorStefans/status/1323376774202478592" rel="noopener noreferrer"&gt;What a beauty!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final touches
&lt;/h2&gt;

&lt;p&gt;Once everything was working correctly, I put it together with the chassis and updated the code a bit to make it drive into a kind of a circle :D&lt;/p&gt;

&lt;p&gt;You can see the current code and setup on my &lt;a href="https://github.com/halldorstefans/pyboardRobotCar" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm really pleased how well this went and honestly thought it would take longer.&lt;/p&gt;

&lt;p&gt;I'm going to put this project on to the side for a bit now. But the next item on the agenda for this project is to add some sensors to it and make them influence the driving.&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/" rel="noopener noreferrer"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>embedded</category>
      <category>electronics</category>
    </item>
    <item>
      <title>My First Arduino Built Robot Car</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 19 Oct 2020 15:56:24 +0000</pubDate>
      <link>https://forem.com/halldorstefans/my-first-arduino-built-robot-car-3beg</link>
      <guid>https://forem.com/halldorstefans/my-first-arduino-built-robot-car-3beg</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on my blog at &lt;a href="https://www.halldorstefans.com/first-arduino-build-robot-car/"&gt;halldorstefans.com&lt;/a&gt; on October 19, 2020&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This post is kind of a sequel to my previous post, &lt;a href="https://dev.to/halldorstefans/first-steps-creating-a-robot-with-micropython-and-pyboard-36cp"&gt;First Steps Creating a Robot with MicroPython and Pyboard.&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/halldorstefans" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IaLZU_PR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--1A7yAIA2--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/113085/01dec832-ff88-4f65-84f6-064139ebeec9.jpeg" alt="halldorstefans"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/halldorstefans/first-steps-creating-a-robot-with-micropython-and-pyboard-36cp" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;First Steps Creating a Robot with MicroPython and Pyboard&lt;/h2&gt;
      &lt;h3&gt;Halldor Stefansson ・ Jul 20 '20 ・ 3 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#microcontrollers&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#python&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#hardware&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;I know you'll see straight away that there's a contradiction between using Arduino vs Pyboard, but I'll get to that later, I promise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the motor(s)
&lt;/h2&gt;

&lt;p&gt;Continuing from where we left off in the last article, I was wondering how I could control two DC motors.&lt;br&gt;
After a bit of research, I found out that I could use an H-bridge chip to do that. &lt;a href="http://www.learningaboutelectronics.com/Articles/2-motor-H-bridge-circuit.php"&gt;How to Build an H-bridge Circuit to Control 2 Motors&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lucky me, I owned an Arduino starter kit, which included an H-bridge motor driver &lt;a href="https://www.arduino.cc/documents/datasheets/H-bridge_motor_driver.PDF"&gt;L293D&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using the above article, about building an H-bridge circuit, and the project book included in the Arduino kit, I started connecting everything up and looking forward to seeing the motors run.&lt;/p&gt;

&lt;p&gt;I started by connecting just one motor to make sure I got that right. Since the project book had one project doing precisely that, it was relatively straightforward, and the motor ran. Yay!&lt;/p&gt;

&lt;p&gt;Since that was pretty painless, then surely all I had to do was to connect the second motor, and that would be that, right?&lt;/p&gt;

&lt;p&gt;But, of course, it wasn't. Unfortunately, I couldn't get both motors running with the H-bridge I owned. Maybe it was broken, or I did something wrong, either way, I wasn't sure what to do.&lt;/p&gt;
&lt;h2&gt;
  
  
  Maker Drive saves the day
&lt;/h2&gt;

&lt;p&gt;So I started to search for a new one and see what it would cost. I also searched for some alternatives.&lt;br&gt;
That's when I found &lt;a href="https://www.cytron.io/p-maker-drive-simplifying-h-bridge-motor-driver-for-beginner"&gt;Maker Drive&lt;/a&gt;, a simplified H-bridge motor driver.&lt;/p&gt;

&lt;p&gt;Even though it's a simplified H-bridge and I'm confident I could figure out how to use a standard H-bridge to run the motors, it would be easier to get the motors running and then later I could upgrade to a standard H-bridge.&lt;/p&gt;

&lt;p&gt;Once the new motor driver arrived, it didn't take me long to get both motors running - credit to good documentation.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gC0Fz23N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1307635208854949889/pu/img/lbfgj_Pkll6f2IUi.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--48cvV-en--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1206592315843891201/Hj3xBHpE_normal.jpg" alt="Halldór Stefánsson profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Halldór Stefánsson
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="mentioned-user" href="https://dev.to/halldorstefans"&gt;@halldorstefans&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Back at it 😊&lt;br&gt;Motors working with the new motor driver ✅ 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      10:58 AM - 20 Sep 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1307635236654768131" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1307635236654768131" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1307635236654768131" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Connecting to an Arduino
&lt;/h2&gt;

&lt;p&gt;Ok, now the motors were running, but I needed something to control them. That's where I decided to go for Arduino over the Pyboard. For the same reason I chose Maker Drive over a standard H-bridge, I wanted the car up and running as soon as possible and then I could switch change the controller later.&lt;/p&gt;

&lt;p&gt;And after watching this video, &lt;a href="https://www.youtube.com/watch?v=SJ5bt8Wp5RU"&gt;Getting Started with Maker Drive and Arduino&lt;/a&gt;, it was pretty straightforward. I just followed the video and a few moments later, my car was running in circles just like the code implied. :D&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cXeRnyGF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1310649701600055297/pu/img/HKe_RpPwKDnMi1Pj.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--48cvV-en--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1206592315843891201/Hj3xBHpE_normal.jpg" alt="Halldór Stefánsson profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Halldór Stefánsson
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="mentioned-user" href="https://dev.to/halldorstefans"&gt;@halldorstefans&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      It's alive! 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      18:37 PM - 28 Sep 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1310649728225476609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1310649728225476609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1310649728225476609" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  What next?
&lt;/h2&gt;

&lt;p&gt;Woohoo, it works! Now what?&lt;/p&gt;

&lt;p&gt;Well, I've two possible next steps, and I'm not sure which way to go. Either I could make it more fun by adding some sensors to it, so it could drive around without crashing or drive around a track, or I could switch out the Arduino for the Pyboard.&lt;/p&gt;

&lt;p&gt;Since that was my initial idea, I'm leaning towards that. I could then later add the sensors, but I'm not sure.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>microcontrollers</category>
    </item>
    <item>
      <title>Tips and Actions to Build your Network</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Wed, 05 Aug 2020 13:03:12 +0000</pubDate>
      <link>https://forem.com/halldorstefans/tips-and-actions-to-build-your-network-1976</link>
      <guid>https://forem.com/halldorstefans/tips-and-actions-to-build-your-network-1976</guid>
      <description>&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@alinnnaaaa?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Alina Grubnyak&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/network?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;



&lt;p&gt;I just recently watched a YouTube video from &lt;a href="https://twitter.com/noahkagan"&gt;Noah Kagan&lt;/a&gt; called &lt;a href="https://www.youtube.com/watch?v=YodeBu7vUGY"&gt;"How to Build a Million Dollar Network?&lt;/a&gt;". &lt;br&gt;
It appealed to me since building a network is something I've recently started thinking more about. &lt;/p&gt;

&lt;p&gt;What I love about Noah is that he gives action steps on how to do something. &lt;br&gt;
And in this post, I want to follow one of his action and share with you the notes I took from that video.&lt;/p&gt;

&lt;p&gt;Some of the actions might not be possible at this moment in time, but you'll definitely find something you can act on today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask interesting friends for referrals
&lt;/h2&gt;

&lt;p&gt;Be specific:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In what city/school/company?&lt;/li&gt;
&lt;li&gt;Gender/personal specification&lt;/li&gt;
&lt;li&gt;Category/niche&lt;/li&gt;
&lt;li&gt;Whatever else&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"I'm in London for a month, who is the one person you hang out with when you come to London?"&lt;/li&gt;
&lt;li&gt;"Who is the most amazing person from city/school/company/category/niche that I should have lunch with?"&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reach out to one impressive/up-and-coming person weekly
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Start building the relationship early on&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Do exciting stuff (and people might come to you)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Start a blog/YouTube/newsletter&lt;/li&gt;
&lt;li&gt;Publish once a week for at least 90 days&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Make an intentional list of people you want to connect with:
&lt;/h2&gt;

&lt;p&gt;A. Who has a career you like?&lt;br&gt;
B. Who's working on something you're curious about?&lt;br&gt;
C. Who's working in an exciting company?&lt;/p&gt;

&lt;h2&gt;
  
  
  Take notes on podcasts/YouTube/webinars/posts and put online
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Send the notes to the creator and let them know (without expecting anything back)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Financially support someone
&lt;/h2&gt;

&lt;p&gt;Examples:&lt;br&gt;
A. Buy their stuff (Products, books, courses, etc.)&lt;br&gt;
B. Support their charity&lt;/p&gt;

&lt;h2&gt;
  
  
  Add value to someone without expectations
&lt;/h2&gt;

&lt;p&gt;A. Create something for them&lt;br&gt;
B. Look at how they are spending their time (and assist them)&lt;br&gt;
C. Compliment without expectations&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep a list of cool people in cities
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Then contact them when you're in that city&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Organize an online event
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Identify someone you want to connect with&lt;/li&gt;
&lt;li&gt;Make it worth it for them to sign up&lt;/li&gt;
&lt;li&gt;Promote and make a great event&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Join online communities
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Pick one of your passions&lt;/li&gt;
&lt;li&gt;Find 3 online groups&lt;/li&gt;
&lt;li&gt;Post and engage at least once a week for 90 days&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Hope you found this useful, have a great week!&lt;/p&gt;

&lt;p&gt;If you liked what you read, please consider signing up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Clean Inbox with 1 Email Rule and 1 Rule of Thumb</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 27 Jul 2020 18:53:21 +0000</pubDate>
      <link>https://forem.com/halldorstefans/clean-inbox-with-1-email-rule-and-1-rule-of-thumb-1md</link>
      <guid>https://forem.com/halldorstefans/clean-inbox-with-1-email-rule-and-1-rule-of-thumb-1md</guid>
      <description>&lt;p&gt;&lt;em&gt;Photo by Davide Baraldi on Unsplash&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;I'm a big fan of keeping things clean and simple and love finding ways that help me focus or be more productive.&lt;/p&gt;

&lt;p&gt;And keeping my inbox as clean as possible is one of those. Making sure I focus on the right things and find them easily.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Email Rule
&lt;/h2&gt;

&lt;p&gt;The email rule that I have in Outlook is this one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl45pav2398zlwruq887k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl45pav2398zlwruq887k.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whenever I'm CC'd in an email, the sender has decided for me that it's not a priority for me. Unless it's marked as 'High Importance'.&lt;/p&gt;

&lt;p&gt;This is great because then I don't have to waste time reading an email that has low relevance to my current task(s).&lt;/p&gt;

&lt;p&gt;Then when I have the time, I can read it.&lt;/p&gt;

&lt;p&gt;If I want to respond, I can do so without the guilt that my response is late since they weren't expecting an answer from me.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Rule of Thumb
&lt;/h2&gt;

&lt;p&gt;For every email I receive, I ask myself "Does this need a response from me, or do I need the information in this week?"&lt;/p&gt;

&lt;p&gt;If the answer is "No", I archive it.&lt;/p&gt;

&lt;p&gt;If I need to answer it, I archive the email once I've responded.&lt;/p&gt;

&lt;p&gt;If I get a response from my reply, I ask the above question again.&lt;/p&gt;

&lt;p&gt;If I need the information in the email for my current task(s), I keep it in the inbox until I no longer need it.&lt;/p&gt;

&lt;p&gt;If it's information that I will need later, for example, in two or three weeks, I archive it.&lt;/p&gt;

&lt;p&gt;Then when I need it, I'll search for it. And if I need to keep that for a few days, I move it to the inbox folder and then archive it when it's no longer needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  I'm Not a CEO
&lt;/h2&gt;

&lt;p&gt;These rules are the foundation for my clean inbox and have served me well. &lt;/p&gt;

&lt;p&gt;On the other hand, I don't receive hundreds of emails per day. So that also helps to keep the inbox clean. 😅&lt;/p&gt;

&lt;p&gt;Hope these rules will help you find rules to keep you focused and productive.&lt;/p&gt;




&lt;p&gt;If you liked what you read, please consider signing up to my &lt;a href="https://email.halldorstefans.com/" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>tips</category>
    </item>
    <item>
      <title>First Steps Creating a Robot with MicroPython and Pyboard</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 20 Jul 2020 18:02:05 +0000</pubDate>
      <link>https://forem.com/halldorstefans/first-steps-creating-a-robot-with-micropython-and-pyboard-36cp</link>
      <guid>https://forem.com/halldorstefans/first-steps-creating-a-robot-with-micropython-and-pyboard-36cp</guid>
      <description>&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@alexkixa?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Alexandre Debiève&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/electronics?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  What are MicroPython and PyBoard
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://micropython.org/"&gt;MicroPython&lt;/a&gt; is a software implementation of the Python 3 programming language, written in C, that is optimised to run on a microcontroller.&lt;/p&gt;

&lt;p&gt;It was &lt;a href="https://github.com/dpgeorge"&gt;Damien George&lt;/a&gt; who created MicroPython. He developed it along with running a Kickstarter campaign to fund it and the &lt;a href="http://docs.micropython.org/en/latest/pyboard/quickref.html"&gt;pyboard&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The pyboard is a compact and powerful electronics development board that runs MicroPython.&lt;/p&gt;

&lt;p&gt;The aim of MicroPython is not to replace C, but to provide a way to program microcontrollers using Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Build a Robot
&lt;/h2&gt;

&lt;p&gt;After &lt;a href="https://www.halldorstefans.com/why-i-took-udacitys-intro-to-self-driving-cars-nanodegree-and-was-it-worth-it/"&gt;finishing the 'Intro to Self Driving Cars' program&lt;/a&gt;, I wanted to build something, like a small car.&lt;/p&gt;

&lt;p&gt;And I wanted it to be able to drive around without crashing by sensing its environment.&lt;/p&gt;

&lt;p&gt;I started by buying a small &lt;a href="https://thepihut.com/products/adafruit-mini-3-layer-round-robot-chassis-kit-2wd-with-dc-motors"&gt;robot kit&lt;/a&gt;, which included a chassis, two DC motors, wheels, and a caster ball for balance.&lt;br&gt;
But of course, I would need something that would control the motors, and be the "driver".&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use MicroPython
&lt;/h2&gt;

&lt;p&gt;I already owned a pybord that I had bought about four or five years ago. But, since then, it had been a dust collector.&lt;/p&gt;

&lt;p&gt;I had written some small programs to turn the LEDs on and off, but that was it. I never tried to connect a component to it, and get that to work.&lt;/p&gt;

&lt;p&gt;I thus thought this would be an excellent opportunity to finally use the pyboard. But I didn't know how it worked.&lt;/p&gt;

&lt;p&gt;Therefore I didn't know how to get it to control my car.&lt;/p&gt;

&lt;h2&gt;
  
  
  First steps
&lt;/h2&gt;

&lt;p&gt;I needed to get familiar with the board and came across &lt;a href="http://docs.micropython.org/en/latest/pyboard/tutorial/index.html"&gt;these tutorials&lt;/a&gt; for the pyboard.&lt;br&gt;
The first ten tutorials are good to get started, needing only the pyboard, a USB cable and a computer. It's a helpful introduction to the board and its possibilities.&lt;/p&gt;

&lt;p&gt;In the second part of the tutorials, you'll need some components. But I didn't have them all so; I did only the ones where I did have the elements.&lt;br&gt;
It was a good feeling to get something physical to work.&lt;/p&gt;

&lt;p&gt;But the motors in the robot kit I bought are DC motors, and none of the tutorials demonstrated how to control them.&lt;/p&gt;

&lt;p&gt;So I wondered how to use the pyboard to control a DC motor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;Reading the description for the robot kit, I saw that run motors will need ~5V and 1.5 A.&lt;br&gt;
But according to &lt;a href="https://forum.micropython.org/viewtopic.php?t=79"&gt;this response&lt;/a&gt; on the MicroPython forum, the max current per pin is 25mA.&lt;br&gt;
We see there's a considerable gap between what the motors need and what the pyboard can provide.&lt;/p&gt;

&lt;p&gt;After a &lt;a href="https://forum.micropython.org/viewtopic.php?f=2&amp;amp;t=277&amp;amp;sid=b155e9c04bf7d79d45324b619f7c4e6d"&gt;bit of research&lt;/a&gt;, I realised that I needed something to control the motors.&lt;/p&gt;

&lt;p&gt;So my next steps are to understand better what I need and how to use it.&lt;/p&gt;




&lt;p&gt;If you liked what you read, please consider signing up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>microcontrollers</category>
      <category>python</category>
      <category>hardware</category>
    </item>
    <item>
      <title>Why I took Udacity's 'Intro to Self-Driving Cars' Nanodegree, and was it worth it?</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Tue, 07 Jul 2020 19:53:06 +0000</pubDate>
      <link>https://forem.com/halldorstefans/why-i-took-udacity-s-intro-to-self-driving-cars-nanodegree-and-was-it-worth-it-1194</link>
      <guid>https://forem.com/halldorstefans/why-i-took-udacity-s-intro-to-self-driving-cars-nanodegree-and-was-it-worth-it-1194</guid>
      <description>&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@dhruvsaranmehra?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Dhruv Mehra&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/toy-car?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
I've long been interested in cars, ever since collecting toy cars and playing on the classic road carpet.&lt;/p&gt;

&lt;p&gt;I also love everything that's automated. So I'm indeed curious about the self-driving technology and thought this program would be a good starting point.&lt;/p&gt;

&lt;h2&gt;
  
  
  To buy or not to buy
&lt;/h2&gt;

&lt;p&gt;However, there was still the question of investing time and money into it.&lt;/p&gt;

&lt;p&gt;Even though I had more free time due to the lockdown situation, the estimated time to finish was 2-3 months.&lt;br&gt;
Could I be using my time in something else?&lt;br&gt;
I already have a bachelor's degree in Mechatronics Engineering, would I be learning something new or just wasting my time and money?&lt;br&gt;
Should I maybe just straight to the 'Self Driving Car Engineer' program?&lt;/p&gt;

&lt;p&gt;When investing your time and money into something, it isn't easy to know whether it will be worth it in the end.&lt;/p&gt;

&lt;p&gt;So, what to do?&lt;/p&gt;

&lt;p&gt;To help me decide, I made a pros/cons list, did some research for online reviews and studied the program's syllabus and overview.&lt;/p&gt;

&lt;p&gt;I didn't find many reviews, but I did see &lt;a href="http://www.pathtolevel5.com/intro-to-self-driving-cars/"&gt;this one&lt;/a&gt;. It's quite a thorough review, and I recommend you read it if you're considering joining the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Taking the plunge
&lt;/h2&gt;

&lt;p&gt;I decided to give it a go.&lt;/p&gt;

&lt;p&gt;My main reasons were that it would help me refresh my Python and C++ skills, which I hadn't used much since university, and learn the basic concepts behind the self-driving technology.&lt;/p&gt;

&lt;p&gt;After a couple of weeks, things were going better than I had expected.&lt;/p&gt;

&lt;p&gt;I was dedicating at least an hour most weekdays on it, and also a few hours during the weekend.&lt;br&gt;
It also helped me that the material wasn't new to me; I had learned most of it in university.&lt;/p&gt;

&lt;p&gt;I'm not going to go into the material, but if you're curious about it, I suggest reading the above mentioned &lt;a href="http://www.pathtolevel5.com/intro-to-self-driving-cars/"&gt;review&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Halfway through the program, I realised this wasn't going to take me 2-3 months, and before I knew it, I had completed the program in about a month and a half.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Even though most of the content wasn't new to me, I don't regret investing in this program. It was nice to see that I was still able to program in Python and C++, and seeing that I hadn't forgotten everything on statistics and probability from the university.&lt;/p&gt;

&lt;p&gt;I also liked the tasks of optimising my LinkedIn and GitHub profiles. It forced me to go over those profiles and improve them.&lt;/p&gt;

&lt;p&gt;Overall I happy with the program, how it's structured and the quizzes and projects in the program.&lt;/p&gt;

&lt;p&gt;I'll definitely consider Udacity's programs again in the future, but I think for now I want to try to do some personal side-projects by my self.&lt;/p&gt;




&lt;p&gt;If you liked what you read, please consider signing up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>learning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>How I Customized The Swagger UI In ASP.NET Core</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 11 May 2020 11:43:38 +0000</pubDate>
      <link>https://forem.com/halldorstefans/how-i-customized-the-swagger-ui-in-asp-net-core-4bi1</link>
      <guid>https://forem.com/halldorstefans/how-i-customized-the-swagger-ui-in-asp-net-core-4bi1</guid>
      <description>&lt;p&gt;Photo by Ern Gan on Unsplash&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on my blog at &lt;a href="https://www.halldorstefans.com/how-i-customized-the-swagger-ui-in-asp-net-core/"&gt;halldorstefans.com&lt;/a&gt; on May 11, 2020&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Many of us use Swagger and Swashbuckle on ASP.NET Core to have some minimal documentation for our API.&lt;br&gt;
It's really easy to integrate with your API and gives a good overview of the available endpoints in the API.&lt;/p&gt;

&lt;p&gt;But you might find that the Swagger UI doesn't fit your colour scheme and/or want to replace the Swagger branding with your own. Thankfully the steps to change that are rather simple.&lt;/p&gt;

&lt;p&gt;Below are the changes I made in order to make the UI more fitting for my API.&lt;/p&gt;
&lt;h2&gt;
  
  
  Route Update
&lt;/h2&gt;

&lt;p&gt;The default Swagger UI page is under &lt;code&gt;myapp.com/swagger/index.html&lt;/code&gt;. But you can change the &lt;code&gt;/swagger/&lt;/code&gt; part.&lt;br&gt;
I, for example, changed my route to &lt;code&gt;/docs/&lt;/code&gt;.&lt;br&gt;
This can be done with few simple changes in the &lt;code&gt;Startup&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void Configure(...)
{
    ...
    app.UseSwagger(options =&amp;gt;
    {
        options.RouteTemplate = "docs/{documentName}/docs.json";
    });

    app.UseSwaggerUI(options =&amp;gt;
    {
        options.SwaggerEndpoint("/docs/v1/docs.json", "My API V1");

        options.RoutePrefix = "docs";
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Replace Swagger Icon/Logo
&lt;/h2&gt;

&lt;p&gt;The Swagger logo can be seen both in the favicon and in the topbar, on the top left corner of the site.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Favicon
&lt;/h3&gt;

&lt;p&gt;To change the favicon, the first step is to make sure you have your favicon. &lt;a href="https://realfavicongenerator.net/favicon/aspnet_core"&gt;RealFaviconGenerator&lt;/a&gt; is a great favicon generator if you need one.&lt;/p&gt;

&lt;p&gt;Once you have your favicon, you need the create the directory &lt;code&gt;wwwroot/docs&lt;/code&gt; where the &lt;code&gt;docs&lt;/code&gt; part is from the Route Change above. So if you haven't changed your route, the directory would be &lt;code&gt;wwwroot/swagger&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You then copy-paste your favicon in that folder. Make sure the files &lt;code&gt;favicon.ico&lt;/code&gt;, &lt;code&gt;favicon-16x16.png&lt;/code&gt;, and &lt;code&gt;favicon-32x32.png&lt;/code&gt; are included.&lt;br&gt;
So, you should see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MnSSweoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://hsblogimages.blob.core.windows.net/ghost/swaggerCSS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MnSSweoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://hsblogimages.blob.core.windows.net/ghost/swaggerCSS.png" alt="Custom CSS folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also make sure that the application uses static files configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void Configure(...)
{
    ...
    app.UseStaticFiles();
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might need to press &lt;code&gt;Ctrl + F5&lt;/code&gt; for cache refresh for the favicon change to appear.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Topbar Logo
&lt;/h3&gt;

&lt;p&gt;Replacing the logo in the topbar means we need to do a little bit of CSS magic.&lt;/p&gt;

&lt;p&gt;A custom CSS file is needed under &lt;code&gt;wwwroot/swagger-ui/custom.css&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In that CSS file I added the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.topbar-wrapper&lt;/span&gt; &lt;span class="nt"&gt;img&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"Swagger UI"&lt;/span&gt;&lt;span class="o"&gt;],&lt;/span&gt; &lt;span class="nc"&gt;.topbar-wrapper&lt;/span&gt; &lt;span class="nt"&gt;span&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.topbar-wrapper&lt;/span&gt; &lt;span class="nc"&gt;.link&lt;/span&gt;&lt;span class="nd"&gt;:after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Unoffical McLaren F1 API'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This replaced the logo with a text, but you should be able to replace it with your own logo.&lt;/p&gt;

&lt;p&gt;Once that is ready, the following code needs to be added to include the custom CSS changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void Configure(...)
{
    ...
    app.UseStaticFiles();
    ...
    app.UseSwaggerUI(options =&amp;gt;
    {
        ...
        options.InjectStylesheet("/swagger-ui/custom.css");
        ...
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Change The Green Colour
&lt;/h2&gt;

&lt;p&gt;This part builds on the last one. I wanted to replace the default Swagger green colour with something else. In my case I replaced it with a red colour.&lt;/p&gt;

&lt;p&gt;So here I added to the custom CSS file created earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;    &lt;span class="nc"&gt;.swagger-ui&lt;/span&gt; &lt;span class="nc"&gt;.topbar&lt;/span&gt; &lt;span class="nc"&gt;.download-url-wrapper&lt;/span&gt; &lt;span class="nc"&gt;.select-label&lt;/span&gt; &lt;span class="nt"&gt;select&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#EF1C25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.swagger-ui&lt;/span&gt; &lt;span class="nc"&gt;.info&lt;/span&gt; &lt;span class="nc"&gt;.title&lt;/span&gt; &lt;span class="nt"&gt;small&lt;/span&gt;&lt;span class="nd"&gt;:last-child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#EF1C25&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Else?
&lt;/h2&gt;

&lt;p&gt;It's also possible to inject a custom JavaScript, in the same way as the CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void Configure(...)
{
    ...

    app.UseSwaggerUI(options =&amp;gt;
    {
        ...
        options.InjectJavascript("/swagger-ui/custom.js");
        ...
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So with the custom CSS and JavaScript you can really customize the UI to your liking.&lt;/p&gt;




&lt;p&gt;You can see my outcome &lt;a href="https://mclarenapi.azurewebsites.net/docs/index.html"&gt;here&lt;/a&gt; and the source code &lt;a href="https://github.com/halldorstefans/McLarenAPI"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hopefully this helped.&lt;br&gt;
Have a great day.&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>dotnet</category>
      <category>sideprojects</category>
      <category>tips</category>
    </item>
    <item>
      <title>Using SQLite in .NET Core Azure Web App</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 27 Apr 2020 11:34:09 +0000</pubDate>
      <link>https://forem.com/halldorstefans/using-sqlite-in-net-core-azure-web-app-3n55</link>
      <guid>https://forem.com/halldorstefans/using-sqlite-in-net-core-azure-web-app-3n55</guid>
      <description>&lt;p&gt;Photo by Verne Ho on Unsplash&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on my blog at &lt;a href="https://www.halldorstefans.com/using-sqlite-in-net-core-azure-web-app/"&gt;halldorstefans.com&lt;/a&gt; on 27. April 2020&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is going to be a short demonstration on how I use SQLite in my API hosted in Azure.&lt;/p&gt;

&lt;p&gt;Few assumptions I'm making:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your application is finished and you're ready to deploy to Azure&lt;/li&gt;
&lt;li&gt;Your database is not big&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This demonstration is based on &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-webapp-using-vscode?view=aspnetcore-3.1"&gt;this tutorial&lt;/a&gt; from Microsoft&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a Release Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open your terminal and make sure you're in the right folder.&lt;br&gt;
In my case, that was at the same level as the '.sln' file was.&lt;br&gt;
If you don't have a '.sln' file, maybe your have a '.csproj' file.&lt;/p&gt;

&lt;p&gt;Run the following command to create a release package in a subfolder called publish:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet publish -c Release -o ./publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Copy database to the new folder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This step is kinda the only difference versus the Microsoft tutorial :)&lt;/p&gt;

&lt;p&gt;Copy-Paste your database, for example 'my.db', into the newly created 'publish' folder.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Publish to Azure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are few ways to publish to Azure.&lt;/p&gt;

&lt;p&gt;I usually start in the &lt;a href="//portal.azure.com"&gt;portal&lt;/a&gt; and create what I need there.&lt;/p&gt;

&lt;p&gt;Then, since I'm using Visual Studio Code and have the Azure App Service extension, I do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click the publish folder and select Deploy to Web App...&lt;/li&gt;
&lt;li&gt;Select the subscription I want to use to create the Web App&lt;/li&gt;
&lt;li&gt;Select the Web App I want to deploy to&lt;/li&gt;
&lt;li&gt;Hit 'deploy' in the pop-up window&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Set Connection String&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the app has been deployed to Azure, you set your connection string in the Azure App Service.&lt;/p&gt;

&lt;p&gt;You can find the setting under &lt;em&gt;Settings -&amp;gt; Configuration -&amp;gt; Connection strings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There you create a new connection string, for example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;SQLiteConnection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;td&gt;Data Source=mydb.db;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Type&lt;/td&gt;
&lt;td&gt;Custom&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Ready&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your application will now use the database in the publish folder that was deployed to Azure.&lt;/p&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hope this helped.&lt;/p&gt;

&lt;p&gt;If you want to migrate from SQLite to Azure SQL Database, you can use &lt;a href="https://docs.microsoft.com/en-us/azure/sql-database/tutorial-sqlite-db-to-azure-sql-serverless-offline"&gt;this tutorial&lt;/a&gt; for that. &lt;br&gt;
&lt;em&gt;I did try to do this, but I was in a hurry and it failed. Might try again later.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sqlite</category>
      <category>dotnet</category>
      <category>azure</category>
    </item>
    <item>
      <title>Building My First API From Scratch</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Mon, 20 Apr 2020 15:31:00 +0000</pubDate>
      <link>https://forem.com/halldorstefans/building-my-first-api-from-scratch-2bpa</link>
      <guid>https://forem.com/halldorstefans/building-my-first-api-from-scratch-2bpa</guid>
      <description>&lt;p&gt;Photo by Glen Carrie on Unsplash&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on my blog at &lt;a href="https://www.halldorstefans.com/building-my-first-api-from-scratch/"&gt;halldorstefans.com&lt;/a&gt; on April 20, 2020&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recently I joined a small group within my company, and we aimed to improve the Integration API for a specific product.&lt;/p&gt;

&lt;p&gt;The problem was that under a specific load, the API threw a bunch of errors.&lt;/p&gt;

&lt;p&gt;But I had a problem of my own.&lt;br&gt;
The API architecture was way more complicated than I had encountered in &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&amp;amp;tabs=visual-studio"&gt;online tutorials&lt;/a&gt;.&lt;br&gt;
I, therefore, didn't understand how it all worked and wondered if I would be able to contribute anything to this task.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get the knowledge I need?
&lt;/h2&gt;

&lt;p&gt;This opportunity was something I found interesting and had offered my help, so I was eager to contribute to it.&lt;br&gt;
But seeing that it was going to be more complicated than I thought, I wondered if I was going to be wasting everyone's time.&lt;/p&gt;

&lt;p&gt;I knew that I learn things quicker if I'm able to build them on my own.&lt;br&gt;
But was there going to any time for me to do that? What would I even build?&lt;/p&gt;

&lt;p&gt;Building the whole API, similar or part of it would be too big and time-consuming. And I would probably end up copy-pasting already existing code and learn nothing.&lt;/p&gt;

&lt;p&gt;So I started to exploring online what kind of API projects people were doing.&lt;br&gt;
It was hard to find a project of the right size. Too small and straightforward and I wouldn't learn much, but too big would be time-consuming and the high possibility of being way over my head and drop the project.&lt;br&gt;
I then came across the &lt;a href="https://pokeapi.co/"&gt;Pokémon API&lt;/a&gt; by &lt;a href="https://twitter.com/phalt_"&gt;Paul Hallett&lt;/a&gt;.&lt;br&gt;
A project like these seemed to be an ideal fit as a side project for me.&lt;br&gt;
Even though the API only has GETs, I was confident that I could create an API with a bit more complicated architecture than the typical beginners' tutorials. Might be overkill, but so be it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How am I going to build it?
&lt;/h2&gt;

&lt;p&gt;I still had some questions that I needed to figure out. What data could I provide? How could I build this API similar to my company's API?&lt;/p&gt;

&lt;p&gt;During my research on API projects, I came across something called "Clean Architecture".&lt;br&gt;
Being somewhat of a minimalized and having read Clean Code by Robert Martin not long ago, this appealed to me straight away.&lt;br&gt;
Plus this architecture was not far from how my company's API was structured.&lt;/p&gt;

&lt;p&gt;I found all kinds of &lt;a href="https://fullstackmark.com/post/18/building-aspnet-core-web-apis-with-clean-architecture"&gt;articles&lt;/a&gt;, &lt;a href="https://www.youtube.com/watch?v=_lwCVE_XgqI"&gt;videos&lt;/a&gt;, and &lt;a href="https://github.com/ardalis/CleanArchitecture"&gt;GitHub repos&lt;/a&gt;. I gathered as much as I could find on the topic, to help me understand it.&lt;/p&gt;

&lt;p&gt;But still, I wasn't programming anything yet because I hadn't figured out what my API would produce.&lt;br&gt;
It needed to be something I would be interested in; otherwise, I had the feeling I wouldn't be able to follow this project through.&lt;br&gt;
I looked at my interests and what data was available in those areas.&lt;/p&gt;

&lt;p&gt;Being a football(soccer)/Manchester United fan, I started looking in that area. Just looking at the English Premier League, I thought that was way too big.&lt;br&gt;
I could narrow it down just to Man United. But even then, I wondered how much data I needed to gather. All the players in the clubs' history, their stats, all the games? Even that seemed too big.&lt;/p&gt;

&lt;p&gt;What other interested to I have? Cars, I like cars. Could I gather information about one manufacturer and all the models that manufacture has created? Maybe.&lt;br&gt;
How about racing? Formula 1, perhaps? Is there any data on my favourite team in F1, McLaren? Hmm... &lt;a href="https://en.wikipedia.org/wiki/McLaren_Grand_Prix_results"&gt;this Wikipedia page&lt;/a&gt; is interesting.&lt;/p&gt;

&lt;p&gt;When I saw this page, I thought this could be perfect. I had all the races McLaren has taken part in and their result.&lt;br&gt;
I could even have a separate table for the cars and drivers, and have some information on them.&lt;/p&gt;

&lt;p&gt;I then noticed where Wikipedia was getting this data from, and ended up on &lt;a href="https://www.statsf1.com/en/mclaren.aspx"&gt;STATS F1&lt;/a&gt;.&lt;br&gt;
It was perfect. There was the data I wanted and structured.&lt;br&gt;
I, therefore, used that as my data structure. Awesome&lt;/p&gt;

&lt;h2&gt;
  
  
  Now, I could start programming
&lt;/h2&gt;

&lt;p&gt;So I started on the Core layer.&lt;br&gt;
Investigating all the Github repos I had found, and figuring out what was supposed to be where and how.&lt;/p&gt;

&lt;p&gt;Once I had roughly finished that part, I moved to the Infrastructure layer and then eventually the Web layer.&lt;br&gt;
Developing this was, of course, a bit of iterative progress, going back and forth in layers, fixing, adjusting and such.&lt;/p&gt;

&lt;p&gt;But, all this helped me better understand how the different layers were connected, deepening my knowledge of interfaces, getting more familiar with Entity Framework and LINQ.&lt;/p&gt;

&lt;p&gt;There was also a bit of frustration in this process (like always), especially around the naming of things.&lt;/p&gt;

&lt;p&gt;For example, items named '&lt;a href="https://github.com/mmacneil/CleanAspNetCoreWebApi/tree/master/src/Web.Api.Core/UseCases"&gt;UseCases&lt;/a&gt;', '&lt;a href="https://github.com/Tillman32/CleanArchitecture/tree/master/src/CleanArchitecture.Core/Service"&gt;Services&lt;/a&gt;' and '&lt;a href="https://github.com/cwoodruff/ChinookASPNETCore3APINTier/tree/master/ChinookASPNETCore3APINTier/Chinook.Domain/Supervisor"&gt;Supervisor&lt;/a&gt;' in different Github repos, all seemed to be doing the same action.&lt;br&gt;
But why are they named differently? Is there no convention on the naming of items or standards? I don't understand.&lt;/p&gt;

&lt;p&gt;It can sometimes be hard to identify if things are doing the same thing, or something completely different when trying to learn new things.&lt;br&gt;
In cases like this, I usually then focus on one solution and follow that. Once I understand that solution, I review the other solutions and see if they start making sense.&lt;/p&gt;

&lt;p&gt;I was finally able to make everything work together. It was such a great feeling when I was finally able to get that 200 response back.&lt;br&gt;
What a beauty!&lt;/p&gt;

&lt;h2&gt;
  
  
  Job done, almost
&lt;/h2&gt;

&lt;p&gt;It was a little bit tempting to say the project was over at that time.&lt;br&gt;
I had achieved what I wanted.&lt;br&gt;
Learned more about APIs and understood better what I was working on in work.&lt;/p&gt;

&lt;p&gt;But I wanted to keep the momentum going, so I decided to add versioning, Swagger documentation and some tests.&lt;/p&gt;

&lt;p&gt;The versioning and Swagger part was pretty straight forward. I found useful documentation from Microsoft, and it helped a lot.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Finding this was great because one of the tasks of improving the Integration API at work was to research and possible implement versioning. Which in the end I did implement :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now toward the last bit, testing.&lt;/p&gt;

&lt;p&gt;Adding testing to the project was going to be the final piece of the puzzle.&lt;br&gt;
I had never used xUnit before but wanted to learn more, so this seemed like an excellent opportunity.&lt;/p&gt;

&lt;p&gt;Even though the repositories I found on Clean Architecture had some tests, I wanted to see also other examples.&lt;br&gt;
I did a bit of research and found some great resources, for example, &lt;a href="https://timdeschryver.dev/blog/how-to-test-your-csharp-web-api"&gt;this article&lt;/a&gt; and &lt;a href="https://github.com/exceptionnotfound/XUnitMockTestsDemo"&gt;this repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I then started on the unit tests.&lt;br&gt;
After some time working on them, they weren't producing the results I wanted, so I wanted to skip doing the tests.&lt;br&gt;
Creating some tests, when the fun part is done, on some side project that possible no know is going to use. Why am I doing this?&lt;br&gt;
But I managed to plough through and get them to work.&lt;br&gt;
I still have some doubts about my unit tests and if they are entirely acceptable tests, but better than nothing, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep going
&lt;/h2&gt;

&lt;p&gt;In the end, I managed to build an API with clean architecture. I even managed to have versioning, documentation and tests. If you're curious how it looks at the moment, &lt;a href="https://github.com/halldorstefans/McLarenAPI"&gt;here is the GitHub repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Damn, I was proud.&lt;/p&gt;

&lt;p&gt;I know building a project can be frustrating but don't give up. It's such a great feeling when you finally manage to finish it.&lt;br&gt;
Thank you for reading and keep ongoing&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>rest</category>
    </item>
    <item>
      <title>Personal Dashboard Showing Calendar Events &amp; Weather Forecast Using .NET Core</title>
      <dc:creator>Halldor Stefansson</dc:creator>
      <pubDate>Thu, 24 Oct 2019 16:18:27 +0000</pubDate>
      <link>https://forem.com/halldorstefans/personal-dashboard-showing-calendar-events-weather-forecast-using-net-core-36gg</link>
      <guid>https://forem.com/halldorstefans/personal-dashboard-showing-calendar-events-weather-forecast-using-net-core-36gg</guid>
      <description>&lt;h2&gt;
  
  
  Idea
&lt;/h2&gt;

&lt;p&gt;I had this idea in my head that I want to display my calendar, the local weather forecast, and possibly some other things, on some screen.&lt;/p&gt;

&lt;p&gt;At first, I was thinking of doing a smart mirror (&lt;a href="https://www.hackster.io/SrivishnuTech/make-your-own-smart-mirror-for-under-80-using-raspberry-pi-a87460"&gt;Example 1&lt;/a&gt;, &lt;a href="https://www.howtogeek.com/414647/how-to-build-a-smart-mirror/"&gt;Example 2&lt;/a&gt;). But I wasn't sure if I wanted to put in all that work for something I might not use. Plus, since my woodworking skills aren't at the highest level, it would have been a pretty clumsy-looking mirror. :/&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware
&lt;/h2&gt;

&lt;p&gt;A couple of months ago, I came across this &lt;a href="https://thepihut.com/products/official-raspberry-pi-7-touchscreen-display"&gt;touchscreen display&lt;/a&gt; for Raspberry Pi and a &lt;a href="https://thepihut.com/products/raspberry-pi-official-7-touchscreen-case?variant=15155531396"&gt;case&lt;/a&gt; for it. I thought they were pretty neat-looking and would be perfect for my idea. So I ordered the display, the case and a new Raspberry Pi :)&lt;/p&gt;

&lt;p&gt;The first order of business was to connect and set up the screen. However, that was not as straight forward as I had hoped. I followed the &lt;a href="https://thepihut.com/blogs/raspberry-pi-tutorials/45295044-raspberry-pi-7-touch-screen-assembly-guide"&gt;assembly guide&lt;/a&gt;, but after powering on the Pi, the screen was just white, and nothing happened.&lt;/p&gt;

&lt;p&gt;I wondered if the Pi was broken or maybe the screen. Yet, the Pi worked if I connected it to a regular PC monitor. So, either the display was broken, or I was missing something.&lt;/p&gt;

&lt;p&gt;Finally, I found the solution on &lt;a href="https://raspberrypi.stackexchange.com/questions/34280/white-screen-on-touchscreen-display"&gt;StackExchange&lt;/a&gt;, and the problem was that I was missing the drivers. Once I installed them, everything worked 'almost' perfectly.&lt;/p&gt;

&lt;p&gt;The screen was upside down, but that was an &lt;a href="https://www.raspberrypi.org/forums/viewtopic.php?p=902849"&gt;easy fix&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Software
&lt;/h2&gt;

&lt;p&gt;After the display was up and running correctly, I needed to figure out how I was going to display the information I wanted.&lt;/p&gt;

&lt;p&gt;We all know that there are loads of tools available to do this, but I wanted to grow my .NET skills. And I came across a tutorial on building an application using ASP.NET Core called "&lt;a href="https://nbarbettini.gitbooks.io/little-asp-net-core-book/"&gt;The Little ASP.NET Core Book&lt;/a&gt;".&lt;/p&gt;

&lt;p&gt;Once I had gone through the tutorial, creating a to-do application, I figured I would be able to use this for my idea.&lt;/p&gt;

&lt;p&gt;The main items I wanted to display were my calendar and the weather forecast. I found this &lt;a href="https://developers.google.com/calendar/quickstart/dotnet"&gt;quickstart&lt;/a&gt; from Google for the Google Calendar API and used that as my base.&lt;/p&gt;

&lt;p&gt;I then found a &lt;a href="https://github.com/amweiss/dark-sky-core"&gt;.NET library for the Dark Sky API&lt;/a&gt;. Along with the forecast, I wanted to display a small image that would represent the forecast. I discovered &lt;a href="http://adamwhitcroft.com/climacons/"&gt;these awesome icons&lt;/a&gt; by &lt;a href="http://adamwhitcroft.com/"&gt;Adam Whitcroft&lt;/a&gt; and managed to integrate them into my solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design
&lt;/h2&gt;

&lt;p&gt;Once I was able to get all the data I needed, next on the agenda was to try to make it pretty.&lt;/p&gt;

&lt;p&gt;I was delighted when I encountered &lt;a href="https://freefrontend.com"&gt;freefrontend.com&lt;/a&gt; and some CSS examples. I found examples for &lt;a href="https://freefrontend.com/css-calendars/"&gt;calendars&lt;/a&gt;, &lt;a href="https://freefrontend.com/css-weather-widgets/"&gt;weather widgets&lt;/a&gt; and I also added the current date and &lt;a href="https://freefrontend.com/css-clocks/"&gt;time&lt;/a&gt; to my display.&lt;/p&gt;

&lt;p&gt;I haven't done much HTML/CSS work, so it took me some time to get everything to work together. But I was satisfied with the result once I ironed that out.&lt;/p&gt;

&lt;h2&gt;
  
  
  "Deployment"
&lt;/h2&gt;

&lt;p&gt;In "&lt;a href="https://nbarbettini.gitbooks.io/little-asp-net-core-book/"&gt;The Little ASP.NET Core Book&lt;/a&gt;" the author goes through &lt;a href="https://nbarbettini.gitbooks.io/little-asp-net-core-book/chapters/deploy-the-application/"&gt;two different deployment scenarios&lt;/a&gt;. On the one hand, using &lt;a href="https://nbarbettini.gitbooks.io/little-asp-net-core-book/chapters/deploy-the-application/deploy-to-azure.html"&gt;Azure&lt;/a&gt;, and on the other with &lt;a href="https://nbarbettini.gitbooks.io/little-asp-net-core-book/chapters/deploy-the-application/deploy-with-docker.html"&gt;Docker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Both deployment strategies failed for me.&lt;/p&gt;

&lt;p&gt;Once I had deployed the application in Azure, I was unable to open the page and got a "Timed Out" error. And my Dockerfile always failed when building.&lt;/p&gt;

&lt;p&gt;Because I wanted to test this as soon as possible on my Raspberry Pi display, I didn't bother to figure out what went wrong at this time. So, I used a USB stick to move the solution.&lt;/p&gt;

&lt;p&gt;However, my Raspberry didn't have .NET Core, so I was unable to run it there. Thankfully I found a guide on how to install it on a Raspberry Pi in a &lt;a href="https://www.hanselman.com/blog/InstallingTheNETCore2xSDKOnARaspberryPiAndBlinkingAnLEDWithSystemDeviceGpio.aspx"&gt;blog post by Scott Hanselman&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once that was installed, I was able to run the application. I needed to make minor CSS adjustments so it would fit the smaller screen better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Updates
&lt;/h2&gt;

&lt;p&gt;I'm pleased about how good it looks, and how neat the display is. And it fits well on top of the shoe cabinet.&lt;/p&gt;

&lt;p&gt;I'm not 100% sure at the moment if I'll make some improvements but examples of the things I could do/add are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Add/update more data from Dark Sky&lt;/li&gt;
&lt;li&gt;  Fix the deployment process&lt;/li&gt;
&lt;li&gt;  Display my &lt;a href="https://todoist.com"&gt;ToDoist&lt;/a&gt; list&lt;/li&gt;
&lt;li&gt;  Motion sensor&lt;/li&gt;
&lt;li&gt;  Voice assistant (&lt;a href="https://mycroft.ai/"&gt;Mycroft&lt;/a&gt;?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading :D&lt;/p&gt;

&lt;p&gt;PS Here is a similar project I found, using Python and an E-Ink display: &lt;a href="https://www.hackster.io/johnjones4/dresser-top-dashboard-913ed3"&gt;&lt;em&gt;Dresser Top Dashboard&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Thank you for reading. For weekly updates from me, you can sign up to my &lt;a href="https://email.halldorstefans.com/"&gt;newsletter.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>raspberrypi</category>
      <category>showdev</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
