<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[SparkFun Tutorials]]></title><description><![CDATA[SparkFun Tutorials]]></description><link>https://www.sparkfun.com/feeds/tutorials</link><image><url>https://www.sparkfun.com/favicon.ico</url><title>SparkFun Tutorials</title><link>https://www.sparkfun.com/feeds/tutorials</link></image><generator>https://rss.app</generator><lastBuildDate>Thu, 14 May 2026 10:48:27 GMT</lastBuildDate><atom:link href="https://rss.app/feeds/bNxSohcoe4jRurtu.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><item><title><![CDATA[Calibrating Your Odometry Sensor]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/2/0/9/SEN-24904-Optical-Tracking-Odometry-Sensor-Feature_1.jpg" style="width: 100%;" /><div><h1>
  Calibrating Your Odometry Sensor  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3639">http://sfe.io/t3639</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>The SparkFun Qwiic Optical Tracking Odometry Sensor empowers you to elevate your robot's navigation capabilities with exceptional precision and streamlined integration. This compact, all-in-one sensor leverages the power of the PAA5160E1 chip from PixArt Imaging Inc., delivering accurate dual-axis motion data across various hard floor surfaces. But that's not all! This sensor boasts a powerful built-in 6-axis Inertial Measurement Unit (IMU) and an onboard microcontroller that performs real-time sensor fusion and tracking algorithms.</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24904">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24904">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/2/0/9/SEN-24904-Optical-Tracking-Odometry-Sensor-Feature_1.jpg" alt="SparkFun Optical Tracking Odometry Sensor - PAA5160E1 (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24904">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24904" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24904 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24904"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24904">
          <span>SparkFun Optical Tracking Odometry Sensor - PAA5160E1 (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-24904    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Optical Tracking Odometry Sensor empowers you to elevate a robot's navigation capabilities with precision …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$79.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="3.2 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-half" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">5</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24904">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">56</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24904" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<p>In this tutorial, we will be going over how to calibrate your Qwiic Optical Tracking Odometry Sensor (or "OTOS") with Arduino and Python Examples. While we recommend using the OTOS with our XRP robotics platform (specifically for FTC teams), following this guide, you will be able to use the Odometry Sensor with any robot you feel comfortable with!</p>

<div class="flex-video-wrap clearfix">
  <div class="flex-video widescreen img">
    <iframe src="https://www.youtube.com/embed/WSELKAIJeFk/?autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen width="560" height="315"></iframe>
  </div>
</div>


<p>If you are looking for the <a href="https://docs.sparkfun.com/SparkFun_Optical_Tracking_Odometry_Sensor/">full Hookup Guide</a> for the SparkFun Qwiic Optical Tracking Odometry Sensor, click the button bellow. This guide only covers sensor calibration to get you started, while the full Hookup Guide goes over every detail of the sensor.</p>

<p><div class="center-block text-center"> <a href="https://docs.sparkfun.com/SparkFun_Optical_Tracking_Odometry_Sensor/" class="btn btn-default">View the Full Hookup Guide</a> </div></p>

<div class="alert alert-warning">
<b>Warning:</b> The laser on this module is a Class 1, 850nm laser, classified IEC 60825-1 2014. Please use appropriate caution while operating.</div>  <a name="#hardware-needed"></a>
  <h2 id="hardware-needed">Hardware Needed</h2>
  <p>To follow along with this tutorial, you may need the following materials. You may not need everything though depending on what you have and what robotics platform you are using. Again, while we recommend the XRP Kit, the choice is ultimately yours. Add it to your cart, read through the guide, and adjust the cart as necessary.</p>

<div class="row">
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24904">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24904">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/2/0/9/SEN-24904-Optical-Tracking-Odometry-Sensor-Feature_1.jpg" alt="SparkFun Optical Tracking Odometry Sensor - PAA5160E1 (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24904">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24904" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24904 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24904"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24904">
          <span>SparkFun Optical Tracking Odometry Sensor - PAA5160E1 (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-24904    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Optical Tracking Odometry Sensor empowers you to elevate a robot's navigation capabilities with precision …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$79.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="3.2 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-half" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">5</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24904">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">56</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24904" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-22230">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/22230">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/1/9/1/XRP_Robot-02.jpg" alt="Experiential Robotics Platform (XRP) Kit - Beta" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="22230">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_22230" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_22230 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_22230"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/22230">
          <span>Experiential Robotics Platform (XRP) Kit - Beta</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      KIT-22230    </span>

          <p class="description" style="display:none">
        The XRP Robotics Platform is a hands-on, comprehensive robotics platform and includes everything needed to build and program …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$114.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="22230">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">65</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="22230" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-15123">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/15123">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/3/4/9/2/15123-SparkFun_RedBoard_Qwiic-01a.jpg" alt="SparkFun RedBoard Qwiic" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="15123">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_15123" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_15123 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_15123"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/15123">
          <span>SparkFun RedBoard Qwiic</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      DEV-15123    </span>

          <p class="description" style="display:none">
        The SparkFun RedBoard Qwiic is an Arduino-compatible development board with a built in Qwiic connector, eliminating the need …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$21.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">20</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="15123">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">63</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="15123" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<div class="row">
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-25596">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/25596">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/6/1/5/1/CAB-25596-Flexible-Qwiic-to-STEMMA-Cable-Feature.jpg" alt="Flexible Qwiic to STEMMA Cable - 500mm" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="25596">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_25596" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_25596 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_25596"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/25596">
          <span>Flexible Qwiic to STEMMA Cable - 500mm</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      CAB-25596    </span>

          <p class="description" style="display:none">
        The Qwiic to STEMMA Adapter Cable allows interoperability between the SparkFun Qwiic Connect System and the I2C based STEMMA …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$2.10</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="25596">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">3</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="25596" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-14427">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/14427">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/2/4/5/3/14427-Qwiic_Cable_-_100mm-01.jpg" alt="Qwiic Cable - 100mm" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="14427">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_14427" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_14427 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_14427"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/14427">
          <span>Qwiic Cable - 100mm</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-14427    </span>

          <p class="description" style="display:none">
        This is a 100mm long 4-conductor cable with 1mm JST termination. It’s designed to connect Qwiic enabled components together…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="14427">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">43</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="14427" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-10215">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/10215">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/4/5/5/8/10215-01.jpg" alt="USB Micro-B Cable - 6 Foot" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="10215">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_10215" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_10215 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_10215"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/10215">
          <span>USB Micro-B Cable - 6 Foot</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      CAB-10215    </span>

          <p class="description" style="display:none">
        USB 2.0 type A to Micro-B 5-pin. This is a new, smaller connector for USB devices. Micro-B connectors are about half the heig…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$5.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.3 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">15</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="10215">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">23</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="10215" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>  <a name="#software-setup"></a>
  <h2 id="software-setup">Software Setup</h2>
  <h3>Arduino</h3>

<div class="alert alert-info">
<b>Attention:</b> If this is your first time using Arduino, please review our tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">installing the Arduino IDE</a>. If you have not previously installed an Arduino library, please check out our <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library">installation guide</a>.</div>

<p>We've written a library to get you started with the SparkFun Optical Tracking Odometry Sensor. You can obtain this library through the Arduino Library Manager by searching for "SparkFun Qwiic OTOS Arduino Library" and installing the latest version from SparkFun. If you prefer downloading libraries manually, you can grab them from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_OTOS_Arduino_Library">GitHub Repository</a>.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_OTOS_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">SparkFun Optical Tracking Odometry Sensor Arduino Library GitHub</a> </div></p>

<h3>Python</h3>

<div class="alert alert-info">
<b>Attention:</b> If this is your first time working with Python, there are quite a few useful tutorials on getting started. The <a href="https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/programming-in-python">Python Programming Section</a> of our Getting Started with the Raspberry Pi Tutorial has some good basic information and resources for getting started with Python.</div>

<p>In addition to the library provided above, we have written a Python script that allows you to visualize an XRP in real time. Download via the button below.</p>

<p><div class="center-block text-center"> <a href="https://docs.sparkfun.com/SparkFun_Optical_Tracking_Odometry_Sensor/assets/SparkFun_OTOS_XRP_Visualization.zip" class="btn btn-default">XRP Visualization Script</a> </div></p>

<h4>Linux/Raspberry Pi Variants</h4>

<p>We've written a python package to get you started with the SparkFun Optical Tracking Odometry Sensor. It's been included in the SparkFun Qwiic Python package, which aggregates all Python Qwiic drivers/modules to provide a single entity for Qwiic within a Python environment. The <a href="https://github.com/sparkfun/Qwiic_Py">Qwiic_Py GitHub Library ReadMe</a> has more information on the Qwiic Python package.</p>

<p>If you already have your Qwiic Python package installed, you can update it with the following command:</p>

<pre><code>pip install --upgrade sparkfun-qwiic
</code></pre>

<p>If you don't have the Qwiic Python package installed already, you can install it with the following command:</p>

<pre><code>pip install sparkfun-qwiic
</code></pre>

<p>If you prefer to install just this package, use the following command:</p>

<pre><code>pip install sparkfun-qwiic-otos
</code></pre>

<p>If you prefer downloading the code to build and install the package manually, you can grab them from the <a href="https://github.com/sparkfun/Qwiic_Py">GitHub Repository</a>.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/Qwiic_OTOS_Py/archive/refs/heads/master.zip" class="btn btn-default">SparkFun Optical Tracking Odometry Sensor Python Package GitHub</a> </div></p>

<div class="alert alert-info">
<b>Attention:</b> <p>If you are working with a Raspberry Pi and are using the new Bookworm distribution of the Raspberry Pi OS, refer to <a href="https://www.raspberrypi.com/documentation/computers/os.html#python-on-raspberry-pi">these instructions</a> to setup a virtual environment.</p>

<p>Make sure to include the --system-site-packages flag:python3 -m venv --system-site-packages</p>

<p>Then it is possible to install the packages using pip.</p></div>

<hr />

<h4>XRP/MicroControllers</h4>

<p>If you are working with the XRP or other microcontroller, pip will not work for you. Instead, you'll need to install the Qwiic_I2C_Py driver as well as the Qwiic_OTOS driver.</p>

<div class="alert alert-info">
<b>Attention:</b> These instructions are written for the XRP using the <a href="https://xrpcode.wpi.edu/">XRPCode IDE</a>. However the setup process is very similar for MicroPython and CircuitPython on any other board, so you should be able to follow along with these instructions using your IDE of choice!</div>

<h5>Install Qwiic_OTOS_Py</h5>

<p>Qwiic_I2C_Py is a generic I2C driver we have created to work on various platforms (such as MicroPython). Our Qwiic Python device drivers take advantage of Qwiic_I2C_Py to function correctly on any of the supported platforms, so it is a required dependency to use our OTOS Python driver.</p>

<p>Fist, go to the <a href="https://github.com/sparkfun/Qwiic_I2C_Py">Qwiic_I2C_Py repository</a> and download it as a .zip file. Once downloaded, extract the <code>qwiic_i2c</code> folder within.</p>

<p>Connect your XRP to your computer over USB, navigate to the <a href="https://xrpcode.wpi.edu/">XRPCode IDE</a>, and connect to your XRP. For usage information, see the <a href="https://xrpusersguide.readthedocs.io/en/latest/course/XRPCode.html">XRPCode User Guide</a>.</p>

<p>Create a new folder within the <code>lib</code> directory (right-click on the folder), and name it <code>qwiic_i2c</code>.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/new_folder.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/new_folder.png" alt="Create a new folder in the lib directory" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Create a new folder in the <code>lib</code> directory</em> </div></p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/new_folder_name.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/new_folder_name.png" alt="Name the folder qwiic_i2c" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Name the folder <code>qwiic_i2c</code></em> </div></p>

<p>Upload the files from the previously extracted <code>qwiic_i2c</code> folder into the new folder you just created on the XRP. From the <strong>File</strong> menu, choose the Upload to XRP option:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/upload.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/upload.png" alt="Choose the Upload to XRP option" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Choose the "Upload to XRP" option</em> </div></p>

<p>Then select the extracted files:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_qwiic_i2c_files.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/select_qwiic_i2c_files.png" alt="Select the extracted I2C Files" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Select the extracted I2C Files</em> </div></p>

<p>Then choose the newly created <code>qwiic_i2c</code> folder on the XRP:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_qwiic_i2c_upload_directory.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_qwiic_i2c_upload_directory.png" alt="Choose the newly created qwiic_i2c folder" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Choose the newly created <code>qwiic_i2c</code> folder</em> </div></p>

<p>Uploading...</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/update_in_progress.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/update_in_progress.png" alt="Update in Progress" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Update in Progress</em> </div></p>

<p>You can test to confirm correct installation by typing <code>import qwiic_i2c</code> followed by <code>qwiic_i2c.get_i2c_driver().scan()</code> in the Shell. If no errors are printed, then the Qwiic_I2C_Py driver has been installed correctly!</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/qwiic_i2c_test.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/qwiic_i2c_test.png" alt="Testing the I2C install" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Testing the install</em> </div></p>

<h5>Install Qwiic_OTOS_Py</h5>

<p>Fist, go to the <a href="https://github.com/sparkfun/Qwiic_OTOS_Py">Qwiic_OTOS_Py repository</a> and download just the <code>qwiic_otos.py</code> file.</p>

<p>Connect your XRP to your computer over USB, navigate to the <a href="https://xrpcode.wpi.edu/">XRPCode editor</a>, and connect to your XRP. For usage information, see the <a href="https://xrpusersguide.readthedocs.io/en/latest/course/XRPCode.html">XRPCode User Guide</a>.</p>

<p>Upload the <code>qwiic_otos.py</code> file into the <code>lib</code> folder on the XRP. From the File menu, choose the Upload to XRP option:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/upload.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/upload.png" alt="Select the Upload to XRP Option from the File Menu" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Select the "Upload to XRP" Option from the File Menu</em> </div></p>

<p>Select the qwiic_otos.py file:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_otos_file.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/select_otos_file.png" alt="Select the qwiic_otos.py file" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Select the qwiic_otos.py file</em> </div></p>

<p>Then select the lib folder on the XRP:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_qwiic_otos_upload_directory.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/select_qwiic_otos_upload_directory.png" alt="Select the lib folder on the XRP" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Select the <code>lib</code> folder on the XRP</em> </div></p>

<p>Updating...</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/update_in_progress.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/update_in_progress.png" alt="Updating" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Updating</em> </div></p>

<p>You can test to confirm correct installation by typing <code>import qwiic_otos</code> followed by <code>qwiic_otos.QwiicOTOS().is_connected()</code> in the Shell. If no errors are printed, then the Qwiic_OTOS_Py driver has been installed correctly!</p>

<p>Testing the install:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/qwiic_otos_test.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/qwiic_otos_test.png" alt="Testing the install" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Testing the install</em> </div></p>

<h4>Visualization</h4>

<p>In addition to the package provided here, we have written a Python script that allows you to visualize the XRP in real time. Download via the button below.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_OTOS_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">SparkFun Optical Tracking Odometry Sensor Arduino Library GitHub</a> </div></p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/SEN-24904-Action-GIF-1.gif"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/SEN-24904-Action-GIF-1.gif" alt="Visualization Script in Action" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Visualization Script in Action</em> </div></p>  <a name="#arduino-examples--calibration"></a>
  <h2 id="arduino-examples--calibration">Arduino Examples & Calibration</h2>
  <div class="alert alert-info">
<b>Attention:</b> All of the examples require the user to enter a key into the serial monitor before the example starts, which triggers the IMU calibration.</div>

<div class="alert alert-info">
<b>Attention:</b> The IMU on the Optical Tracking Odometry Sensor includes a gyroscope and accelerometer, which could have an offset. The OTOS performs a quick calibration when it powers up, but it is recommended to perform a more thorough calibration at the start of all your programs.</div>

<h3>Example 1: Basic Readings</h3>

<p>This first example just does some basic measurements to make sure everything is hooked up correctly. To find Example 1, go to <strong>File > Examples > SparkFun Qwiic OTOS > Example1_BasicReadings</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_1_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_1_Menu.jpg" alt="Finding Example 1" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Finding Example 1</em> </div></p>

<p>Alternatively, you can expand the link below and copy and paste the code into a shiny new Arduino sketch:</p>

<pre><code>/*
    SPDX-License-Identifier: MIT

    Copyright (c) 2024 SparkFun Electronics
*/

/*******************************************************************************
    Example 1 - Basic Readings

    This example demonstrates how to read the position and heading from the
    SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS).

    This example should be used to verify that the OTOS is connected and
    functioning correctly. It will just print the position and heading tracked
    by the OTOS to the serial monitor. It is recommended that you check out the
    other examples before using the OTOS in your own project.
*******************************************************************************/

#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
#include "Wire.h"

// Create an Optical Tracking Odometry Sensor object
QwiicOTOS myOtos;

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("Qwiic OTOS Example 1 - Basic Readings");

    Wire.begin();

    // Attempt to begin the sensor
    while (myOtos.begin() == false)
    {
        Serial.println("OTOS not connected, check your wiring and I2C address!");
        delay(1000);
    }

    Serial.println("OTOS connected!");

    Serial.println("Ensure the OTOS is flat and stationary, then enter any key to calibrate the IMU");

    // Clear the serial buffer
    while (Serial.available())
        Serial.read();
    // Wait for user input
    while (!Serial.available())
        ;

    Serial.println("Calibrating IMU...");

    // Calibrate the IMU, which removes the accelerometer and gyroscope offsets
    myOtos.calibrateImu();

    // Reset the tracking algorithm - this resets the position to the origin,
    // but can also be used to recover from some rare tracking errors
    myOtos.resetTracking();
}

void loop()
{
    // Get the latest position, which includes the x and y coordinates, plus the
    // heading angle
    sfe_otos_pose2d_t myPosition;
    myOtos.getPosition(myPosition);

    // Print measurement
    Serial.println();
    Serial.println("Position:");
    Serial.print("X (Inches): ");
    Serial.println(myPosition.x);
    Serial.print("Y (Inches): ");
    Serial.println(myPosition.y);
    Serial.print("Heading (Degrees): ");
    Serial.println(myPosition.h);

    // Wait a bit so we don't spam the serial port
    delay(500);

    // Alternatively, you can comment out the print and delay code above, and
    // instead use the following code to rapidly refresh the data
    // Serial.print(myPosition.x);
    // Serial.print("\t");
    // Serial.print(myPosition.y);
    // Serial.print("\t");
    // Serial.println(myPosition.h);
    // delay(10);
}
</code></pre>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, go ahead and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>. You should see something similar to the following.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_1_Output.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_1_Output.jpg" alt="Example 1 Output" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Example 1 Output</em> </div></p>

<hr />

<h3>Example 2: SetUnits</h3>

<p>This example sets the desired units for linear and angular measurements. Can be either meters or inches for linear, and radians or degrees for angular. If not set, the default is inches and degrees. Note that this setting is not stored in the sensor, it's part of the library, so you need to set at the start of all your programs.</p>

<p>To find Example 2, go to <strong>File > Examples > SparkFun Qwiic OTOS > Example2_SetUnits</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_Menu.jpg" alt="Finding Example 2" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Finding Example 2</em> </div></p>

<p>Alternatively, you can expand the link below and copy and paste the code into a shiny new Arduino sketch:</p>

<pre><code>/*
    SPDX-License-Identifier: MIT

    Copyright (c) 2024 SparkFun Electronics
*/

/*******************************************************************************
    Example 2 - Set Units

    This example demonstrates how to change the units of the SparkFun Qwiic
    Optical Tracking Odometry Sensor (OTOS).

    The OTOS library defaults to inches and degrees, but you can change the
    units to suit the needs of your project.
*******************************************************************************/

#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
#include "Wire.h"

// Create an Optical Tracking Odometry Sensor object
QwiicOTOS myOtos;

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("Qwiic OTOS Example 2 - Set Units");

    Wire.begin();

    // Attempt to begin the sensor
    while (myOtos.begin() == false)
    {
        Serial.println("OTOS not connected, check your wiring and I2C address!");
        delay(1000);
    }

    Serial.println("OTOS connected!");

    Serial.println("Ensure the OTOS is flat and stationary, then enter any key to calibrate the IMU");

    // Clear the serial buffer
    while (Serial.available())
        Serial.read();
    // Wait for user input
    while (!Serial.available())
        ;

    Serial.println("Calibrating IMU...");

    // Calibrate the IMU, which removes the accelerometer and gyroscope offsets
    myOtos.calibrateImu();

    // Set the desired units for linear and angular measurements. Can be either
    // meters or inches for linear, and radians or degrees for angular. If not
    // set, the default is inches and degrees. Note that this setting is not
    // stored in the sensor, it's part of the library, so you need to set at the
    // start of all your programs.
    myOtos.setLinearUnit(kSfeOtosLinearUnitMeters);
    // myOtos.setLinearUnit(kSfeOtosLinearUnitInches);
    myOtos.setAngularUnit(kSfeOtosAngularUnitRadians);
    // myOtos.setAngularUnit(kSfeOtosAngularUnitDegrees);

    // Reset the tracking algorithm - this resets the position to the origin,
    // but can also be used to recover from some rare tracking errors
    myOtos.resetTracking();
}

void loop()
{
    // Get the latest position, which includes the x and y coordinates, plus the
    // heading angle
    sfe_otos_pose2d_t myPosition;
    myOtos.getPosition(myPosition);

    // Print measurement
    Serial.println();
    Serial.println("Position:");
    Serial.print("X (Meters): ");
    Serial.println(myPosition.x, 4);
    Serial.print("Y (Meters): ");
    Serial.println(myPosition.y, 4);
    Serial.print("Heading (Radians): ");
    Serial.println(myPosition.h, 4);

    // Wait a bit so we don't spam the serial port
    delay(500);
}
</code></pre>

<p>Notice the following code snippet - this is the section of code that allows you to choose your units:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_CodeSnippet.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_CodeSnippet.jpg" alt="Example 2 Code To Change Units" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Example 2 Code To Change Units</em> </div></p>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, go ahead and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>. You should see something similar to the following.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_Output.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_2_Output.jpg" alt="Example 2 Output" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Example 2 Output</em> </div></p>

<hr />

<h3>Example 3: Calibration</h3>

<div class="alert alert-warning">
<b>Warning:</b> As of firmware version 1.0, these calibration values will be lost after a power cycle, so you will need to set them each time you power up the sensor.</div>

<p>The data from the OTOS will likely have minor scaling errors that can be calibrated out. This is especially important for the angular scalar, because an incorrect angle measurement causes the linear measurements to be rotated by the wrong angle in the firmware, which can lead to very inaccurate tracking.</p>

<p>To find Example 3, go to <strong>File > Examples > SparkFun Qwiic OTOS > Example3_Calibration</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_3_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_3_Menu.jpg" alt="Finding Example 3" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Finding Example 3</em> </div></p>

<p>Alternatively, you can expand the link below and copy and paste the code into a shiny new Arduino sketch:</p>

<pre><code>/*
    SPDX-License-Identifier: MIT

    Copyright (c) 2024 SparkFun Electronics
*/

/*******************************************************************************
    Example 3 - Calibration

    This example demonstrates how to calibrate the SparkFun Qwiic Optical
    Tracking Odometry Sensor (OTOS).

    This example should be used to calibrate the linear and angular scalars of
    the OTOS to get the most accurate tracking performance. The linear scalar
    can be used to compensate for scaling issues with the x and y measurements,
    while the angular scalar can be used to compensate for scaling issues with
    the heading measurement. Note that if the heading measurement is off, that
    can also cause the x and y measurements to be off, so it's recommended to
    calibrate the angular scalar first.
*******************************************************************************/

#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
#include "Wire.h"

// Create an Optical Tracking Odometry Sensor object
QwiicOTOS myOtos;

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("Qwiic OTOS Example 3 - Calibration");

    Wire.begin();

    // Attempt to begin the sensor
    while (myOtos.begin() == false)
    {
        Serial.println("OTOS not connected, check your wiring and I2C address!");
        delay(1000);
    }

    Serial.println("OTOS connected!");

    Serial.println("Ensure the OTOS is flat and stationary, then enter any key to calibrate the IMU");

    // Clear the serial buffer
    while (Serial.available())
        Serial.read();
    // Wait for user input
    while (!Serial.available())
        ;

    Serial.println("Calibrating IMU...");

    // The IMU on the OTOS includes a gyroscope and accelerometer, which could
    // have an offset. Note that as of firmware version 1.0, the calibration
    // will be lost after a power cycle; the OTOS performs a quick calibration
    // when it powers up, but it is recommended to perform a more thorough
    // calibration at the start of all your programs. Note that the sensor must
    // be completely stationary and flat during calibration! When calling
    // calibrateImu(), you can specify the number of samples to take and whether
    // to wait until the calibration is complete. If no parameters are provided,
    // it will take 255 samples and wait until done; each sample takes about
    // 2.4ms, so about 612ms total
    myOtos.calibrateImu();

    // Alternatively, you can specify the number of samples and whether to wait
    // until it's done. If you don't want to wait, you can asynchronously check
    // how many samples remain with the code below. Once zero samples remain,
    // the calibration is done!
    // myOtos.calibrateImu(255, false);
    // bool done = false;
    // while(done == false)
    // {
    //     // Check how many samples remain
    //     uint8_t samplesRemaining;
    //     myOtos.getImuCalibrationProgress(samplesRemaining);

    //     // If 0 samples remain, the calibration is done
    //     if(samplesRemaining == 0)
    //         done = true;
    // }

    // Here we can set the linear and angular scalars, which can compensate for
    // scaling issues with the sensor measurements. Note that as of firmware
    // version 1.0, these values will be lost after a power cycle, so you will
    // need to set them each time you power up the sensor. They can be any value
    // from 0.872 to 1.127 in increments of 0.001 (0.1%). It is recommended to
    // first set both scalars to 1.0, then calibrate the angular scalar, then
    // the linear scalar. To calibrate the angular scalar, spin the robot by
    // multiple rotations (eg. 10) to get a precise error, then set the scalar
    // to the inverse of the error. Remember that the angle wraps from -180 to
    // 180 degrees, so for example, if after 10 rotations counterclockwise
    // (positive rotation), the sensor reports -15 degrees, the required scalar
    // would be 3600/3585 = 1.004. To calibrate the linear scalar, move the
    // robot a known distance and measure the error; do this multiple times at
    // multiple speeds to get an average, then set the linear scalar to the
    // inverse of the error. For example, if you move the robot 100 inches and
    // the sensor reports 103 inches, set the linear scalar to 100/103 = 0.971
    myOtos.setLinearScalar(1.0);
    myOtos.setAngularScalar(1.0);

    // Reset the tracking algorithm - this resets the position to the origin,
    // but can also be used to recover from some rare tracking errors
    myOtos.resetTracking();
}

void loop()
{
    // Get the latest position, which includes the x and y coordinates, plus the
    // heading angle
    sfe_otos_pose2d_t myPosition;
    myOtos.getPosition(myPosition);

    // Print measurement
    Serial.println();
    Serial.println("Position:");
    Serial.print("X (Inches): ");
    Serial.println(myPosition.x);
    Serial.print("Y (Inches): ");
    Serial.println(myPosition.y);
    Serial.print("Heading (Degrees): ");
    Serial.println(myPosition.h);

    // Wait a bit so we don't spam the serial port
    delay(500);

}
</code></pre>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, go ahead and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>.</p>

<p>Calibrating your bot requires you to move it around a bit. First, set both scalars to 1.0, then calibrate the angular scalar, then the linear scalar.</p>

<p>To calibrate the angular scalar, spin the robot by multiple rotations (eg. 10) to get a precise error, then set the scalar to the inverse of the error. Remember that the angle wraps from -180 to 180 degrees, so for example, if after 10 rotations counterclockwise(positive rotation), the sensor reports -15 degrees, the required scalar would be 3600/3585 = 1.004.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-Rotation.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-Rotation.jpg" alt="Rotating the Optical Tracking Odometry Sensor" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Rotating the Optical Tracking Odometry Sensor</em> </div></p>

<p>To calibrate the linear scalar, move the robot a known distance and measure the error; do this multiple times at multiple speeds to get an average, then set the linear scalar to the inverse of the error. For example, if you move the robot 100 inches and the sensor reports 103 inches, set the linear scalar to 100/103 = 0.971.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-Distance.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-Distance.jpg" alt="Moving the Optical Tracking Odometry Sensor" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Moving the Optical Tracking Odometry Sensor</em> </div></p>

<hr />

<h3>Example 4: SetOffsetAndPosition</h3>

<p>This example shows how to set the offset for the sensor relative to the center of the robot. The units default to inches and degrees, but if you want to use different units, make sure you specify them before setting the offset. Without setting the offset, the OTOS will report the coordinates of itself. If the offset is set, the OTOS will instead report the coordinates of the center of your robot.</p>

<p>Note that the OTOS typically starts tracking from the origin, but if your robot starts at some other location, or you have another source of location information from another sensor that's more accurate, you can send the current location to the OTOS and it will continue tracking from there.</p>

<div class="alert alert-warning">
<b>Warning:</b> As of firmware version 1.0, these calibration values will be lost after a power cycle, so you will need to set them each time you power up the sensor.</div>

<p>To find Example 4, go to <strong>File > Examples > SparkFun Qwiic OTOS > Example4_SetOffsetAndPosition</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/Arduino_Example_4_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/Arduino_Example_4_Menu.jpg" alt="Finding Example 4" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Finding Example 4</em> </div></p>

<p>Alternatively, you can expand the link below and copy and paste the code into a shiny new Arduino sketch:</p>

<pre><code>/*
    SPDX-License-Identifier: MIT

    Copyright (c) 2024 SparkFun Electronics
*/

/*******************************************************************************
    Example 4 - Set Offset and Position

    This example demonstrates how to set the offset and position of the SparkFun
    Qwiic Optical Tracking Odometry Sensor (OTOS).

    If your OTOS is mounted to a robot and is not centered, you can specify the
    offset for the sensor relative to the center of the robot; rather than
    returning the position of the sensor, the OTOS will calculate and return the
    position of the robot's center. If you know where your robot is located,
    such as the starting location or from another sensor, you can send that
    position to the OTOS and it will continue to track from there.
*******************************************************************************/

#include "SparkFun_Qwiic_OTOS_Arduino_Library.h"
#include "Wire.h"

// Create an Optical Tracking Odometry Sensor object
QwiicOTOS myOtos;

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("Qwiic OTOS Example 4 - Set Offset and Position");

    Wire.begin();

    // Attempt to begin the sensor
    while (myOtos.begin() == false)
    {
        Serial.println("OTOS not connected, check your wiring and I2C address!");
        delay(1000);
    }

    Serial.println("OTOS connected!");

    Serial.println("Ensure the OTOS is flat and stationary, then enter any key to calibrate the IMU");

    // Clear the serial buffer
    while (Serial.available())
        Serial.read();
    // Wait for user input
    while (!Serial.available())
        ;

    Serial.println("Calibrating IMU...");

    // Calibrate the IMU, which removes the accelerometer and gyroscope offsets
    myOtos.calibrateImu();

    // Assuming you've mounted your sensor to a robot and it's not centered,
    // you can specify the offset for the sensor relative to the center of the
    // robot. The units default to inches and degrees, but if you want to use
    // different units, specify them before setting the offset! Note that as of
    // firmware version 1.0, these values will be lost after a power cycle, so
    // you will need to set them each time you power up the sensor. For example, if
    // the sensor is mounted 5 inches to the left (negative X) and 10 inches
    // forward (positive Y) of the center of the robot, and mounted 90 degrees
    // clockwise (negative rotation) from the robot's orientation, the offset
    // would be {-5, 10, -90}. These can be any value, even the angle can be
    // tweaked slightly to compensate for imperfect mounting (eg. 1.3 degrees).
    sfe_otos_pose2d_t offset = {-5, 10, -90};
    myOtos.setOffset(offset);

    // Reset the tracking algorithm - this resets the position to the origin,
    // but can also be used to recover from some rare tracking errors
    myOtos.resetTracking();

    // After resetting the tracking, the OTOS will report that the robot is at
    // the origin. If your robot does not start at the origin, or you have
    // another source of location information (eg. vision odometry), you can set
    // the OTOS location to match and it will continue to track from there.
    sfe_otos_pose2d_t currentPosition = {0, 0, 0};
    myOtos.setPosition(currentPosition);
}

void loop()
{
    // Get the latest position, which includes the x and y coordinates, plus the
    // heading angle
    sfe_otos_pose2d_t myPosition;
    myOtos.getPosition(myPosition);

    // Print measurement
    Serial.println();
    Serial.println("Position:");
    Serial.print("X (Inches): ");
    Serial.println(myPosition.x);
    Serial.print("Y (Inches): ");
    Serial.println(myPosition.y);
    Serial.print("Heading (Degrees): ");
    Serial.println(myPosition.h);

    // Wait a bit so we don't spam the serial port
    delay(500);

}
</code></pre>

<p>If the sensor is mounted 5 inches to the left (negative X) and 10 inches forward (positive Y) of the center of the robot, and mounted 90 degrees clockwise (negative rotation) from the robot's orientation, the offset would be {-5, 10, -90}. These can be any value, even the angle can be tweaked slightly to compensate for imperfect mounting (eg. 1.3 degrees).</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-XY-Offset.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/3/9/SEN-24904-XRP-XY-Offset.jpg" alt="The X, Y, and Angular Offset of the Optical Tracking Sensor" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>The X, Y, and Angular Offset of the Optical Tracking Sensor</em> </div></p>

<p>These four examples cover the basics - there are more examples to explore in the library!</p>  <a name="#python-examples--calibration"></a>
  <h2 id="python-examples--calibration">Python Examples & Calibration</h2>
  <div class="alert alert-info">
<b>Attention:</b> These instructions are written for the XRP using the <a href="https://xrpcode.wpi.edu/">XRPCode IDE</a>. However the setup process is very similar for MicroPython and CircuitPython on any other board, so you should be able to follow along with these instructions using your IDE of choice!</div>

<h3>Download Examples</h3>

<p>First, go to the <a href="https://github.com/sparkfun/Qwiic_OTOS_Py">Qwiic_OTOS_Py repository</a>, open the <code>examples</code> folder, and download the example files you want to run.</p>

<p>Connect your XRP to your computer over US...</div></div>]]></description><link>https://learn.sparkfun.com/tutorials/calibrating-your-odometry-sensor</link><guid isPermaLink="false">57f2c69171d9d90cca545c392933fc02</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Mon, 02 Dec 2024 07:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/2/0/9/SEN-24904-Optical-Tracking-Odometry-Sensor-Feature_1.jpg"/></item><item><title><![CDATA[Moving Beyond the Ordinary With the Qwiic Alphanumeric Display]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/8/9/2/6/19297-SparkFun_Qwiic_Alphanumeric_Sampler_Kit-01.jpg" style="width: 100%;" /><div><h1>
  Moving Beyond the Ordinary With the Qwiic Alphanumeric Display  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3606">http://sfe.io/t3606</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>Sometimes you need a display that can not only share information, but also catch the attention of those passing by. LCDs are great at getting a good amount of information on a small screen, but they’re not nearly as eye-catching as an LED. Our Qwiic Alphanumeric Displays combine the best of both worlds, offering the ability to share information, combined with the eye-catching pop of LEDs. In this tutorial, We’ll show you how fast and simple it is to start displaying information on the SparkFun Alphanumeric Display, starting with the most basic, then looking at some more advanced examples.</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-19297">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/19297">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/8/9/2/6/19297-SparkFun_Qwiic_Alphanumeric_Sampler_Kit-01.jpg" alt="SparkFun Qwiic Alphanumeric Display Kit" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="19297">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_19297" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_19297 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_19297"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/19297">
          <span>SparkFun Qwiic Alphanumeric Display Kit</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="only 6 left!"><span class=sfe-icon-stock-low><span class=visuallyhidden>Only 6 left!</span></span></a>
    </span>

    <span class="sku">
      KIT-19297    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Alphanumeric Display Kit comes with six different colored, 14-segment Qwiic displays. This is your all-in-…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$54.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">1</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="19297">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">8</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="19297" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<div class="flex-video-wrap clearfix">
  <div class="flex-video widescreen img">
    <iframe src="https://www.youtube.com/embed/w4SYlc3qlu0/?autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen width="560" height="315"></iframe>
  </div>
</div>  <a name="#required-hardware"></a>
  <h2 id="required-hardware">Required Hardware</h2>
  <p>For this tutorial, you’ll only need the following components:</p>

<p>A Qwiic Alphanumeric Display, in the color of your choosing:
<li><a href="https://www.sparkfun.com/products/18565">White Qwiic Alphanumeric Display</a></li>
<li><a href="https://www.sparkfun.com/products/16916">Red Qwiic Alphanumeric Display</a></li>
<li><a href="https://www.sparkfun.com/products/16917">Blue Qwiic Alphanumeric Display</a></li>
<li><a href="https://www.sparkfun.com/products/16918">Purple Qwiic Alphanumeric Display</a></li>
<li><a href="https://www.sparkfun.com/products/16919">Pink Qwiic Alphanumeric Display</a></li>
<li><a href="https://www.sparkfun.com/products/18566">Green Qwiic Alphanumeric Display</a></li></p>

<p>For the more advanced examples using multiple displays, you can mix and match from the individual options above, or pick up one of our kits containing multiple Qwiic Alphanumeric Displays:
<li><a href="https://www.sparkfun.com/products/18624">SparkFun Qwiic Alphanumeric Starter Kit - Red and White</a></li>
<li><a href="https://www.sparkfun.com/products/19297">SparkFun Qwiic Alphanumeric Display Kit</a></li></p>

<p>And of course, you'll need a <a href="https://www.sparkfun.com/search/results?term=Redboard">microcontroller</a> and some <a href="https://www.sparkfun.com/products/15081">Qwiic Cables</a> to hook it all up.</p>

<div class="alert alert-info">
<b>Note:</b> If you have a microcontroller that doesn't have a Qwiic connector, you can still easily connect your Qwiic board by utilizing our <a href="https://www.sparkfun.com/products/18566">Flexible Qwiic Cable Breadboard Jumper.</a>
</div>  <a name="#setting-up-your-alphanumeric-display"></a>
  <h2 id="setting-up-your-alphanumeric-display">Setting Up Your Alphanumeric Display</h2>
  <p>Thanks to our Qwiic system, setup could not be easier. Just follow these simple steps:</p>

<p><li>Connect one end of your Qwiic cable to the Qwiic connector on your microcontroller.</li>
<li>Connect the other end of your Qwiic cable to the Qwiic connector on your Alphanumeric Display.</li>
<li>Connect your USB-C cable to your microcontroller, then to your computer.</li></p>

<p>Feeling creative? You can change the order of these steps, and your setup will still work perfectly!</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/Alphanumeric_Hardware_Hookup.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/Alphanumeric_Hardware_Hookup.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>  <a name="#installing-the-required-libraries"></a>
  <h2 id="installing-the-required-libraries">Installing the Required Libraries</h2>
  <p>You can install the SparkFun Qwiic Alphanumeric Display Library in either of a couple of different ways.</p>

<p>In the Arduino IDE, open the Library Manager (either by opening the panel of the left side of the app, or from the dropdown menu going to Sketch/Include Library/Manage Libraries). From there, search “SparkFun Qwiic Alphanumeric”, and click the “Install” button.</p>

<p>Use the following link, download the .ZIP file, and either extract it and install it, or use the “Add .ZIP Library” option in the IDE.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Alphanumeric_Display_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">Download the Arduino Library</a> </div></p>  <a name="#the-basics"></a>
  <h2 id="the-basics">The Basics</h2>
  <p>Let’s start at the very beginning, a very good place to start. Once you’ve installed the library, you’ll be able to access all of our example code. Navigate your way to File/Examples/SparkFun Qwiic Alphanumeric Display Arduino Library/Example_01_PrintString, open it and upload it to your microcontroller. If all goes as expected, your display should be showing the work “Milk” for all to see! (Why “Milk”? Eh, why not? It’s four characters in length, shows the use of both uppercase and lowercase letters, and, well, I suppose our engineer likes milk!)</p>

<pre><code>/*****************************************************************************************
 * This example tests illuminating whole 4 letter strings on the 14-segment display.
 * 
 * Priyanka Makin @ SparkFun Electronics
 * Original Creation Date: February 3, 2020
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/16391
 * 
 * This code is Lemonadeware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable.
 * 
 * Distributed as-is; no warranty is given.
 ****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h> //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup()
{
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 1: Print String");

  Wire.begin(); //Join I2C bus

  if (display.begin() == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while (1);
  }
  Serial.println("Display acknowledged.");

  display.print("Milk");
}

void loop()
{
}
</code></pre>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/AlphanumericSingleMilk.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/AlphanumericSingleMilk.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<p><br>
If you feel like the bright lights of the Alphanumeric Display aren’t enough to capture the attention of passersby, there’s always the option of adding a little motion to your message. Our library has a built-in function, shiftLeft() (or shiftRight()), that slides your message across the displays. Run File/Examples/SparkFun Qwiic Alphanumeric Display Arduino Library/Example_09_ScrollingString to see it in action.</p>

<pre><code>/**************************************************************************************
 * This example tests scrolling functionality of alphanumeric displays.
 * 
 * Priyanka Makin @ SparkFun Electronics
 * Original Creation Date: February 26, 2020
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/16391
 * 
 * This code is Lemonadeware; if you see me (or any other SparkFun employee) at the
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable. 
 *  Don't close any of the address jumpers so that it defaults to address 0x70.
 * Attach a second Alphanumeric display using Qwiic cable.
 *  Close address jumper A0 so that this display's address become 0x71.
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h>  //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup() {
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 9: Scrolling String");
  Wire.begin(); //Join I2C bus

  //check if displays will acknowledge
  if (display.begin(0x70) == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while(1);
  }
  Serial.println("Displays acknowledged.");

  display.print("MILK");
  delay(500);
}

void loop() 
{  
  delay(300);
  display.shiftLeft();
  //Alternatively - you could also shift the string to the right
  //display.shiftRight();
}
</code></pre>  <a name="#going-beyond-the-basics"></a>
  <h2 id="going-beyond-the-basics">Going Beyond the Basics</h2>
  <p>Our shift function is a fast and super-simple way to scroll text, but the length of the text is limited to four characters. (More if you’re using multiple displays, but we’ll talk about that a little later on.) So, what can you do if you want to scroll a text string that’s longer than the number of display digits you have. We just need to get a little creative with our coding.</p>

<p>Example - Moving text the hard way
Suppose I want to try the scrolling example, but I’m lactose intolerant. I want to scroll “soy milk”, but my display is only four characters. For this, we can use a little creative manual character shifting. Take a look at the code below, and you’ll see how the eight characters (I’m including the space between the two words) make their way past the four available spaces.</p>

<pre><code>/*******************************************************************************************
 * This demo shows how to manually scroll a word or words longer than four characters
 * across a digit alphanumeric display.
 * 
 * Rob Reynolds @ SparkFun Electronics
 * Original Creation Date: October 16, 2024
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/19297
 * 
 * This code is Beerware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable.
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h>  //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup()
{
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 2: Turn On One Segment");
  Wire.begin(); //Join I2C bus


if (display.begin() == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while(1);
  }

  Serial.println("Display acknowledged.");
  delay(2000);

}

void loop()
{
  // Scroll SOY MILK past the 4 available character displays
  display.clear();
  display.print("SOY ");
  delay(1000);
  display.clear();
  display.print("OY M");
  delay(300);
  display.clear();
  display.print("Y MI");
  delay(300);
  display.clear();
  display.print(" MIL");
  delay(300);
  display.clear();
  display.print("MILK");
  delay(300);
  display.clear();
  display.print("ILK");
  delay(300);
  display.clear();
  display.print("LK");
  delay(300);
  display.clear();
  display.print("K");
  delay(300);
  display.clear();
  delay(5000);

}
</code></pre>

<p>Earlier, I mentioned the possibility of using multiple displays. This takes a little bit of work on the front end, but after that, using four displays is just as easy as using one.</p>

<p>On the rear of the display board, you’ll find a pair of jumpers labeled A0 and A1. These jumpers will allow you to change the I2C address, giving you four options.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/I2C_Jumpers.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/I2C_Jumpers.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<p><br>
We’ve made linking and using multiple displays incredibly simple. There are just a couple of things you need to keep in mind. In your setup(), you will, as usual, check to make sure that your I2C peripheral (in this case your Alphanumeric Display) acknowledges, like this:</p>

<pre><code>if (display.begin() == false)
</code></pre>

<p>When using multiple displays, you simply verify that all of them acknowledge, like this:</p>

<pre><code> if (display.begin(0x70, 0x71, 0x72, 0x73) == false)
</code></pre>

<p>The big thing the remember here is that when daisy-chaining your displays, they do not need to be connected in numeric order. However, the order in which you verify them in your code must match their physical order, Therefore, if you are using four displays, each of a different color, once you’ve given each its own unique I2C address, you can place the colors in any order you want. Just make sure that you match their I2C address order with the order in which you verify them in your code, something like this:</p>

<pre><code>if (display.begin(0x73, 0x71, 0x70, 0x72) == false) // This is perfectly acceptable
</code></pre>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/Alphanumeric_Daisy_Chain.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/Alphanumeric_Daisy_Chain.jpg" alt="alt text" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <i><sup> But why stop at just two Alphanumeric Displays? By changing the I2C addresses, you can daisy-chain up to four displays at once!</sup></i> </div></p>

<div class="alert alert-warning">
WARNING: TECHNICAL (BUT IMPORTANT) STUFF: When using multiple I2C devices all containing built-in pull up resistors, the parallel equivalent resistance will often create too strong of a pull up for the bus to operate. A good rule of thumb is, if you’re using multiple I2C boards, you should disable all but one pair of pull up resistors. These pull up resistors can be removed by cutting the traces of the I2C jumpers, as highlighted in the image below.
</div>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/Alphanumeric-Display_I2CJumper.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/Alphanumeric-Display_I2CJumper.jpg" alt="alt text" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <i><sup>When using multiple I2C devices, you may need to cut the trace for the I2C resistors on one of your boards.</sup></i> </div></p>  <a name="#going-beyond-the-expected"></a>
  <h2 id="going-beyond-the-expected">Going beyond the Expected</h2>
  <p>Sometimes it’s fun to take something, completely ignore its intended use, and turn it on its head. Or at least, on its side. I found myself wondering if I could use these Alphanumeric Modules for Vertical display. Of course, if we had single character boards, it would be simple. But with four characters per board, stacking vertically becomes a bit more of a challenge. Luckily, as we learned in Example 02 Turn On One Segment, we can control each of the fourteen segments of each character individually. What that example doesn’t show is that we can turn on multiple segments at once, allowing us to create any number of shapes. In its simplest form, you can think of the segments that make up the letter “U”. If you turn the display on its end, those same segments will give you a low, wide, letter “C”.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/AlphaNumericSegmentLabels.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/AlphaNumericSegmentLabels.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<p>The code below will give you an idea of what it takes to create vertical displays.</p>

<pre><code>/*******************************************************************************************
 * This example tests illuminating individual segments to create a vertical display of sorts.
 * We will also use characters that, when turned on their side, can pass for vertical displays.
 * ex using a Z as an N
 *
 * Pass in the segment
 * and digit you wish to illuminate to illuminateSegement().
 * 
 *
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/16391
 * 
 * This code is Beerware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable.
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h>  //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup()
{
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 2: Turn On One Segment");
  Wire.begin(); //Join I2C bus

  //check if display will acknowledge
  if (display.begin() == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while(1);
  }
  Serial.println("Display acknowledged.");
  display.clear();
  delay(1000);

}

void loop()
{
  //code();
  //delay(5000);
  //name();
  //delay(5000);
  neon();
  delay(5000);
  //zone();
  //delay(5000);
}


void code()
{
  display.clear();

  display.printChar('U', 0);  // Flip it sideways, it becomes a C

  display.printChar('O', 1);  // Sometimes an O is just an O

  // On the next six lines, we illuminate specific segments to create a very wide D
  display.illuminateSegment('A', 2);
  display.illuminateSegment('B', 2);
  display.illuminateSegment('C', 2);
  display.illuminateSegment('E', 2);
  display.illuminateSegment('F', 2);
  display.illuminateSegment('G', 2);
  display.illuminateSegment('I', 2);
  // Thus endeth the creation of the sideways D

  // On the next six lines, we illuminate specific segments to create a very wide E
  display.illuminateSegment('B', 3);
  display.illuminateSegment('C', 3);
  display.illuminateSegment('D', 3);
  display.illuminateSegment('E', 3);
  display.illuminateSegment('F', 3);
  display.illuminateSegment('J', 3);
  display.illuminateSegment('M', 3);
  // Thus endeth the creation of the sideways E


  display.updateDisplay();
  delay(100);
}

void name()
{
  display.clear();

  display.printChar('Z', 0);  // Flip it sideways, it becomes an N

  // On the next six lines, we illuminate specific segments to create a very wide A
  display.illuminateSegment('A', 1);
  display.illuminateSegment('D', 1);
  display.illuminateSegment('E', 1);
  display.illuminateSegment('F', 1);
  display.illuminateSegment('J', 1);
  display.illuminateSegment('M', 1);
  // Thus endeth the creation of the sideways A

  // We will now attempt to make a sideways M
  display.illuminateSegment('A', 2);
  display.illuminateSegment('D', 2);
  display.illuminateSegment('N', 2);
  display.illuminateSegment('H', 2);
  // Thus endeth the creation of the sideways M

  // On the next six lines, we illuminate specific segments to create a very wide E
  display.illuminateSegment('B', 3);
  display.illuminateSegment('C', 3);
  display.illuminateSegment('D', 3);
  display.illuminateSegment('E', 3);
  display.illuminateSegment('F', 3);
  display.illuminateSegment('J', 3);
  display.illuminateSegment('M', 3);
  // Thus endeth the creation of the sideways E

  display.updateDisplay();
  delay(100);
}

void neon()
{
  display.clear();

  display.printChar('Z', 0);  // Flip it sideways, it becomes an N

  // On the next six lines, we illuminate specific segments to create a very wide E
  display.illuminateSegment('B', 1);
  display.illuminateSegment('C', 1);
  display.illuminateSegment('D', 1);
  display.illuminateSegment('E', 1);
  display.illuminateSegment('F', 1);
  display.illuminateSegment('J', 1);
  display.illuminateSegment('M', 1);
  // Thus endeth the creation of the sideways E

  display.printChar('O', 2);  // Sometimes an O is just an O

  display.printChar('Z', 3);  // Flip it sideways, it becomes an N

  display.updateDisplay();
  delay(100);
}

void zone()
{
  display.clear();

  // We will now attempt to make a sideways Z
  display.illuminateSegment('E', 0);
  display.illuminateSegment('F', 0);
  display.illuminateSegment('H', 0);
  display.illuminateSegment('L', 0);
  display.illuminateSegment('C', 0);
  display.illuminateSegment('B', 0);
  // Thus endeth the creation of the sideways Z

  display.printChar('O', 1);  // Sometimes an O is just an O

  display.printChar('Z', 2);  // Flip it sideways, it becomes an N

  // On the next six lines, we illuminate specific segments to create a very wide E
  display.illuminateSegment('B', 3);
  display.illuminateSegment('C', 3);
  display.illuminateSegment('D', 3);
  display.illuminateSegment('E', 3);
  display.illuminateSegment('F', 3);
  display.illuminateSegment('J', 3);
  display.illuminateSegment('M', 3);
  // Thus endeth the creation of the sideways E

  display.updateDisplay();
  delay(100);

  delay(25000);

}
</code></pre>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/AlphanumericVertNEON.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/AlphanumericVertNEON.jpg" alt="alt text" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <i><sup>Of course it's not neon, but if you dim the lights, and maybe squint a little, it's not a bad substitute.</sup></i> </div></p>

<p><br>
And if you want to get really crazy, you can combine vertical and horizontal! Combining the display.illuminateSegment() calls with the display.printChar() calls (and making sure you assign each to their proper character number) will put you high and above all others with their simple horizontal alphanumeric displays.</p>

<p><br></p>

<pre><code>/**************************************************************************************
 * This example allows for both vertical and horizontal display of characters.
 * Keep in mind that they are not designed for vertical use, so some of the characters
 * are a little off. Hey, it's the best I could do!
 * 
 * Rob Reynolds @ SparkFun Electronics
 * Original Creation Date: November 11, 2024
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/19297
 * 
 * This code is Beerware; if you see me (or any other SparkFun employee) at the
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable. 
 *  Don't close any of the address jumpers so that it defaults to address 0x70.
 * Attach a second Alphanumeric display using Qwiic cable.
 * Close address jumper A0 so that this display's address become 0x71.
 * Close the necessary jumpers (A0 and/or A1) to change the other displays I2C
 * addresses to 0x72 znd 0x73. See hoolup guide or tutorial for specifics.
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h>  //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup() {
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 8: Multi Display");
  Wire.begin(); //Join I2C bus

  //check if displays will acknowledge
  //The first address in the begin() function should be the left-most display, traveling to the right from there
  //This is how the string will print across displays, reading from left to right.
  if (display.begin(0x70, 0x71, 0x72, 0x73) == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while(1);
  }
  Serial.println("Displays acknowledged.");
  display.setBrightness(15);
  display.clear();

  //display.print("*BUY MOREDISPLAYS");
}

void loop() 
{
  //display.printChar('*', 0);  // An asterisk is an asterisk from any angle!

  // We can make an arrow pointing in any direction. I'll go with Down
  //display.illuminateSegment('G', 0);
  //display.illuminateSegment('H', 0);
  //display.illuminateSegment('N', 0);
  // Thus endeth the creationNof the sideways Down Arrow


  // We will now attempt to make a sideways B
  display.illuminateSegment('A', 0);
  display.illuminateSegment('B', 0);
  display.illuminateSegment('C', 0);
  display.illuminateSegment('E', 0);
  display.illuminateSegment('F', 0);
  display.illuminateSegment('G', 0);
  display.illuminateSegment('I', 0);
  display.illuminateSegment('J', 0);
  // Thus endeth the creation of the sideways B

  // Here is how we make a sideways U
  display.illuminateSegment('A', 1);
  display.illuminateSegment('B', 1);
  display.illuminateSegment('C', 1);
  display.illuminateSegment('D', 1);
  // Thus endeth the sideways U

  // This will hopefully look like a sideways Y
  display.illuminateSegment('H', 2);
  display.illuminateSegment('I', 2);
  display.illuminateSegment('N', 2);
  // Thus endeth the sideways Y

  // We will now attempt to make a sideways M
  display.illuminateSegment('A', 4);
  display.illuminateSegment('D', 4);
  display.illuminateSegment('N', 4);
  display.illuminateSegment('H', 4);
  // Thus endeth the creation of the sideways M

  display.printChar('O', 5);  // Sometimes an O is just an O

  // We will now attempt to make a sideways R
  display.illuminateSegment('D', 6);
  display.illuminateSegment('E', 6);
  display.illuminateSegment('F', 6);
  display.illuminateSegment('H', 6);
  display.illuminateSegment('K', 6);
  display.illuminateSegment('M', 6);
  // Thus endeth the creation of the sideways R

  // On the next six lines, we illuminate specific segments to create a very wide E
  display.illuminateSegment('B', 7);
  display.illuminateSegment('C', 7);
  display.illuminateSegment('D', 7);
  display.illuminateSegment('E', 7);
  display.illuminateSegment('F', 7);
  display.illuminateSegment('J', 7);
  display.illuminateSegment('M', 7);
  // Thus endeth the creation of the sideways E

  display.printChar('D', 8);
  display.printChar('I', 9);
  display.printChar('S', 10);
  display.printChar('P', 11);
  display.printChar('L', 12);
  display.printChar('A', 13);
  display.printChar('Y', 14);
  display.printChar('S', 15);

  display.updateDisplay();

  //display.print("*BUYMOREDISPLAYS");
  //delay(1000);
  //display.clear();
  //delay(250);
  //display.print("*BUYMORESPARKFUN");
  //delay(1000);
  //display.clear();
  delay(25000);

}
</code></pre>

<p><br>
<div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/AlphanumericVertHorizDisplays.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/AlphanumericVertHorizDisplays.jpg" alt="alt text" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"><i><sup>We don't need more subliminal messaging, we need more Qwiic Alphanumeric Displays!</sup></i> </div></p>  <a name="#final-thoughts"></a>
  <h2 id="final-thoughts">Final Thoughts</h2>
  <p>LEDs are a fast and easy way to add eye-catching pizazz to any project, and, let’s face it, they make everything better. LEDs that can display information quickly go from an ornament to a very useful tool, while maintaining the allure of LEDs. The design, size, and multiple color options of these displays allow for clear visibility from a distance, making for great readability. And now that you know how simple it is to display any number (or letter!) of things to your project in bold, bright characters, your project shelf should look like the Las Vegas Strip in no time!</p>

<p>Or maybe that’s just me…</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/6/0/6/AlphanumericLasVegas.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/6/0/6/AlphanumericLasVegas.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<p><br>
<div class="center-block text-center"> <a href="https://share.hsforms.com/1m0duVCnuQq2rkKKWDYKdOQ1bo1v" class="btn btn-default">Have you created an amazing project? We want to see it! Click here to share.</a> </div></p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/moving-beyond-the-ordinary-with-the-qwiic-alphanumeric-display</link><guid isPermaLink="false">4c99e854063242b3852f053eda704367</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Thu, 07 Nov 2024 07:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/1/8/9/2/6/19297-SparkFun_Qwiic_Alphanumeric_Sampler_Kit-01.jpg"/></item><item><title><![CDATA[IMU Data to Motion: Tutorial for Translating Sensor Data into Real-World Movement]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementSetup.jpg" style="width: 100%;" /><div><h1>
  IMU Data to Motion: Tutorial for Translating Sensor Data into Real-World Movement  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3573">http://sfe.io/t3573</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/7/3/MotionToMovementSetup.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementSetup.jpg" alt="Setup" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <sub><i>A Qwiic cable, some jumper wires, a couple of servos, and you're good to go. (3D printed rig optional)</i></sub> </div></p>

<p>Over the Years, we’ve carried quite a number of IMUs. And why not? Inertial Motion Units are used in an incredibly broad array of products, from robots to rockets, smart watches to structural components, electronic stabilization systems to exoskeletons. IMUs combine several sensors to provide data about movement and orientation in three-dimensional space, utilizing an accelerometer and gyroscope in the case of a 6DoF sensor (six degrees of freedom), or an accelerometer, gyroscope, and magnetometer in the case of a 9DoF (nine degrees of freedom).</p>

<p><div class="center-block text-center"> <a href="https://www.sparkfun.com/pages/accel_gyro_guide" class="btn btn-default">Confused by IMUs? Learn more here</a> </div></p>  <a name="#the-challenge-translating-measured-movement-to-motion"></a>
  <h2 id="the-challenge-translating-measured-movement-to-motion">The Challenge: Translating Measured Movement to Motion</h2>
  <p>Monitoring and measuring this incoming data is simple, especially with our Qwiic sensors and example sketches. But let’s face it, we want to do more with our incoming motion data than just read the results on a screen. So I decided to revisit an old project build that I quickly threw together for a new product demo. Since I’ll only be using the measurements from one of the three possible sensors on a 9D0F IMU, for this project I’m going to be using one of our newer, smaller magnetometer boards to control a pair of servos, and then toss out some ideas to upgrade to a much bigger, cooler project.</p>

<div class="row">
    <div class="col-md-6">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-19921">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/19921">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/9/6/5/3/19921_03.jpg" alt="SparkFun Micro Magnetometer - MMC5983MA (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="19921">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_19921" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_19921 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_19921"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/19921">
          <span>SparkFun Micro Magnetometer - MMC5983MA (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-19921    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Micro MMC5983MA Magnetometer is a micro-sized 0.75in. by 0.30in. sensor that utilizes a highly sensitive t…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$15.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="3 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-empty" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">4</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="19921">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">11</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="19921" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-6">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-19895">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/19895">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/9/6/1/5/19895_Diag.jpg" alt="SparkFun 9DoF IMU Breakout - ISM330DHCX, MMC5983MA (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="19895">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_19895" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_19895 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_19895"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/19895">
          <span>SparkFun 9DoF IMU Breakout - ISM330DHCX, MMC5983MA (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-19895    </span>

          <p class="description" style="display:none">
        The SparkFun 9DoF IMU Breakout combines a high-performance 6DoF IMU with the highly sensitive triple-axis magnetometer in a Q…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$39.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">1</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="19895">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">19</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="19895" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<p><div class="center-block text-center"> <a href="https://learn.sparkfun.com/tutorials/qwiic-micro-magnetometer---mmc5983ma-hookup-guide" class="btn btn-default">View the Full Hookup Guide</a> </div></p>  <a name="#components-required"></a>
  <h2 id="components-required">Components Required</h2>
  <p>You can opt for a number of different servos, or a number of different microcontrollers, but here are some suggestions for a fast and simple demo.</p>

<p><strong>The magnetometer -</strong> <a href="https://www.sparkfun.com/products/19921">SparkFun Micro Magnetometer - MMC5983MA (Qwiic)</a></p>

<p><strong>A microcontroller -</strong> <a href="https://www.sparkfun.com/products/15123">SparkFun Redboard Qwiic</a></p>

<p><strong>2 Servos (anything from sub-micro to giant) -</strong> <a href="https://www.sparkfun.com/products/9065">Generic sub-micro servo</a></p>

<p><strong>Power Supply for Servos (optional).</strong> <a href="https://www.sparkfun.com/categories/28">Power Supplies</a></p>

<p><strong>SparkFun Qwiic Connectors -</strong> <a href="https://www.sparkfun.com/products/15081">SparkFun Qwiic Cable Kit</a></p>  <a name="#the-project"></a>
  <h2 id="the-project">The Project</h2>
  <p>I’ve always been a fan of flying, and eventually of flight simulators. So of course, I’ve always wanted to build a chair frame that would move in concert with the movements of my onscreen plane, whether it’s a Cessna 172 or a Airbus H225 helicopter. So in order to do this, I want to read the movement or position of our yolk or stick. 
Note: I know that when it actually comes to creating a chair frame that moves based on the movement of the flight stick, the movements will need to be measured from local axes, and a magnetometer, like I’m using in this example, bases its measurements on global axes. This is just a broad look at how to translate sensor data into motion, and can then be tailored to fit the needs of each project. 
Planes use cables to control the ailerons and elevator, and if you’re planning on building an experimental aircraft, I’m going to suggest not using this method., but if something goes wrong on a Flight Sim build, a catastrophic control failure would, at worst, toss toss onto the floor.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/7/3/MotionToMovementCockpit.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementCockpit.jpg" alt="Lego Pilot in the cockpit of a Cessna Citation" style="max-width: 100%;" /></a> </div></p>

<p>For testing the concept, I’m going to translate the sensor data to a pair of small servos. I 3D printed a small rig and a tiny chair for my little lego fly-boy. The initial concept worked just fine, I only needed to tweak the limits of the servo travel.</p>  <a name="#hardware-setup"></a>
  <h2 id="hardware-setup">Hardware Setup</h2>
  <p><strong>Connecting the MMC5983MA Sensor:</strong> Connect the MMC5983MA sensor to the Arduino using the SparkFun Qwiic Connectors. Plug the Qwiic connector on the MMC5983MA into one of the Qwiic ports on the Qwiic Shield or directly on a Qwiic-compatible Arduino board.</p>

<p><strong>Connecting the Servos:</strong>
Servo 1 Signal to Pin 8 on Arduino
Servo 2 Signal to Pin 9 on Arduino
Servo Power (VCC) to an external 5V power supply (opt)
Servo Ground (GND) to Arduino GND</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/7/3/MotionToMovementLayout.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementLayout.jpg" alt="Layout of Components" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <i><sup>The basic layout is fast and simple, getting you to the testing phase quickly.</sup></i> </div></p>  <a name="#arduino-sketch"></a>
  <h2 id="arduino-sketch">Arduino Sketch</h2>
  <pre><code>/*
  Movement to Motion: Using the SparkFun Micro Magnetometer (MMC5983MA) to control servo motors
  By: Rob Reynolds
  SparkFun Electronics
  Date: September 19th, 2024
  Based on original code by Nathan Seidle and Ricardo Ramos
  License: SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/19921

  This example demonstrates how to take raw X/Y/Z readings from the sensor over Qwiic
  and translate them to movement through servo motors on the X and Y axes

  Hardware Connections:
  Plug a Qwiic cable into the sensor and a RedBoard
  If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper
  (https://www.sparkfun.com/products/17912) Open the serial monitor at 115200 baud to see the output
*/


#include <Wire.h>

#include <SparkFun_MMC5983MA_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_MMC5983MA

SFE_MMC5983MA myMag;

// Here's where we set up the servos

#include <Servo.h>
Servo servoPitchX; //Create object on X access
Servo servoRollY; //Create object on Y access

// initiate variables for servo positions
int rollYVal;
int pitchXVal;


void setup()
{
    Serial.begin(115200);
    Serial.println("Movement to Motion Example with the MMC5983MA");

    Wire.begin();

    if (myMag.begin() == false)
    {
        Serial.println("MMC5983MA did not respond - check your wiring. Freezing.");
        while (true)
            ;
    }

    myMag.softReset();

    Serial.println("MMC5983MA connected");

    servoPitchX.attach(8);
    servoRollY.attach(9);
}


void loop()
{
    uint32_t currentX = 0;
    uint32_t currentY = 0;
    uint32_t currentZ = 0;

    // This reads the X, Y and Z channels consecutively
    // (Useful if you have one or more channels disabled)
    currentX = myMag.getMeasurementX();
    currentY = myMag.getMeasurementY();
    currentZ = myMag.getMeasurementZ();  // Z axis/Yaw not needed for this example

    // Or, we could read all three simultaneously
    //myMag.getMeasurementXYZ(&currentX, &currentY, &currentZ);

    Serial.print("X axis raw value: ");
    Serial.print(currentX/1000);
    rollYVal = map(currentX/1000, 123, 133, 15, 165);
    servoRollY.write(rollYVal);
    Serial.print("\tY axis raw value: ");
    Serial.print(currentY/1000);
    pitchXVal = map(currentY/1000, 131, 119, 35, 135);
    servoPitchX.write(pitchXVal);
    Serial.print("\tZ axis raw value: ");
    Serial.println(currentZ);  //Z values are not necessary here, unless you want to add yaw on the Z axis

    Serial.println();
    delay(50); // Don't overtax the I2C
}
</code></pre>

<p><br>
<div class="flex-video-wrap clearfix">
  <div class="flex-video widescreen img">
    <iframe src="https://www.youtube.com/embed/b5TpKqRlNFs/?autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen width="560" height="315"></iframe>
  </div>
</div>
</p>  <a name="#explanations"></a>
  <h2 id="explanations">Explanations</h2>
  <p><strong>1. Libraries:</strong>
Wire.h: For I2C communication.
SparkFunLSM6DSV16X.h: To interface with the LSM6DSV16X sensor via Qwiic.
Servo.h: To control the servos.</p>

<p><strong>2. Setup Function:</strong>
Initializes serial communication for debugging.
Initializes the IMU sensor and checks if it's detected.
Attaches servos to their respective pins and sets initial positions.</p>

<p><strong>3. Loop Function:</strong>
Reads magnetometer data (x, y, z).
Maps x and y positional values to servo angles.
Constrains angles to valid ranges (for this, 15-165 and 35-135 degrees).
Updates servo positions based on mapped angles.
Includes a small delay for stability.</p>

<p><strong>Testing and Calibration:</strong></p>

<p><strong>Upload the Sketch:</strong> Connect your Arduino to your computer and upload the sketch using the Arduino IDE.</p>

<p><strong>Power the Servos</strong>: Ensure the servos are powered correctly with an external power supply. (Small servos with light lode might be able to get away with using power from teh board.)</p>

<p><strong>Observe Movement:</strong> Tilt or move the IMU sensor and watch how the servos react. The servos should adjust their positions based on the x and y acceleration data from the sensor.</p>  <a name="#troubleshooting"></a>
  <h2 id="troubleshooting">Troubleshooting</h2>
  <p><strong>Troubleshooting:</strong></p>

<p><strong>IMU Not Detected:</strong> Ensure the Qwiic connections are secure and that the sensor is properly connected to the I2C bus. Check if the Qwiic shield or board is functioning correctly.</p>

<p><strong>Servo Movement Issues:</strong> Verify that the mapping and constraints are correct. Make sure the servo power supply is adequate.
By following this tutorial, you should be able to easily interface the SparkFun Micro 6DoF IMU Breakout - LSM6DSV16X with your Arduino using Qwiic connectors and control servos based on the sensor’s motion data.</p>  <a name="#going-further"></a>
  <h2 id="going-further">Going Further</h2>
  <p>There are a million ways to take IMU data and translate it into motion. Hopefully this gives you a look into how easy it is to get started, and inspires you to build on this simple tutorial to create your own moving masterpiece. Happy Hacking!!</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/7/3/MotionToMovementDream.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementDream.jpg" alt="alt text" style="max-width: 100%;" /></a> </div>
<div class="center-block text-center"> <i><sup>Dream big, makers! Dream big!!</sup></i> </div></p>

<p><br>
<div class="center-block text-center"> <a href="https://share.hsforms.com/1m0duVCnuQq2rkKKWDYKdOQ1bo1v" class="btn btn-default">Have you built a sweet IMU project? We want to see it!</a> </div></p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/imu-data-to-motion-tutorial-for-translating-sensor-data-into-real-world-movement</link><guid isPermaLink="false">74915b2f7c4eb7fbb49b074efef891a1</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Sun, 03 Nov 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/7/3/MotionToMovementSetup.jpg"/></item><item><title><![CDATA[How to Play Mulitple Buzzers at Once]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/140-140/assets/parts/1/3/4/3/1/15081-_01.jpg" style="width: 100%;" /><div><h1>
  How to Play Mulitple Buzzers at Once  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3540">http://sfe.io/t3540</a>
</h3>


  <a name="#polyphony-in-action"></a>
  <h2 id="polyphony-in-action">Polyphony in Action</h2>
  <p>Simple electronic sound devices, such as the <a href="https://www.sparkfun.com/products/24474">SparkFun Qwiic Buzzer</a> can output one note at a time. For a simple beep here or a buzz there, this works just fine. However, if your project needs a little more pizzaz than a single note then you’ll have to utilize multiple buzzers at once. This is what is called Polyphony. Polyphony is simply when two or more separate tones or melodies are sounded out simultaneously. As mentioned before, Qwiic Buzzers only make one sound at a time so in order to create a polyphonic melody you would need to utilize multiple Qwiic Buzzers. This involves setting each buzzer to a different I2C address and playing different notes simultaneously, creating more complex and rich soundscapes in your projects.</p>

<p>In this tutorial, we'll connect three Qwiic Buzzers to a <a href="https://www.sparkfun.com/products/18158">RedBoard</a> microcontroller and play a melody, harmony, and bass part of one of the most recognizable tunes of all time; the Super Mario Bros theme!</p>  <a name="#hardware-needed"></a>
  <h2 id="hardware-needed">Hardware Needed</h2>
  <ul>
<li>Three <a href="https://www.sparkfun.com/products/24474">SparkFun Qwiic Buzzers</a></li>
<li>We’ll use the <a href="https://www.sparkfun.com/products/18158">SparkFun RedBoard Plus</a> in this example but any Arduino compatible board should work.</li>
<li><a href="https://www.sparkfun.com/products/15081">Qwiic cables</a></li>
</ul>



<div class="tile-wrap">
<div class="tile product-tile has_addl_actions  grid " data-id="product-15081">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/15081">
        <img src="https://cdn.sparkfun.com/r/140-140/assets/parts/1/3/4/3/1/15081-_01.jpg" alt="SparkFun Qwiic Cable Kit" height="140" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="15081">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_15081" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_15081 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_15081"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/15081">
          <span>SparkFun Qwiic Cable Kit</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      KIT-15081    </span>

          <p class="description" style="display:none">
        To make it even easier to get started, we've assembled this Qwiic Cable Kit with a variety of Qwiic cables from 50mm to 500mm…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$8.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.5 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">22</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="15081">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">91</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="15081" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
<div class="tile product-tile has_addl_actions  grid " data-id="product-18158">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/18158">
        <img src="https://cdn.sparkfun.com/r/140-140/assets/parts/1/7/4/8/7/18158-SparkFun_RedBoard_Plus-01.jpg" alt="SparkFun RedBoard Plus" height="140" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="18158">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_18158" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_18158 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_18158"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/18158">
          <span>SparkFun RedBoard Plus</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="only 11 left!"><span class=sfe-icon-stock-low><span class=visuallyhidden>Only 11 left!</span></span></a>
    </span>

    <span class="sku">
      DEV-18158    </span>

          <p class="description" style="display:none">
        The RedBoard Plus is an Arduino-compatible development board that has everything you need in an Arduino Uno with extra perks …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$21.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.8 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-full" data-star-index="4"></span>
  </span>
      <span class="count">6</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="18158">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">28</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="18158" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
<div class="tile product-tile has_addl_actions  grid " data-id="product-24474">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24474">
        <img src="https://cdn.sparkfun.com/r/140-140/assets/parts/2/4/8/3/2/BOB-24474-Qwiic-Buzzer-Feature.jpg" alt="SparkFun Qwiic Buzzer" height="140" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24474">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24474" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24474 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24474"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24474">
          <span>SparkFun Qwiic Buzzer</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      BOB-24474    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Buzzer adds simple beeps and buzzes to your projects via I2C. Make some noises to alert you when something…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$6.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24474">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">5</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24474" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>

  <div class="clearfix"></div>



<p> </p>

<hr>

<p> </p>  <a name="#connecting-the-hardware"></a>
  <h2 id="connecting-the-hardware">Connecting the Hardware</h2>
  <h3>Connections are breeze with Qwiic:</h3>

<ol>
    <li>Connect three SparkFun Qwiic Buzzers to your microcontroller via the Qwiic connectors.</li>
    <li>Ensuring each buzzer has a unique I2C address is key to playing the buzzers simultaneously:</li>
        <ul>
            <li>Default addresses are <b>0x34</b>, <b>0x35</b>, and <b>0x36</b> for the melody, harmony, and bass buzzers, respectively.
            </li>
        </ul>
    <li>Setup Simple Circuit:
Use Qwiic cables to daisy-chain the buzzers to the microcontroller.</li>

</ol>

<p> </p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/4/0/qwiic-buzzer-nintendo.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/5/4/0/qwiic-buzzer-nintendo.jpg" alt="Qwiic Buzzer Setup" style="max-width: 100%;" /></a> </div></p>

<p align="center" class="small">If you've been to SparkFun HQ you'll recognize our giant Nintendo controller.</p>

<p> </p>

<hr>

<p> </p>  <a name="#software-setup"></a>
  <h2 id="software-setup">Software Setup</h2>
  <p>Before you begin you'll first need to <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide/all">Install the Arduino IDE</a> and SparkFun Qwiic Buzzer Arduino Library.</p>

<h3>Installing the Qwiic Buzzer Library</h3>

<ul>
    <li>Open the Arduino IDE.</li>
    <li>Go to Sketch > Include Library > Manage Libraries...</li>
    <li>Search for "SparkFun Qwiic Buzzer Arduino Library" and install it or install from the link below.</li>
</ul>

<a href="https://github.com/sparkfun/SparkFun_Qwiic_Buzzer_Arduino_Library" class="btn btn-default">Qwiic Buzzer Arduino Library</a>

<p> </p>

<hr>

<p> </p>  <a name="#running-the-code"></a>
  <h2 id="running-the-code">Running the Code</h2>
  <ol>
    <li><b>Upload the Code:</b></li>
        <ul>
            <li>Connect your microcontroller to your computer.</li>
            <li>Open the Arduino IDE.</li>
            <li>Copy and paste the provided code into the IDE.</li>
            <li>Select the correct board and port.</li>
            <li>Click Upload.</li>
        </ul>
        
    <li><b>Observe the Buzzers:</b></li>
        <ul>
            <li>Once the code is uploaded, the buzzers will play the Super Mario Bros theme with melody, harmony, and bass parts.</li>
        </ul>
</ol>

<div class="clearfix"></div>

<div id="scoped-content">
    
<video controls>
  <source src="https://cdn.sparkfun.com/assets/learn_tutorials/3/5/4/0/qwiic-buzzer-demo.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>
</div>

<p> </p>

<pre><code>/*
* SparkFun Qwiic Buzzer Polyphony Demo
* 
* This example shows off the Qwiic Buzzer's ability
* to comtrol multiple buzzers simultaneously by
* playing a 3-part arrangement of a little bit of
* the Super Mario Bros Theme.
* 
* By Rob Reynolds @ SparkFun Electronics
* February 2024
* 
* Hardware connections:
* Connect three (3) SparkFun Qwiic Buzzers to you
* microcontroller via the Qwiic connectors.
* 
* SparkFun code, firmware, and software is released under the MIT License.
* Please see LICENSE.md for further details.
* 
* This code is released under the Beerware License. If you find this code
* useful, and see me or any other Funion at the local, buy us a beer!
* 
* Distributed as-is, with no warranty * 
* 
*/


#include <SparkFun_Qwiic_Buzzer_Arduino_Library.h>  // Import the library for the Qwiic Buzzer
QwiicBuzzer melodyBuzzer; //0x34 (default)
QwiicBuzzer harmonyBuzzer; //0x35 (previously changed)
QwiicBuzzer bassBuzzer; //0x36  (previously changed)

// notes in the melody:
int melody[] = {
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_E5, 
  SFE_QWIIC_BUZZER_NOTE_C5, 
  SFE_QWIIC_BUZZER_NOTE_E5, 
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_REST,  // silence (aka "rest") 
  SFE_QWIIC_BUZZER_NOTE_G4, 
  SFE_QWIIC_BUZZER_NOTE_REST,  // silence (aka "rest")
  // "A" section starts here***********************************
  SFE_QWIIC_BUZZER_NOTE_C5, 
  SFE_QWIIC_BUZZER_NOTE_REST,  // silence (aka "rest")
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_REST,  // silence (aka "rest")
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_REST,  // silence (aka "rest")
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_AS4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_G4, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_A5,
  SFE_QWIIC_BUZZER_NOTE_F5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  // "A" section repeat starts here ***********************
  SFE_QWIIC_BUZZER_NOTE_C5, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_AS4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_G4, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_A5,
  SFE_QWIIC_BUZZER_NOTE_F5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  //"B" Section starts here**************************
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 7
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_FS5,
  SFE_QWIIC_BUZZER_NOTE_F5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 8
  SFE_QWIIC_BUZZER_NOTE_GS4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 9
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_FS5,
  SFE_QWIIC_BUZZER_NOTE_F5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 10
  SFE_QWIIC_BUZZER_NOTE_C6,
  SFE_QWIIC_BUZZER_NOTE_C6,
  SFE_QWIIC_BUZZER_NOTE_C6,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 11
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_FS5,
  SFE_QWIIC_BUZZER_NOTE_F5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 12
  SFE_QWIIC_BUZZER_NOTE_GS4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 13
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C5,    //measure 14
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
};

// Notes in the harmony
int harmony[] = {
  SFE_QWIIC_BUZZER_NOTE_FS4,
  SFE_QWIIC_BUZZER_NOTE_FS4,
  SFE_QWIIC_BUZZER_NOTE_FS4, 
  SFE_QWIIC_BUZZER_NOTE_FS4, 
  SFE_QWIIC_BUZZER_NOTE_FS4, 
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,   
  SFE_QWIIC_BUZZER_NOTE_G3, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  // "A" section starts here*********************************
  SFE_QWIIC_BUZZER_NOTE_E4, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_CS4,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_C4, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  // "A" section repeat starts here*********************************
  SFE_QWIIC_BUZZER_NOTE_E4, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_CS4,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_C4, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_A4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  //"B" Section starts here**************************
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 7
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 8
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 9
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 10
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_G5,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 11
  SFE_QWIIC_BUZZER_NOTE_E5,
  SFE_QWIIC_BUZZER_NOTE_DS5,
  SFE_QWIIC_BUZZER_NOTE_D5,
  SFE_QWIIC_BUZZER_NOTE_B4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C5,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 12
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_G4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_REST,  //measure 13
  SFE_QWIIC_BUZZER_NOTE_GS4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_E4,    //measure 14
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
  SFE_QWIIC_BUZZER_NOTE_REST,
};

// notes in the bass:
int bass[] = {
  SFE_QWIIC_BUZZER_NOTE_D3,
  SFE_QWIIC_BUZZER_NOTE_D3,
  SFE_QWIIC_BUZZER_NOTE_D3, 
  SFE_QWIIC_BUZZER_NOTE_D3, 
  SFE_QWIIC_BUZZER_NOTE_D3, 
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_REST,   
  SFE_QWIIC_BUZZER_NOTE_G2, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  // "A" section starts here**********************************
  SFE_QWIIC_BUZZER_NOTE_G3, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_E3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_F3,
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_FS3,
  SFE_QWIIC_BUZZER_NOTE_F3,
  SFE_QWIIC_BUZZER_NOTE_E3, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_A3,
  SFE_QWIIC_BUZZER_NOTE_B3,
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_REST,
  // "A" section starts here**********************************
  SFE_QWIIC_BUZZER_NOTE_G3, 
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_E3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_C3,
  SFE_QWIIC_BUZZER_NOTE_REST,  
  SFE_QWIIC_BUZZER_NOTE_F3,
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_FS3,
  SFE_QWIIC_BUZZER_NOTE_F3,
  SFE_QWIIC_BUZZER_NOTE_E3, //TRIPLETS START
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_F4,
  SFE_QWIIC_BUZZER_NOTE_D4,
  SFE_QWIIC_BUZZER_NOTE_E4,
  SFE_QWIIC_BUZZER_NOTE_C4,
  SFE_QWIIC_BUZZER_NOTE_A3,
  SFE_QWIIC_BUZZER_NOTE_B3,
  SFE_QWIIC_BUZZER_NOTE_G3,
  SFE_QWIIC_BUZZER_NOTE_REST,
  // "B" section starts here ***************************************
  // Numbers indicate note durations, just for my reference when writing
  SFE_QWIIC_BUZZER_NOTE_C3,    //4  measure 7
  SFE_QWIIC_BUZZER_NOTE_REST,  //8 
  SFE_QWIIC_BUZZER_NOTE_G3,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_C4,    //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_F3,    //4  measure 8
  SFE_QWIIC_BUZZER_NOTE_REST,  //16
  SFE_QWIIC_BUZZER_NOTE_REST,  //16
  SFE_QWIIC_BUZZER_NOTE_C4,    //8
  SFE_QWIIC_BUZZER_NOTE_C4,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_F3,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_C3,    //4  measure 9
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_G3,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_G3,    //8
  SFE_QWIIC_BUZZER_NOTE_C4,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //2  measure 10
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_G3,    //4
  SFE_QWIIC_BUZZER_NOTE_C3,    //4  measure 11
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_G3,    //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_C4,    //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_F3,    //4  measure 12
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_C4,    //8
  SFE_QWIIC_BUZZER_NOTE_C4,    //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_F3,    //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //4
  SFE_QWIIC_BUZZER_NOTE_C3,    //4  measure 13
  SFE_QWIIC_BUZZER_NOTE_GS3,   //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_AS3,   //4
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_C4,    //4  measure 14
  SFE_QWIIC_BUZZER_NOTE_REST,  //8
  SFE_QWIIC_BUZZER_NOTE_G3,    //8
  SFE_QWIIC_BUZZER_NOTE_G3,    //4
  SFE_QWIIC_BUZZER_NOTE_C3,    //4
};


// note durations: 4 = quarter note, 8 = eighth note, etc.:
int marioNoteDurations[] = {
  8, 4, 4, 8, 4,    4, 4, 4, 4,
  4, 8, 4, 8, 4,    8, 4, 4, 8, 4,    6, 6, 6, 4, 8, 4,    4, 8, 8, 4, 8,
  4, 8, 4, 8, 4,    8, 4, 4, 8, 4,    6, 6, 6, 4, 8, 4,    4, 8, 8, 4, 8,  //start "B" section next line
  4, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    4, 8, 8, 8, 8, 8, 8,    8, 4, 8, 4, 4,
  4, 8, 8, 8, 8, 8, 8,    8, 8, 8, 8, 8, 8, 8, 8,    4, 4, 8, 4, 8,     4, 8, 8, 4, 4
  // The extended spaces above aren't necessary, I use them to separate measures
  // simply to help me keep the music more clear. Very helpful for debugging!
};

void setup() {
  Serial.begin(115200);
  Serial.println("Qwiic Buzzer Super Mario Bros Sample");
  Wire.begin(); //Join I2C bus
  melodyBuzzer.begin(0x34);
  harmonyBuzzer.begin(0x35);
  bassBuzzer.begin(0x36);

/*  
  // These are good for testing, I commented them out when I moved the project to stand-alone

  //check if buzzer will connect over I2C
  if (buzzer1.begin() == false) {
    Serial.println("Buzzer 1 did not connect! Freezing.");
    while (1);
  }

  else if (buzzer2.begin() == false) {
    Serial.println("Buzzer 2 did not connect! Freezing.");
    while (1);
  }

  else if (buzzer3.begin() == false) {
    Serial.println("Buzzer 3 did not connect! Freezing.");
    while (1);
  }

*/
  Serial.println("Buzzers connected.");

  Serial.println("Buzzing Melody now...");
  play_melody();
}

void loop() {
  // do nothing here
  // we just play the melody once during setup above.
}

void play_melody()
{
    // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 103; thisNote++) {  // 51 for A section only (repeated), 97 for entire demo for total melody/harmony notes, add 8 rests to bass

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int melodyNoteDuration = 1000 / marioNoteDurations[thisNote];  // change number to change tempo. <1000 = faster; >1000 = slower

    melodyBuzzer.configureBuzzer(melody[thisNote], melodyNoteDuration, SFE_QWIIC_BUZZER_VOLUME_MAX);
    melodyBuzzer.on();

    harmonyBuzzer.configureBuzzer(harmony[thisNote], melodyNoteDuration, SFE_QWIIC_BUZZER_VOLUME_MAX);
    harmonyBuzzer.on();

    bassBuzzer.configureBuzzer(bass[thisNote], melodyNoteDuration, SFE_QWIIC_BUZZER_VOLUME_MAX);
    bassBuzzer.on();



    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = melodyNoteDuration * 1.30;
    delay(pauseBetweenNotes);
  }
}
</code></pre>

<h3>Code Explanation</h3>

<p>The code for this project can be a little intense as each individual sound that is made over 3 buzzers is a line of code. Our very own Rob Reynolds went through the painstaking process of working with figuring out each tone and octive needed for the Super Mario Brother's theme music. You can read all about his efforts <a href="https://www.sparkfun.com/news/9910">here</a>.</p>

<a href="https://www.sparkfun.com/news/9910" class="btn btn-default">Raise your Buzzer Projects to the Next Level</a>

<h3>Key Points in the Code</h3>

<ol>
<li>Making sure the library is included: <strong>#include <SparkFun_Qwiic_Buzzer_Arduino_Library.h></strong></li>
<li>Initialize Buzzers: Define three and assign each for melody, harmony, and bass.</li>
<li>Play Melody Function: Configure each buzzer to play its respective part in the song.</li>
</ol>

<p> </p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/how-to-play-mulitple-buzzers-at-once</link><guid isPermaLink="false">a2b2f683b26693dfafe5acf9c92de74e</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Fri, 18 Oct 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/140-140/assets/parts/1/3/4/3/1/15081-_01.jpg"/></item><item><title><![CDATA[How To Take Multiple RFID Readings Simultaneously]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/6/2/WRL-24738-Simultaneous-RFID-Reader-Feature.jpg" style="width: 100%;" /><div><h1>
  How To Take Multiple RFID Readings Simultaneously  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3441">http://sfe.io/t3441</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>In this tutorial, we'll show you how to set up the SparkFun Simultaneous RFID Reader to take multiple, if not nearly unlimited, <a href="https://www.sparkfun.com/rfid">RFID</a> readings simultaneously by connecting either the M7E Hecto or M6E Nano directly to your computer using a USB-C connection and running Universal Reader Assistant (URA) software, which provides a simple and effective interface for configuring and managing your RFID reader. This is really useful for applications like measuring attendance at events, as well livestock management etc.</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24738">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24738">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/6/2/WRL-24738-Simultaneous-RFID-Reader-Feature.jpg" alt="SparkFun Simultaneous RFID Reader - M7E Hecto" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24738">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24738" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24738 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24738"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24738">
          <span>SparkFun Simultaneous RFID Reader - M7E Hecto</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      WRL-24738    </span>

          <p class="description" style="display:none">
        The SparkFun M7E Hecto Simultaneous RFID Reader simplifies reading UHF RFID tags (EPCglobal Gen 2) with its powerful M7E-HECT…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$299.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24738">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">15</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24738" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<div class="flex-video-wrap clearfix">
  <div class="flex-video widescreen img">
    <iframe src="https://www.youtube.com/embed/ITT54OnKUzM/?autohide=1&border=0&wmode=opaque&enablejsapi=1" frameborder=0 allowfullscreen width="560" height="315"></iframe>
  </div>
</div>  <a name="#required-hardware-"></a>
  <h2 id="required-hardware-">Required Hardware </h2>
  <p>To complete this project, you will need the following components:</p>

<ul>
<li><p><a href="https://www.sparkfun.com/products/24738">SparkFun Simultaneous RFID Reader - M7E Hecto</a> or...</p></li>
<li><p><a href="https://www.sparkfun.com/products/14066">SparkFun Simultaneous RFID Reader - M6E Nano</a> (older version)</p></li>
<li><p><a href="https://www.sparkfun.com/products/15426">Reversible USB A to C Cable - 0.3m</a></p></li>
<li><p>A computer with a USB-C port (running Windows, which is required for URA software)</p></li>
<li><p><a href="https://www.sparkfun.com/categories/559">RFID Tags</a> - we offer a bunch of different types, check out the link to see what works best for your application</p></li>
</ul>

<p>For this simple setup, you do not need a microcontroller. However, in many (maybe most) practical applications, it would make sense to connect the RFID Reader to a microcontroller and add an antenna so you could take readings remotely without your computer in front of you and extend the range (which goes up to 3 or 4 feet in this example). Users who prefer to communicate with the RFID reader using the Serial PTH header should solder either wires or header pins to connect them to a 3.3V microcontroller, such as our <a href="https://www.sparkfun.com/products/15444">RedBoard Artemis</a>. Check out our <a href="https://docs.sparkfun.com/SparkFun_Simultaneous_RFID_Reader_M7E/hardware_assembly/#communicating-via-usb-c-serial">Hookup Guide</a> for instructions on how to do this.</p>  <a name="#setting-up-your-simultaneous-rfid-reader"></a>
  <h2 id="setting-up-your-simultaneous-rfid-reader">Setting Up Your Simultaneous RFID Reader</h2>
  <p>To connect the RFID reader directly to your computer via USB-C. Follow these steps:</p>

<ul>
<li><p>Connect the USB-C Cable: Plug the USB-C end of the cable into the RFID reader and the USB-A end into your computer. This connection will provide both power and data communication between the RFID reader and your computer.</p></li>
<li><p>Check the UART Selection Switch: Ensure that the UART selection switch on the RFID reader is in the correct position for USB operation. This is crucial for proper communication with the software.</p></li>
</ul>  <a name="#how-to-download-and-install-universal-reader-assistant-ura"></a>
  <h2 id="how-to-download-and-install-universal-reader-assistant-ura">How to Download and Install Universal Reader Assistant (URA)</h2>
  <p>With the hardware set up, you can now move on to using the Universal Reader Assistant to interact with your RFID reader.</p>

<p>The Universal Reader Assistant (URA) software is a powerful tool designed to help you make full use of the capabilities of your SparkFun Simultaneous RFID Reader. Unfortunately, as mentioned, <u>the URA is only available for Windows.</u></p>

<a href="https://www.jadaktech.com/product/thingmagic-universal-reader-assistant/" class="btn btn-default">Download URA</a>

<h3>Setting Up the URA</h3>

<ul>
<li>Download the URA: Visit the <a href="https://www.jadaktech.com/product/thingmagic-universal-reader-assistant/">ThingMagic website</a> to download the Universal Reader Assistant. Ensure you choose the correct version (32-bit or 64-bit) based on your Windows operating system.</li>
<li>Install the URA: Once the download is complete, open the installer and follow the instructions provided by the installation wizard.</li>
</ul>

<h3>Using the Software</h3>

<ul>
<li>Connect Your RFID Reader: Make sure your Simultaneous RFID Reader is connected to your computer via USB. Open the Universal Reader Assistant after the installation is complete.</li>
<li>Connection Wizard: Upon opening URA, you will be greeted by the Connection Wizard menu. Here, you can select the reader type and the port your RFID reader is connected to. (If you're familiar with the setup, you can skip this selection and move directly to the main menu. Otherwise, select the correct port for your RFID reader and click "Next.")</li>
</ul>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/1/URA-Port_Selection.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/1/URA-Port_Selection.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<ul>
<li>Connect to the Reader: The Connection Wizard should display your RFID reader's settings. You can click "Connect & Read" to start scanning tags immediately or "Connect" to access the main window without starting the read operation.</li>
</ul>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/1/URA-M7E_Selected.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/1/URA-M7E_Selected.jpg" alt="alt text" style="max-width: 100%;" /></a> </div></p>  <a name="#ura-features-and-tips"></a>
  <h2 id="ura-features-and-tips">URA Features and Tips</h2>
  <h3>Exploring URA Features</h3>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/1/Screenshot_2024-09-12_at_12.47.24___PM.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/4/4/1/Screenshot_2024-09-12_at_12.47.24___PM.png" alt="alt text" style="max-width: 100%;" /></a> </div></p>

<p>The main window of the Universal Reader Assistant offers a wide range of settings and status options for the M6E Nano or M7E Hecto RFID readers. Here are some key features you can explore.</p>

<p>Read/Write Options: Adjust the RFID reader's power level, read/write settings, and other operational parameters.</p>

<div class="alert alert-info">
<b>Practical Tech Tips</b> - most settings can be adjusted on the right drop down menu. 
</br>
</br>
Thermal Management: The RFID reader has an internal temperature sensor to prevent damage from overheating. If you encounter a temperature-limit fault, reduce the read power or improve cooling.
</br>
</br>
Power Level: Start with a moderate power level (e.g., 500 dBm) to prevent the USB port from browning out. You can increase the power as needed but be mindful of thermal limits.
</br>
</br>
Tag Read Efficiency: Experiment with different settings in the URA to optimize the RFID reader's performance for your specific application.
</div>  <a name="#final-thoughts"></a>
  <h2 id="final-thoughts">Final Thoughts</h2>
  <p>By following this tutorial, you’ve (hopefully) successfully set up your SparkFun Simultaneous RFID Reader to take multiple RFID readings directly through a USB connection using your computer. The Universal Reader Assistant software allows you to explore the full potential of your RFID reader, making it a powerful tool for various RFID applications. Happy hacking!</p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/how-to-take-multiple-rfid-readings-simultaneously</link><guid isPermaLink="false">ec6a8d194416dbacc99a89b5b4f806ee</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Thu, 22 Aug 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/6/2/WRL-24738-Simultaneous-RFID-Reader-Feature.jpg"/></item><item><title><![CDATA[Detecting Colors with the SparkFun Tristimulus Color Sensor]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/7/9/8/22638-_SEN_SparkFun_Tristimulus_Color_Sensor-_01.jpg" style="width: 100%;" /><div><h1>
  Detecting Colors with the SparkFun Tristimulus Color Sensor  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3442">http://sfe.io/t3442</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>In this tutorial, we'll show you how to use the SparkFun Tristimulus Color Sensor - OPT4048DTSR (Qwiic) to detect and classify colors based on their CIE XYZ color space values. The sensor is capable of measuring the color intensity in the X, Y, and Z channels, which correspond to red, green, and blue components in a simplified form.</p>

<div class="row">
    <div class="col-md-6">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-22638">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/22638">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/7/9/8/22638-_SEN_SparkFun_Tristimulus_Color_Sensor-_01.jpg" alt="SparkFun Tristimulus Color Sensor - OPT4048DTSR (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="22638">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_22638" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_22638 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_22638"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/22638">
          <span>SparkFun Tristimulus Color Sensor - OPT4048DTSR (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="34 available"><span class=sfe-icon-stock-low><span class=visuallyhidden>34 available</span></span></a>
    </span>

    <span class="sku">
      SEN-22638    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic Tristimulus Color Sensor is built around the OPT4048 High Speed High Precision Tristimulus XYZ Color Senso…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$9.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="22638">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">6</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="22638" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-6">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-22639">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/22639">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/7/9/9/22639-_SEN_SparkFun_Mini_Tristimulus_Color_Sensor-_01.jpg" alt="SparkFun Mini Tristimulus Color Sensor - OPT4048DTSR (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="22639">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_22639" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_22639 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_22639"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/22639">
          <span>SparkFun Mini Tristimulus Color Sensor - OPT4048DTSR (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-22639    </span>

          <p class="description" style="display:none">
        The SparkFun Mini Tristimulus Color Sensor - OPT4048DTSR (Qwiic) is built around the OPT4048 High Speed High Precision Tristi…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$10.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="22639">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">2</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="22639" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<p>If you are looking for the full Hookup Guide for the SparkFun Tristimulus Color Sensor - OPT4048DTSR (Qwiic), click the button bellow. This guide only covers a simple project to get you started quickly, while the full Hookup Guide goes over every detail of the sensor.</p>

<p><div class="center-block text-center"> <a href="https://docs.sparkfun.com/SparkFun_Tristimulus_Color_Sensor-OPT4048/introduction/" class="btn btn-default">View the Full Hookup Guide</a> </div></p>

<p> </p>

<hr />  <a name="#hardware-needed"></a>
  <h2 id="hardware-needed">Hardware Needed</h2>
  <p>To follow this experiment, you will need the following materials. While this is a simple project we wanted to make sure that you have everything you need to get started before we get to the code. For this simple project we chose the <a href="https://www.sparkfun.com/products/15123">RedBoard Qwiic</a> but you could choose from many of our development boards such as the <a href="https://www.sparkfun.com/products/15795">Qwiic Pro Micro</a> as well.</p>

<p> </p>

<script src="https://www.sparkfun.com/wish_lists/176857.js"></script>

<p> </p>

<hr />  <a name="#software-setup"></a>
  <h2 id="software-setup">Software Setup</h2>
  <div class="alert alert-info">
<b>Note:</b> If this is your first time using Arduino, please review our tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">installing the Arduino IDE.</a> If you have not previously installed an Arduino library, please check out our <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library">installation guide.</a>
</div>  <a name="#installing-the-required-libraries"></a>
  <h2 id="installing-the-required-libraries">Installing the Required Libraries</h2>
  <ul>
<li><strong>Install the SparkFun OPT4048 Library</strong>: Open the Arduino IDE and navigate to <strong>Sketch > Include Library > Manage Libraries</strong>. In the Library Manager, search for <strong>"OPT4048"</strong> and install the latest version from SparkFun.</li>
</ul>  <a name="#read-measurements-with-a-serial-monitor"></a>
  <h2 id="read-measurements-with-a-serial-monitor">Read Measurements with a Serial Monitor</h2>
  <p>Now that we've installed the Arduino library, it's time to upload our first sketch to make sure everything is working properly and you are able to read basic measurements with your Serial Monitor in the Arduino IDE.</p>

<p>For this example you will need the <a href="https://www.sparkfun.com/products/22638">SparkFun Tristimulus Color Sensor - OPT4048DTSR (Qwiic)</a>, a <a href="https://www.sparkfun.com/products/15123">SparkFun RedBoard Qwiic</a>, a <a href="https://www.sparkfun.com/products/14427">Qwiic Cable</a>, and a <a href="https://www.sparkfun.com/products/10215">USB Micro-B Cable</a>.</p>

<p>Using the Qwiic system, assembling the hardware is simple. Connect the RedBoard to one of the SparkFun Tristimulus Color Sensor Qwiic ports using your Qwiic cables (please remember to insert this cable in the correct orientation). Then connect the RedBoard to your computer via the MicroUSB cable and voila! You're ready to rock!</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/24805-Ultrasonic-Distance-Sensor-Action-2.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/22638-SparkFun_Tristimulus_Color_Sensor-Hookup.jpg" alt="SparkFun Tristimulus Color Sensor to RedBoard" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>SparkFun Tristimulus Color Sensor to RedBoard</em> </div></p>

<p> </p>

<p>Alternatively, you can copy and paste the code below into a shiny new Arduino sketch:</p>

<pre><code>#include "SparkFun_OPT4048.h"  // Include the SparkFun OPT4048 library
#include <Wire.h>  // Include the Wire library for I2C communication

SparkFun_OPT4048 colorSensor;  // Create an instance of the OPT4048 color sensor

void setup() {
 Serial.begin(115200);  // Initialize serial communication at 115200 baud
 Serial.println("OPT4048 Color Sensing Example");  // Print a message to the serial monitor

 Wire.begin();  // Initialize the I2C bus

 if (!colorSensor.begin()) {  // Try to initialize the color sensor
   Serial.println("OPT4048 not detected - check wiring or I2C address!"); 
   while (1);  // Enter an infinite loop to halt the program
 }

 colorSensor.setBasicSetup();  // Apply basic setup configuration to the sensor

 Serial.println("Sensor initialized and ready!");  // Print a success message
}

void loop() {
  float x = colorSensor.getCIEx();  // Get the CIE X value from the sensor
  float y = colorSensor.getCIEy();  // Get the CIE Y value from the sensor
  float z = 1 - x - y;  // Approximate the CIE Z value (this is a simplification)

  Serial.print("CIEx: ");  // Print label for CIE X value
  Serial.print(x, 4);  // Print CIE X value with 4 decimal places
  Serial.print(" CIEy: ");  // Print label for CIE Y value
  Serial.print(y, 4);  // Print CIE Y value with 4 decimal places
  Serial.print(" CIEz: ");  // Print label for CIE Z value
  Serial.print(z, 4);  // Print approximated CIE Z value with 4 decimal places

  String detectedColor = classifyColor(x, y, z);  // Classify the color based on CIE values
  Serial.print(" Detected color: ");  // Print label for detected color
  Serial.println(detectedColor);  // Print the classified color

  delay(600);  // Wait for 600ms before the next reading (3 channels * 200ms conversion time)
}

String classifyColor(float x, float y, float z) {
  float total = x + y + z;  // Calculate the sum of x, y, and z
  float r = x / total;  // Calculate the relative red component
  float g = y / total;  // Calculate the relative green component
  float b = z / total;  // Calculate the relative blue component

  // The following if statements check the RGB ratios to classify the color
  if (r > 0.4 && g < 0.3 && b < 0.3) return "Red";
  if (r < 0.3 && g > 0.4 && b < 0.3) return "Green";
  if (r < 0.3 && g < 0.3 && b > 0.4) return "Blue";
  if (r > 0.3 && g > 0.3 && b < 0.3) return "Yellow";
  if (r > 0.3 && g < 0.3 && b > 0.3) return "Purple";
  if (r < 0.3 && g > 0.3 && b > 0.3) return "Cyan";
  if (r > 0.3 && g > 0.3 && b > 0.3) return "White";
  if (r < 0.1 && g < 0.1 && b < 0.1) return "Black";

  return "Unknown";  // If no color matches, return "Unknown"
}
</code></pre>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, go ahead and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>. Set the baud rate to 115200. You should see output like this:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/Color_reading_.png"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/Color_reading_.png" alt="Color Readings" style="max-width: 100%;" /></a> </div></p>  <a name="#interpreting-the-results"></a>
  <h2 id="interpreting-the-results">Interpreting the Results</h2>
  <ul>
<li><strong>CIEx, CIEy, CIEz</strong>: These are the values from the CIE 1931 color space which represent the color's chromaticity.</li>
<li><strong>Detected Color</strong>: Based on the values, the code attempts to classify the color into a basic category like "Red," "Green," "Blue," etc.</li>
</ul>

<p>The CIEx and CIEy values are going to fall somewhere between 0 and 1. Page 35 of the <a href="https://docs.sparkfun.com/SparkFun_Tristimulus_Color_Sensor-OPT4048/assets/board_files/opt4048.pdf">datasheet</a> gives more detail on this, but generally speaking, you can map the predominant color of the space you're measuring using the following:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/CIE-YX-Color-Readings.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/CIE-YX-Color-Readings.jpg" alt="CIE Y and X Color Readings" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/CIE-VU-Color-Readings.jpg"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/4/2/CIE-VU-Color-Readings.jpg" alt="CIE V and U Color Readings" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> CIE XY and CIE UV space plots of color coordinates </div></p>

<p>For more information on the CIE and CIY values, refer to the CIE 1931 <a href="https://en.wikipedia.org/wiki/CIE_1931_color_space">Color Space Wiki Page</a>.</p>

<p>If you see unexpected values or the sensor isn’t detected, double-check your wiring and ensure the sensor is properly connected to the I2C bus.</p>  <a name="#conclusion"></a>
  <h2 id="conclusion">Conclusion</h2>
  <p>You've successfully set up the SparkFun Tristimulus Color Sensor to classify colors based on CIE XYZ values. This tutorial provides a foundation for more advanced color detection projects. You can now expand on this knowledge to create sophisticated color analysis systems or integrate the sensor into larger, more complex projects.</p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/detecting-colors-with-the-sparkfun-tristimulus-color-sensor</link><guid isPermaLink="false">d94382316c9830a18019f3b524a4b9c1</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Thu, 22 Aug 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/7/9/8/22638-_SEN_SparkFun_Tristimulus_Color_Sensor-_01.jpg"/></item><item><title><![CDATA[GeoFence Treasure Hunt With Artemis Global Tracker]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/0/8/image2.png" style="width: 100%;" /><div><h1>
  GeoFence Treasure Hunt With Artemis Global Tracker  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3408">http://sfe.io/t3408</a>
</h3>


  <a name="#the-story"></a>
  <h2 id="the-story">The Story</h2>
  <p>The Artemis Global Tracker is a highly functional sensor device with professional grade pressure, humidity, and temperature sensing with the onboard TE MS8607 PHT sensor, and location data through the onboard u-blox ZOE-M8Q GNSS receiver. It can also be programmed with the Arduino IDE through the Artemis processor and transfer information through the Iridium Satellite Network due to the Iridium 9603N Short Burst Data modem. The goal of this project is to demonstrate the ease of working with this device, and the accuracy and potential of its onboard sensors, specifically the GNSS receiver.</p>

<p>This project will use the Artemis Global Tracker (AGT) to create a “Treasure Game” in which the player begins the game, the AGT will randomly select a position in a 20 meter radius (designated the “treasure spot”), and the onboard LED will blink faster as the player moves toward the “treasure spot” - winning when they find it exactly. In this way, the onboard LED will lead the player to the “treasure spot”. This game will also transfer location information to a computer using the Iridium Satellite Network, meaning it could be played even where no WIFI or wireless data is accessible.</p>  <a name="#the-components"></a>
  <h2 id="the-components">The Components</h2>
  <p> </p>

<script src="https://www.sparkfun.com/wish_lists/176602.js"></script>

<p> </p>

<p>NOTE: To connect to the Iridium Satellite Network requires a monthly fee of $17 and a purchase of credits, however, you can pick and choose the periods to access the network.</p>

<p><br><center><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/0/8/image2.png" width="300" style="max-width: 100%;"></center><br></p>  <a name="#the-setup"></a>
  <h2 id="the-setup">The Setup</h2>
  <p>The first step in the development setup is the software setup. If you have not programmed with the Arduino IDE before, SparkFun made a great introductory guide to setup with the Artemis module which can be <a href="https://learn.sparkfun.com/tutorials/artemis-development-with-the-arduino-ide">found here</a>. It notes the need to add the Artemis module within the Arduino IDE boards manager using the following link:</p>

<pre><code>https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/main/package_sparkfun_apollo3_index.json
</code></pre>

<p>You will also need to add the following libraries to the Arduino IDE: SparkFun u-blox GNSS Arduino Library, IridiumSBDi2c. If you want to make use of the PHT sensor, you will also need the SparkFun PHT MS8607 Arduino Library. These can all be found within the Arduino Library Manager.</p>

<p>To begin development, you will need to connect the Artemis Global Tracker to your device with the Arduino IDE using the USB-C cable, and select the designated board (RedBoard Artemis ATP).</p>  <a name="#the-logic"></a>
  <h2 id="the-logic">The Logic</h2>
  <p>The code enables the GNSS module funcitonality, finds the current longitude and latitude of the AGT device, randomly generates a target distance and angle based on the current location, and begins blinking the onboard LED with intervals relating to the distance between the current location and target location. We will also mark the location of a 30 meter radius around the starting location using the “addGeofence” function from the SparkFun u-blox GNSS Arduino Library. If the device leaves this radius while playing the game, the player will lose. The treasure position is chosen by randomly selecting a distance between 15 and 30 meters and a distance between 0 and 360 degrees from the starting position.</p>

<p>The magic here involves calculating distances and angles with spherical coordinates. The game should be playable on a large (potentially worldly) scale, which means no assuming the Earth is flat. Therefore, from two sets of spherical coordinates (the initial and current position of the AGT device), we need to compute the effective spherical angle and distance between them. Through research, making use of the haversine and bearing equations, where the haversine function calculates the distance between the two positions and the bearing function calculates the angle, seemed like the best approach. They work as follows:</p>

<h4>Haversine Distance Function</h4>

<p><br><center><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/4/0/8/image5.png" width="450" style="max-width: 100%;"></center><br></p>

<pre><code class="c">// GET COORDINATE DISTANCE - HAVERSINE FORMULA

double getCoordinateDistance(long La1, long Lo1, double La2, long Lo2) {
    double radius = 6.3781e6;  // radius of the Earth (meters)
    // conversion to radians
    double rla1 = La1*(1E-7) * (PI/180);
    double rla2 = La2*(1E-7) * (PI/180);
    double rlo1 = Lo1*(1E-7) * (PI/180);
    double rlo2 = Lo2*(1E-7) * (PI/180);

    double a = sin((rla2-rla1)/2) * sin((rla2-rla1)/2) + cos(rla1) * cos(rla2) * sin((rlo2 - rlo1)/2) * sin((rlo2 - rlo1)/2);

    double b = 2 * atan2(sqrt(a), sqrt(1-a));

    return radius * b;

</code></pre>

<h4>Bearing Angle Function</h4>

<pre><code class="c">// GET COORDINATE ANGLE (BEARING) HELPER
long getCoordinateBearing(long La1, long Lo1, long La2, long Lo2) {
    double rLa1 = La1*(1E-7) * (PI/180);
    double rLa2 = La2*(1E-7) * (PI/180);
    double rLo1 = Lo1*(1E-7) * (PI/180);
    double rLo2 = Lo2*(1E-7) * (PI/180);

    double y = sin(rLo2-rLo1) * cos(rLa2);
    double x = cos(rLa1) * sin(rLa2) - sin(rLa1)*cos(rLa2)*cos(rLo2-rLo1);

    return (atan2(y, x) * (180/PI)); // returns angle between -180 and 180

</code></pre>

<p>The necessity of these functions becomes apparent once you learn about the system of spherical coordinates. Longitudinal values may work as expected, associated with a vertical position on a sphere. However, Latitudinal distances become difficult to calculate since each longitudinal value forces each horizontal cross-section of the Earth to be a different sized circle.</p>

<p>With these functions, we calculate the current positions angle and distance from the initial position, essentially creating polar coordinates. Once the distance between the target and current polar coordinates reaches a certain threshold (within 2 meters), the treasure has been found! The distance to the target is also made aware to the player visually through an LED meter as shown in the demo. In order to find this distance we use the polar distance formula as shown:</p>

<p>As the player gets closer to the goal position, the onboard LED blinks faster and faster until it stays lit when the treasure is found. Also, the AGT is writing to the Arduino Serial Monitor with the current player positions, the goal positions, and a message demonstrating how close the player is to the treasure (“hotter”, “colder, etc)</p>  <a name="#the-result"></a>
  <h2 id="the-result">The Result</h2>
  <p>Finally, once the treasure is found, the AGT connects to the iridium satellite network and sends an HTTP POST request with the success message to any destination. The AGT does not need wifi connection for this request: the satellite network does this for you after you make an account with Ground Control and connect the iridium device on the AGT. I made a temporary site on Webhook.site which automatically sets up an endpoint to receive HTTP requests. Here’s an example message after I played the game and won!</p>

<p>The Iridium network can also estimate the approximate location of the message based on the positioning of the satellite themselves.</p>  <a name="#the-code"></a>
  <h2 id="the-code">The Code</h2>
  <p>Here, we have the main loop function which combines the logic above with functions that interact with the AGT hardware.</p>

<pre><code class="c">// MAIN LOOP FUNCTION
void loop() {

 if (WIN) {

   Serial.println(F("YOU FOUND THE TREASURE!!"));
   signalVictory();
   while (true) {
     delay(2000);
     Serial.println(F("YOU FOUND THE TREASURE!!"));
   }

 } else {
   geofenceState currentGeofenceState; // Create storage for the geofence state
   boolean result = myGNSS.getGeofenceState(currentGeofenceState);
   Serial.print(F("getGeofenceState returned: ")); // Print the combined state
   Serial.print(result); // Get the geofence state

   if (!result) // If getGeofenceState did not return true
   {
     Serial.println(F(".")); // Tidy up
     return; // and go round the loop again
   }

   // Print the Geofencing status
   // 0 - Geofencing not available or not reliable; 1 - Geofencing active
   Serial.print(F(". status is: "));
   Serial.print(currentGeofenceState.status);

   // Print the numFences
   Serial.print(F(". numFences is: "));
   Serial.print(currentGeofenceState.numFences);

   // Print the state of the geofence
   // 0 - Unknown; 1 - Inside; 2 - Outside
   Serial.print(F(". The geofence stats is: "));
   Serial.print(currentGeofenceState.states[0]);

   byte fenceStatus = digitalRead(geofencePin); // Read the geofence pin
   digitalWrite(LED, !fenceStatus); // Set the LED (inverted)
   Serial.print(F(". Geofence pin (PIO14) is: ")); // Print the pin state
   Serial.print(fenceStatus);
   Serial.println(F("."));


   // GET CURRENT POSITION
   curr_lat = myGNSS.getLatitude(); // Get the latitude in degrees * 10^-7
   curr_long = myGNSS.getLongitude(); // Get the longitude in degrees * 10^-7
   curr_angle = (getCoordinateBearing(latitude, longitude, curr_lat, curr_long) + 180) % 360;
   curr_distance = getCoordinateDistance(latitude, longitude, curr_lat, curr_long);

   Serial.print(F("Current Latitude: "));
   Serial.print(curr_lat);
   Serial.print(F(". Current Longitude: "));
   Serial.println(curr_long);

   Serial.print(F("Goal Angle: "));
   Serial.print(goal_angle);
   Serial.print(F(". Goal Distance: "));
   Serial.println(goal_distance);

   Serial.print(F("Current Angle: "));
   Serial.print(curr_angle);
   Serial.print(F(". Current Distance: "));
   Serial.println(curr_distance);

   score = sqrt(curr_distance * curr_distance + goal_distance * goal_distance - 2 * goal_distance * curr_distance * cos((curr_angle * (2*PI/360)) - (goal_angle * (2*PI/360))));
   Serial.print(F("Current Score: "));
   Serial.print(score);

   if (score < 2) {
     WIN = true;
   } if (score < 5) {
     Serial.println(F(": HOT!!"));
   } else if (score < 12) {
     Serial.println(F(": Warmerrr..."));
   } else if (score < 20) {
     Serial.println(F(": Room Temp"));
   } else {
     Serial.println(F(": Ice Cold..."));
   }
   Serial.println();

 }

 digitalWrite(LED, LOW);
 delay(score*5);
 digitalWrite(LED, HIGH);
 delay(score*5);
}
</code></pre>

<p>Once the player finds the treasure, the victory function runs, which connects the AGT to the Iridium network and sends a victory message.</p>

<pre><code class="c">void signalVictory() {
  int signalQuality = -1;
  int err;

  pinMode(LED, OUTPUT); // Make the LED pin an output

  gnssOFF(); // Disable power for the GNSS
  pinMode(gnssBckpBatChgEN, INPUT); // GNSS backup batttery charge control
  pinMode(geofencePin, INPUT); // Configure the geofence pin as an input
  pinMode(iridiumPwrEN, OUTPUT); // Configure the Iridium Power Pin
  digitalWrite(iridiumPwrEN, LOW); // Disable Iridium Power
  pinMode(superCapChgEN, OUTPUT); // Configure the super capacitor charger enable pin
  digitalWrite(superCapChgEN, LOW); // Disable the super capacitor charger
  pinMode(iridiumSleep, OUTPUT); // Iridium 9603N On/Off (Sleep) pin
  digitalWrite(iridiumSleep, LOW); // Put the Iridium 9603N to sleep
  pinMode(iridiumRI, INPUT); // Configure the Iridium Ring Indicator as an input
  pinMode(iridiumNA, INPUT); // Configure the Iridium Network Available as an input
  pinMode(superCapPGOOD, INPUT); // Configure the super capacitor charger PGOOD input

  modem.endSerialPort();

  // Enable the supercapacitor
  Serial.println(F("Enabling the supercapacitor charger..."));
  digitalWrite(superCapChgEN, HIGH);
  delay(1000);
  // wait for the capacitor to charge
  while (digitalRead(superCapPGOOD) == false)
  {
    Serial.println(F("Waiting for supercapacitors to charge..."));
    delay(1000);
  }
  Serial.println(F("Supercapacitors charged!"));

  // Enable power for the 9603N (Iridium Connection)
  Serial.println(F("Enabling 9603N power..."));
  digitalWrite(iridiumPwrEN, HIGH); // Enable Iridium Power
  delay(1000);
  modem.setPowerProfile(IridiumSBD::USB_POWER_PROFILE);

  // Startup the modem
  Serial.println(F("Starting modem..."));
  err = modem.begin();
  if (err != ISBD_SUCCESS)
  {
    Serial.print(F("Begin failed: error "));
    Serial.println(err);
    if (err == ISBD_NO_MODEM_DETECTED)
    Serial.println(F("No modem detected: check wiring."));
    return;
  }

  // Test the signal quality.
  err = modem.getSignalQuality(signalQuality);
  if (err != ISBD_SUCCESS)
  {
    Serial.print(F("SignalQuality failed: error "));
    Serial.println(err);
    return;
  }
  modem.useMSSTMWorkaround(false);

  Serial.print(F("On a scale of 0 to 5, signal quality is currently "));
  Serial.print(signalQuality);
  Serial.println(F("."));

  // Send the message
  Serial.println(F("Trying to send the message.  This might take several minutes."));
  err = modem.sendSBDText("YOU FOUND THE TREASURE!!");
  if (err != ISBD_SUCCESS)
  {
    Serial.print(F("sendSBDText failed: error "));
    Serial.println(err);
    if (err == ISBD_SENDRECEIVE_TIMEOUT)
    Serial.println(F("Try again with a better view of the sky."));
  }

  // POWER DOWN IRIDIUM CONNECTION

  // Clear the Mobile Originated message buffer
  Serial.println(F("Clearing the MO buffer."));
  err = modem.clearBuffers(ISBD_CLEAR_MO); // Clear MO buffer
  if (err != ISBD_SUCCESS)
  {
    Serial.print(F("clearBuffers failed: error "));
    Serial.println(err);
  }

  // Power down the modem
  Serial.println(F("Putting the 9603N to sleep."));
  err = modem.sleep();
  if (err != ISBD_SUCCESS)
  {
    Serial.print(F("sleep failed: error "));
    Serial.println(err);
  }

  Serial.println(F("Disabling 9603N power..."));
  digitalWrite(iridiumPwrEN, LOW); // Disable Iridium Power

  Serial.println(F("Disabling the supercapacitor charger..."));
  digitalWrite(superCapChgEN, LOW); // Disable the super capacitor charger

  Serial.println(F("Game Complete!"));
}

</code></pre>  <a name="#next-steps"></a>
  <h2 id="next-steps">Next Steps</h2>
  <p>All of these components together creates a fun hide and seek game with your Artemis Global Tracker! There are many ways one could extend this example and create a higher functioning game. For one, you could create a website designed to take a POST request after a player wins the game and show stats from the game (ex: time until find, score, etc.). Also, you could add hardware components along with the AGT to graphically show game stats for the user while playing. For example, an LED meter would be a great way to show live score updates to the player.</p>  <a name="#acknowledgements"></a>
  <h2 id="acknowledgements">Acknowledgements</h2>
  <p>This project could not have happened without the documentation and examples from the Sparkfun AGT examples repository found <a href="https://github.com/sparkfun/SparkFun_Artemis_Global_Tracker/tree/main/Software/examples">here</a>. Some of Sparkfun’s setup functions and definitions were necessary in the working game, and can be found in the resulting code.</p>

<p>This tutorial was created and engineered by <a href="https://www.linkedin.com/in/jameson-koonce-543292267/">Jameson Koonce</a>, a Computer Engineering Student at the University of Illinois at Urbana-Champaign.</p>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/geofence-treasure-hunt-with-artemis-global-tracker</link><guid isPermaLink="false">6c553b69da6fc68e39350239b0f06bdb</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Wed, 31 Jul 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/assets/learn_tutorials/3/4/0/8/image2.png"/></item><item><title><![CDATA[Display Distance Measurements On an OLED]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/9/7/SEN-24805-Ultrasonic-Distance-Sensor-Feature_2.jpg" style="width: 100%;" /><div><h1>
  Display Distance Measurements On an OLED  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3375">http://sfe.io/t3375</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>This tutorial will take your SparkFun Qwiic Ultrasonic Distance Sensor to the next level by adding a cool little OLED display.  With this upgrade, your robot (or you!) won't just be able to measure distances, you'll be able to see them in real time on the screen!</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24805">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24805">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/9/7/SEN-24805-Ultrasonic-Distance-Sensor-Feature_2.jpg" alt="SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24805">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24805" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24805 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24805"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24805">
          <span>SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-24805    </span>

          <p class="description" style="display:none">
        The TCT40 distance sensor is great for non-contact distance readings from 2cm to 400cm. This unit adds a pair of Qwiic connec…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$9.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24805">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">6</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24805" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<p>If you are looking for the full Hookup Guide for the SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic), click the button bellow. This guide only covers a simple project to get you started quickly, while the full Hookup Guide goes over every detail of the sensor.</p>

<p><div class="center-block text-center"> <a href="https://docs.sparkfun.com/SparkFun_Ultrasonic_Distance_Sensor-Qwiic" class="btn btn-default">View the Full Hookup Guide</a> </div></p>

<p> </p>

<hr />  <a name="#hardware-needed"></a>
  <h2 id="hardware-needed">Hardware Needed</h2>
  <p>To follow this experiment, you will need the following materials. While this is a simple project we wanted to make sure that you have everything you need to get started before we get to the code. For this simple project we chose the <a href="https://www.sparkfun.com/products/15123">RedBoard Qwiic</a> but you could choose from many of our development boards such as the <a href="https://www.sparkfun.com/products/15795">Qwiic Pro Micro</a> as well.</p>

<div class="row">
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24805">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24805">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/9/7/SEN-24805-Ultrasonic-Distance-Sensor-Feature_2.jpg" alt="SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24805">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24805" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24805 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24805"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24805">
          <span>SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-24805    </span>

          <p class="description" style="display:none">
        The TCT40 distance sensor is great for non-contact distance readings from 2cm to 400cm. This unit adds a pair of Qwiic connec…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$9.95</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24805">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">6</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24805" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-15123">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/15123">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/3/4/9/2/15123-SparkFun_RedBoard_Qwiic-01a.jpg" alt="SparkFun RedBoard Qwiic" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="15123">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_15123" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_15123 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_15123"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/15123">
          <span>SparkFun RedBoard Qwiic</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      DEV-15123    </span>

          <p class="description" style="display:none">
        The SparkFun RedBoard Qwiic is an Arduino-compatible development board with a built in Qwiic connector, eliminating the need …      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$21.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">20</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="15123">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">63</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="15123" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-24606">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/24606">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/9/6/3/LCD-24606-Qwiic-OLED-Display-Feature-Screen.jpg" alt="SparkFun Qwiic OLED Display (0.91 in., 128x32)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="24606">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_24606" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_24606 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_24606"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/24606">
          <span>SparkFun Qwiic OLED Display (0.91 in., 128x32)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      LCD-24606    </span>

          <p class="description" style="display:none">
        The SparkFun Qwiic OLED Display can display up to four lines of text and features 128x32 pixels in a small 0.91in. (diagonal)…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$10.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="1 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-empty" data-star-index="1"></span>
          <span class="sfe-icon-star-empty" data-star-index="2"></span>
          <span class="sfe-icon-star-empty" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">1</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="24606">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">17</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="24606" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<div class="row">
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-14427">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/14427">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/2/4/5/3/14427-Qwiic_Cable_-_100mm-01.jpg" alt="Qwiic Cable - 100mm" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="14427">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_14427" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_14427 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_14427"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/14427">
          <span>Qwiic Cable - 100mm</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-14427    </span>

          <p class="description" style="display:none">
        This is a 100mm long 4-conductor cable with 1mm JST termination. It’s designed to connect Qwiic enabled components together…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="14427">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">43</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="14427" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-14427">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/14427">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/2/4/5/3/14427-Qwiic_Cable_-_100mm-01.jpg" alt="Qwiic Cable - 100mm" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="14427">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_14427" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_14427 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_14427"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/14427">
          <span>Qwiic Cable - 100mm</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-14427    </span>

          <p class="description" style="display:none">
        This is a 100mm long 4-conductor cable with 1mm JST termination. It’s designed to connect Qwiic enabled components together…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="14427">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">43</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="14427" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-4">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-10215">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/10215">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/4/5/5/8/10215-01.jpg" alt="USB Micro-B Cable - 6 Foot" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="10215">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_10215" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_10215 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_10215"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/10215">
          <span>USB Micro-B Cable - 6 Foot</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      CAB-10215    </span>

          <p class="description" style="display:none">
        USB 2.0 type A to Micro-B 5-pin. This is a new, smaller connector for USB devices. Micro-B connectors are about half the heig…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$5.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.3 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">15</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="10215">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">23</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="10215" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<div class="alert alert-info">
<b>Note:</b> This tutorial calls for two 100mm Qwiic Cables (which is why it's listed twice), but any Qwiic cable can be used instead of the 100mm version. Please be sure to have the correct amount in your cart before purchasing.</div>

<hr />  <a name="#software-setup"></a>
  <h2 id="software-setup">Software Setup</h2>
  <div class="alert alert-info">
<b>Note:</b> If this is your first time using Arduino, please review our tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">installing the Arduino IDE.</a> If you have not previously installed an Arduino library, please check out our <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library">installation guide.</a>
</div>

<p>SparkFun has written a library to work with the SparkFun Ultrasonic Distance Sensor Qwiic Board. You can obtain this library by clicking on the button below, or by downloading it from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_Ultrasonic_Arduino_Library/tree/v10">GitHub Repository</a>.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_Ultrasonic_Arduino_Library" class="btn btn-default">SparkFun Qwiic Ultrasonic Arduino Library GitHub</a> </div></p>

<p> </p>

<hr />  <a name="#read-measurements-with-a-serial-monitor"></a>
  <h2 id="read-measurements-with-a-serial-monitor">Read Measurements with a Serial Monitor</h2>
  <p>Now that we've installed the Arduino library, it's time to upload our first sketch to make sure everything is working properly and you are able to read basic measurements with your Serial Monitor in the Arduino IDE.</p>

<p>For this example you will need the <a href="https://www.sparkfun.com/products/24805">SparkFun Ultrasonic Distance Sensor - TCT40 (Qwiic)</a>, a <a href="https://www.sparkfun.com/products/15123">SparkFun RedBoard Qwiic</a>, a <a href="https://www.sparkfun.com/products/14427">Qwiic Cable</a>, and a <a href="https://www.sparkfun.com/products/10215">USB Micro-B Cable</a>.</p>

<p>Using the Qwiic system, assembling the hardware is simple. Connect the RedBoard to one of the Ultrasonic Distance Sensor Qwiic ports using your Qwiic cables (please remember to insert this cable in the correct orientation). Then connect the RedBoard to your computer via the MicroUSB cable and voila! You're ready to rock!</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/24805-Ultrasonic-Distance-Sensor-Action-2.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/7/5/24805-Ultrasonic-Distance-Sensor-Action-2.jpg" alt="Ultrasonic Distance Sensor Connected to Programming" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Ultrasonic Distance Sensor Connected to RedBoard</em> </div></p>

<p> </p>

<p>To find Example 1, go to <strong>File > Examples > SparkFun Qwiic Ultrasonic Arduino Library > Example1_BasicReadings</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/Example1_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/7/5/Example1_Menu.jpg" alt="Finding Example 1" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Finding Basic Readings Sketch</em> </div></p>

<p>Alternatively, you can copy and paste the code below into a shiny new Arduino sketch:</p>

<pre><code>/* SparkFun Ulrasonic Distance Sensor - Example 1 Basic Distance Sensing
     * 
     * Product: 
     *  *  SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04 (SEN-1XXXX)
     *  *  https://www.sparkfun.com/1XXXX
     * 
     * Written By: Elias Santistevan
     * Date: 06/2024
     *
     * SPDX-License-Identifier: MIT
     *
     * Copyright (c) 2024 SparkFun Electronics
     */

    #include "SparkFun_Qwiic_Ultrasonic_Arduino_Library.h"

    // Create an ultrasonic sensor object
    QwiicUltrasonic myUltrasonic;

    // Here we set the device address. Note that an older version of the Qwiic
    // Ultrasonic firmware used a default address of 0x00. If yours uses 0x00,
    // you'll need to change the address below. It is also recommended to run
    // Example 2 to change the address to the new default.
    uint8_t deviceAddress = kQwiicUltrasonicDefaultAddress; // 0x2F
    // uint8_t deviceAddress = 0x00;

    void setup()
    {
      // Start serial
      Serial.begin(115200);
      Serial.println("Ultrasonic Distance Sensor Example 1 - Basic Readings");

      Wire.begin();

      // Attempt to begin the sensor
      while (myUltrasonic.begin(deviceAddress) == false)
      {
        Serial.println("Ultrasonic sensor not connected, check your wiring and I2C address!");
        delay(2000);
      }

      Serial.println("Ultrasonic sensor connected!");
    }

    void loop()
    {
      uint16_t distance = 0;
      myUltrasonic.triggerAndRead(distance);

      // Print measurement
      Serial.print("Distance (mm): ");
      Serial.println(distance);

      //Serial.println("Distance (cm): "); 
      //Serial.print((distance / 10.0), 2);         

      //Serial.println("Distace (in): "); 
      //Serial.print((distance / 25.4), 2);         

      // Wait a bit
      delay(250);
    }
</code></pre>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, go ahead and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>. You should see something similar to the following.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/Example1_Output.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/7/5/Example1_Output.jpg" alt="Example 1 Output" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Example distance measurements in millimeters</em> </div></p>

<div class="alert alert-info">Note: The code for changing the measurements to <b>inches</b> or <b>centimeters</b> is provided near the bottom of the sketch. You'll simply need to add/remove commenting syntax to change your output.</div>

<p> </p>

<hr />  <a name="#display-measurements-on-an-oled"></a>
  <h2 id="display-measurements-on-an-oled">Display Measurements On an OLED</h2>
  <p>Let's add in an LCD screen to display our measurements. For this example you will need another <a href="https://www.sparkfun.com/products/14427">Qwiic Cable</a> and the <a href="https://www.sparkfun.com/products/24606">SparkFun Qwiic OLED Display (0.91 in., 128x32)</a>. Again, the Qwiic system makes this example quite literally plug and play. Use Qwiic cables to make your hardware setup look like this:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/24805-Ultrasonic-Distance-Sensor-Action-4.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/7/5/24805-Ultrasonic-Distance-Sensor-Action-4.jpg" alt="Example 2 Hardware Hookup" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Hardware Hookup with OLED</em> </div></p>

<p>To display the sensor readings on the connected Qwiic OLED, we will need to install the SparkFun Qwiic OLED library. You can install this library to automatically in the Arduino IDE's Library Manager by searching for "SparkFun Qwiic OLED". Or you can manually download it from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library">GitHub repository</a>.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">Download the SparkFun Qwiic OLED Library (ZIP)</a> </div></p>

<p> </p>

<p>To find Example 2, go to <strong>File > Examples > SparkFun Qwiic Ultrasonic Arduino Library > Example2_OLED_Distance</strong>:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/Example2_Menu.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/7/5/Example2_Menu.jpg" alt="Finding Example 2" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Locating Arduino Library Example</em> </div></p>

<p>Alternatively, you can copy and paste the code below into a shiny new Arduino sketch:</p>

<pre><code>/* SparkFun Ulrasonic Distance Sensor - Example 2 Basic Distance Sensing on an OLED Display
  * 
   * Products: 
   *  *  SparkFun Qwiic Ultrasonic Distance Sensor - HC-SR04 (SEN-1XXXX)
   *  *  https://www.sparkfun.com/1XXXX
   *  *  SparkFun Qwiic Narrow OLED Display (LCD-1XXXX)
   *  *  https://www.sparkfun.com/1XXXX
   *
   * Link to OLED library: https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library
   * 
   * Written By: Elias Santistevan
   * Date: 06/2024
   *
   * SPDX-License-Identifier: MIT
   *
   * Copyright (c) 2024 SparkFun Electronics
   */

  #include "SparkFun_Qwiic_OLED.h"
  // For the narrow LED, I prefer the slightly larger font included in the OLED library.
  // This is completely optional and can be deleted or commented out. By default the font
  // is slightly smaller. 
  #include "res/qw_fnt_8x16.h"
  #include "SparkFun_Qwiic_Ultrasonic_Arduino_Library.h"

  // Create an ultrasonic sensor object
  QwiicUltrasonic myUltrasonic;
  // Creat an OLED object
  QwiicNarrowOLED myOLED;

  char distanceBuff[4] = {}; 
  String distanceStr = "";
  int centerX; 
  int centerY; 

  // Here we set the device address. Note that an older version of the Qwiic
  // Ultrasonic firmware used a default address of 0x00. If yours uses 0x00,
  // you'll need to change the address below. It is also recommended to run
  // Example 2 to change the address to the new default.
  uint8_t deviceAddress = kQwiicUltrasonicDefaultAddress; // 0x2F
  // uint8_t deviceAddress = 0x00;

  void setup()
  {

    Serial.begin(115200); // Default config settings
    Serial.println("Ultrasonic Distance Sensor - Example 4 - Distance on an OLED Display");
    Wire.begin();

    while (myOLED.begin() == false) {
      Serial.println("OLED sensor not connected, check your wiring and I2C address!");
      delay(1000);
    }
    while(myUltrasonic.begin(deviceAddress) == false)
    {
      Serial.println("Ultrasonic sensor not connected, check your wiring and I2C address!");
      delay(1000);
    }

    String hello = "Hello, Ultrasonic!";

    // This is good for the narrow OLED screen. You can also just remove this 
    // and it will default to a slightly smaller font. 
    myOLED.setFont(QW_FONT_8X16);

    // This will center the text onto the screen. 
    int x0 = (myOLED.getWidth() - myOLED.getStringWidth(hello)) / 2;
    int y0 = (myOLED.getHeight() - myOLED.getStringHeight(hello)) / 2;

    myOLED.text(x0, y0, hello);

    // There's nothing on the screen yet - Now send the graphics to the device
    myOLED.display();
    delay(2000);
  }

  void loop() 
  {
    uint16_t distance = 0;
    myUltrasonic.triggerAndRead(distance);

    // Convert distance, which is an integer, to char so that we can print it.
    snprintf(distanceBuff, 6, "%d", distance);

    // Put the distance in a string so that we can also print "mm".
    distanceStr = distanceBuff; 
    distanceStr += "mm";

    myOLED.erase();
    centerX = (myOLED.getWidth() - myOLED.getStringWidth(distanceStr)) / 2;
    centerY = (myOLED.getHeight() - myOLED.getStringHeight(distanceStr)) / 2;
    myOLED.text(centerX, centerY, distanceStr);
    myOLED.display();

    delay(250);
  }
</code></pre>

<p>Make sure you've selected the correct board and port in the Tools menu and then hit the upload button. Once the code has finished uploading, you should see something similar to the following.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/SEN-24805-GIF.gif"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/7/5/SEN-24805-GIF.gif" alt="Run away!" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"> <em>Run away!</em> </div></p>

<p>Try moving an object (like your hand or a dinosaur) closer to the sensor - notice the output of the OLED shows you how close the object is! Grr. Rawr!</p>

<p> </p>

<hr />  <a name="#resources-and-going-further"></a>
  <h2 id="resources-and-going-further">Resources and Going Further</h2>
  <p>There are more examples in the Arduino Library that allow you to change the I2C address or use the Trigger and Echo Pins. Feel free to check them out!</p>

<p><H3>Suggested Reading</H3></p>

<p>If you aren’t familiar with the the preceding concepts, we recommend checking out these tutorials to gain a little background knowledge.</p>


<div class="tile-wrap">
  <div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-50">

  <a href="https://learn.sparkfun.com/tutorials/what-is-an-arduino">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/3/b/6/e/b/512e66bece395f492b000000.jpg)"></div>
      </div>
    
    
    <h3 class="title">What is an Arduino?</h3>
      </a>

      <div class="description">
      What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.
    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="50">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">56</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-61">

  <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/6/1/arduinoThumb.jpg)"></div>
      </div>
    
    
    <h3 class="title">Installing Arduino IDE</h3>
      </a>

      <div class="description">
      A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.     </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="61">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">17</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-62">

  <a href="https://learn.sparkfun.com/tutorials/logic-levels">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/6/2/Input_Output_Logic_Level_Tolerances_tutorial_tile.png)"></div>
      </div>
    
    
    <h3 class="title">Logic Levels</h3>
      </a>

      <div class="description">
      Learn the difference between 3.3V and 5V devices and logic levels.     </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="62">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">91</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-82">

  <a href="https://learn.sparkfun.com/tutorials/i2c">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/8/2/I2C-Block-Diagram.jpg)"></div>
      </div>
    
    
    <h3 class="title">I2C</h3>
      </a>

      <div class="description">
      An introduction to I2C, one of the main embedded communications protocols in use today.    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="82">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">139</span>
</span>  </div>

</div>
</div>

  <div class="clearfix"></div>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/display-distance-measurements-on-an-oled</link><guid isPermaLink="false">19d3ff8005a4e70027aaee026f9f0763</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Tue, 02 Jul 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/5/0/9/7/SEN-24805-Ultrasonic-Distance-Sensor-Feature_2.jpg"/></item><item><title><![CDATA[Fading with the MOSFET Power Switch and Buck Regulator]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/3/0/3/COM-23979-MOSFET-Power-Switch-Feature.jpg" style="width: 100%;" /><div><h1>
  Fading with the MOSFET Power Switch and Buck Regulator  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3342">http://sfe.io/t3342</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>This tutorial will guide you through using the SparkFun MOSFET Power Switch and Buck Regulator (Low-Side) with your Arduino projects. This handy board combines a MOSFET switch for controlling high-power loads (up to 12V) with a built-in buck regulator that conveniently provides stable 3.3V power for your Arduino.</p>

<p>We'll explore various functionalities, starting with basic on/off control and progressing to creating dimming effects for LEDs and controlling motors with variable speeds.  By the end, you'll be able to safely manage powerful components and add exciting features to your Arduino projects!</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-23979">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/23979">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/3/0/3/COM-23979-MOSFET-Power-Switch-Feature.jpg" alt="SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="23979">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_23979" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_23979 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_23979"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/23979">
          <span>SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      COM-23979    </span>

          <p class="description" style="display:none">
        The MOSFET Power Switch and Buck Regulator (Low-Side) can be powered with up to 12V and control up to 10A, all while providin…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$14.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">2</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="23979">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">9</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="23979" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<p>If you are looking for the full Hookup Guide for the SparkFun MOSFET Power Switch and Buck Regulator (Low-Side), click the button bellow. This guide only covers a simple project to get you started quickly, while the full Hookup Guide goes over every detail of the sensor.</p>

<p><div class="center-block text-center"> <a href="https://docs.sparkfun.com/SparkFun_MOSFET_Power_Switch_and_Buck_Regulator_Low-Side/" class="btn btn-default">View the Full Hookup Guide</a> </div></p>

<p> </p>

<div class="alert alert-warning">
<b>Tip:</b> The 3.3V output from the MOSFET Power Switch and Buck Regulator (Low-Side) provides another alternative to power microcontrollers that may not be able to accept higher voltages. For example, most of the Thing Plus Development Boards only accept a maximum of 6V at their VIN pin, and they most operate at 3.3V. So this board is especially handy in those use-cases. Additionally, even though the Arduino Pro Mini can accept up to 12V, this will require its onboard linear regulator to work very had to regulate that voltage down to 3.3V. Thus, this MOSFET Power Switch and Buck Regulator (Low-Side) would be the "cooler" choice.</div>

<div class="alert alert-info">
<b>Note:</b> The tutorial focuses on using a microcontroller with Arduino. However, if your microcontroller has a digital or PWM, you can also control the N-channel MOSFET controller as well! You can also use this using a micro:bit with MakeCode or Raspberry Pi's RP2040 microcontroller with MicroPython!</div>

<hr />  <a name="#hardware-needed"></a>
  <h2 id="hardware-needed">Hardware Needed</h2>
  <p>To follow this experiment, you will need the following materials. While this is a simple project we wanted to make sure that you have everything you need to get started before we get to the code. For this simple project we chose the <a href="https://www.sparkfun.com/products/19177">ESP32 IoT RedBoard Development Board</a>.</p>

<div class="row">
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-23979">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/23979">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/3/0/3/COM-23979-MOSFET-Power-Switch-Feature.jpg" alt="SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="23979">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_23979" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_23979 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_23979"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/23979">
          <span>SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      COM-23979    </span>

          <p class="description" style="display:none">
        The MOSFET Power Switch and Buck Regulator (Low-Side) can be powered with up to 12V and control up to 10A, all while providin…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$14.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">2</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="23979">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">9</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="23979" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-19177">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/19177">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/8/8/0/0/ESP32_03.jpg" alt="SparkFun IoT RedBoard - ESP32 Development Board" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="19177">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_19177" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_19177 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_19177"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/19177">
          <span>SparkFun IoT RedBoard - ESP32 Development Board</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      WRL-19177    </span>

          <p class="description" style="display:none">
        The IoT RedBoard is an ESP32 WROOM-equipped development board that has everything you need in an Arduino Uno with extra perks…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$29.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="3.1 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-empty" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">8</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="19177">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">27</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="19177" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-12021">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/12021">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/8/5/4/9/12021-01.jpg" alt="LED RGB Strip - Bare (1m)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="12021">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_12021" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_12021 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_12021"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/12021">
          <span>LED RGB Strip - Bare (1m)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      COM-12021    </span>

          <p class="description" style="display:none">
        These are bare non-addressable 1 meter long RGB LED strips that come packed with 60 5060 LEDs per meter. As these are bare LE…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$10.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="3 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-empty" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">1</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="12021">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">10</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="12021" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-15313">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/15313">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/3/8/1/6/TOL-15313-1.jpg" alt="Wall Adapter Power Supply - 12VDC, 600mA (Barrel Jack)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="15313">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_15313" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_15313 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_15313"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/15313">
          <span>Wall Adapter Power Supply - 12VDC, 600mA (Barrel Jack)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      TOL-15313    </span>

          <p class="description" style="display:none">
        This is a high quality AC to DC 'wall wart' which produces a regulated output of 12VDC at up to 600mA.      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$6.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="15313">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">10</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="15313" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<div class="row">
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-10287">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/10287">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/4/6/8/3/10287-01.jpg" alt="DC Barrel Jack Adapter - Male" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="confirm_backorder" method="post">
          <input type=hidden name=id value="10287">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_10287" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-default" value="Backorder">
                  </form>
      </div>
      <div class="added_to_cart_10287 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_10287"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/10287">
          <span>DC Barrel Jack Adapter - Male</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="out of stock"><span class=sfe-icon-stock-out><span class=visuallyhidden>Out of stock</span></span></a>
    </span>

    <span class="sku">
      PRT-10287    </span>

          <p class="description" style="display:none">
        This adapter allows you to connect a barrel jack connector to bare wires. One end has screw terminals and the other has a 5.5…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$3.50</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="10287">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">19</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="10287" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-10288">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/10288">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/4/6/8/4/10288-02.jpg" alt="DC Barrel Jack Adapter - Female" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="10288">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_10288" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_10288 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_10288"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/10288">
          <span>DC Barrel Jack Adapter - Female</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-10288    </span>

          <p class="description" style="display:none">
        This adapter allows you to connect a barrel jack connector to bare wires. One end has screw terminals and the other has a 5.5…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$3.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="5 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-full" data-star-index="4"></span>
  </span>
      <span class="count">1</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="10288">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">25</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="10288" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-9088">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/9088">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/6/2/09088-02-L.jpg" alt="Mini Photocell" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="9088">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_9088" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_9088 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_9088"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/9088">
          <span>Mini Photocell</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      SEN-09088    </span>

          <p class="description" style="display:none">
        This is a very small light sensor. A photocell changes (also called a [photodetector](http://en.wikipedia.org/wiki/Photodetec…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.60</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.9 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-full" data-star-index="4"></span>
  </span>
      <span class="count">7</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="9088">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">76</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="9088" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-9806">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/9806">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/3/8/2/3/09806-01.jpg" alt="Trimpot 10K Ohm with Knob" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="9806">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_9806" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_9806 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_9806"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/9806">
          <span>Trimpot 10K Ohm with Knob</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      COM-09806    </span>

          <p class="description" style="display:none">
        This 10K trimmable potentiometer has a small knob built right in and it's breadboard friendly to boot!      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.05</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.8 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-full" data-star-index="4"></span>
  </span>
      <span class="count">6</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="9806">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">56</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="9806" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<div class="row">
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-12002">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/12002">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/8/5/0/3/12002-Breadboard_-_Self-Adhesive__White_-01.jpg" alt="Breadboard - Self-Adhesive (White)" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="12002">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_12002" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_12002 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_12002"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/12002">
          <span>Breadboard - Self-Adhesive (White)</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-12002    </span>

          <p class="description" style="display:none">
        This is your tried and true white solderless breadboard. It has 2 power buses, 10 columns, and 30 rows - a total of 400 tie i…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$5.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.3 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">48</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="12002">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">104</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="12002" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-15425">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/15425">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/3/9/8/4/15425-Reversible_USB_A_to_C_Cable_-_0.8m-01.jpg" alt="Reversible USB A to C Cable - 0.8m" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="15425">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_15425" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_15425 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_15425"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/15425">
          <span>Reversible USB A to C Cable - 0.8m</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      CAB-15425    </span>

          <p class="description" style="display:none">
        These 0.8m cables have minor modifications that allow them to be plugged into their ports regardless of orientation on the US…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$5.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-empty" data-star-index="4"></span>
  </span>
      <span class="count">2</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="15425">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">6</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="15425" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-8431">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/8431">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/1/8/1/JumperWire-Male-01-L.jpg" alt="Jumper Wires Premium 6" M/M Pack of 10" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="8431">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_8431" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_8431 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_8431"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/8431">
          <span>Jumper Wires Premium 6" M/M Pack of 10</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-08431    </span>

          <p class="description" style="display:none">
        This is a SparkFun exclusive! These are 155mm long, 26 AWG jumpers with male connectors on both ends. Use these to jumper fro…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$4.50</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="5 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-full" data-star-index="4"></span>
  </span>
      <span class="count">2</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="8431">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">12</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="8431" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
    <div class="col-md-3">

<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-14491">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/14491">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/1/2/2/1/6/14491-03.jpg" alt="Resistor 10K Ohm 1/4 Watt PTH - 20 pack (Thick Leads) " height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="14491">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_14491" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_14491 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_14491"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/14491">
          <span>Resistor 10K Ohm 1/4 Watt PTH - 20 pack (Thick Leads) </span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="in stock"><span class=sfe-icon-stock-in><span class=visuallyhidden>In stock</span></span></a>
    </span>

    <span class="sku">
      PRT-14491    </span>

          <p class="description" style="display:none">
        These are your run-of-the-mill 1/4 Watt, +/- 5% tolerance PTH resistors. Commonly used in breadboards and other prototyping a…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$1.25</span>
        </span>
      </div>
    </div>
  
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="14491">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">13</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="14491" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>


</div>
</div>

<hr />  <a name="#software-setup"></a>
  <h2 id="software-setup">Software Setup</h2>
  <div class="alert alert-info">
<b>Note:</b> If this is your first time using Arduino, please review our tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">installing the Arduino IDE.</a> If you have not previously installed an Arduino library, please check out our <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library">installation guide.</a>
</div>

<p>SparkFun has written a library to work with the SparkFun MOSFET Power Switch and Buck Regulator. You can obtain this library by clicking on the button below, or by downloading it from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_Ultrasonic_Arduino_Library/tree/v10">GitHub Repository</a>.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_MOSFET_Power_Switch_and_Buck_Regulator_Low-Side/tree/main/Firmware/Arduino" class="btn btn-default">SparkFun MOSFET Power Switch and Buck Regulator Library GitHub</a> </div></p>

<p> </p>

<hr />  <a name="#fading"></a>
  <h2 id="fading">Fading</h2>
  <p>In this example, we will slowly turn on the load and then slowly turn it off using the N-channel MOSFET. This example is better with a DC motor and 12V LED. You will typically want the solenoid to be fully turned on/off.</p>

<p>For this example you will need the <a href="https://www.sparkfun.com/products/19177">SparkFun IoT RedBoard - ESP32 Development Board</a>, a <a href="https://www.sparkfun.com/products/15092">USB-C Cable</a>, the <a href="https://www.sparkfun.com/products/23979">SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)</a>, a <a href="https://www.sparkfun.com/products/9146">Mini Screwdriver</a>, <a href="https://www.sparkfun.com/products/8431">M/M Jumper Wires</a>, an <a href="https://www.sparkfun.com/products/12021">RGB LED Strip</a>, and a [12V Wall Adapter Power Supply](12V Wall Adapter Power Supply).</p>

<h3>Hardware Hookup</h3>

<p>You will need to connect everything as explained earlier. For this particular example, we will use one channel from a 12V RGB LED strip as shown in the circuit diagram below.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/SparkFun_Power_Control_Switch_N-Channel_MOSFET_Buck_Regulator_RedBoard_Arduino_IoT_ESP32_Fade_Red_12V_LED_Strip_bb.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/4/2/SparkFun_Power_Control_Switch_N-Channel_MOSFET_Buck_Regulator_RedBoard_Arduino_IoT_ESP32_Fade_Red_12V_LED_Strip_bb.jpg" alt="Fritzing Diagram for Hardware Hookup" style="max-width: 100%;" /></a> </div></p>

<div class="alert alert-info">
<b>Note:</b> Notice that we are using pin 16 to fade the red channel instead of pin 25 on the IoT RedBoard - ESP32.</div>

<p> </p>

<p>Your setup should look similar to the image below without the power supply.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/23979-MOSFET_Power_Switch_ESP32_LED_Strip_Red_Fading.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/4/2/23979-MOSFET_Power_Switch_ESP32_LED_Strip_Red_Fading.jpg" alt="Your setup should look similar to this." style="max-width: 100%;" /></a> </div></p>

<h3>Upload Code</h3>

<p>To upload code, insert the USB cable into the IoT RedBoard - ESP32.</p>

<div class="alert alert-info">
<b>Note:</b> This example is similar to the built-in Arduino example. From the menu, select the following: <b>File > Examples > 03.Analog > Fading</b>. You will need to modify the defined pin with a PWM pin for your microcontroller. Note that the logic is reversed due to the transistor.</div>

<p>Copy the following code and paste it in the Arduino IDE. If you have not already, select your Board (in this case, the <strong>SparkFun ESP32 IoT RedBoard</strong>), and associated COM port. Then hit the upload button.</p>

<pre><code>/******************************************************************************
  Example: Fading
  Modified By: Ho Yun "Bobby" Chan
  SparkFun Electronics
  Date: October 27th, 2023
  License: MIT. See license file for more information but you can
  basically do whatever you want with this code.

  This example is based on Arduino's fade example. It has been modified
  so that it can be used for the SparkFun IoT RedBoard- ESP32 but it can be
  used with any Arduino that has a PWM pin. The load (DC motor,
  or 12V LED) will slowly turn on and off. This code will be more useful for
  users connecting a DC motor or nonaddressable LED so that you can partially
  turn on/off the load.

  Users can also open the Serial Monitor at 115200 to check on
  the status of the button for debugging.

  Feel like supporting open source hardware?
  Buy a board or component from SparkFun!

      SparkFun MOSFET Power Switch and Buck Regulator (Low-Side): https://www.sparkfun.com/products/23979
      SparkFun IoT RedBoard - ESP32 Development Board: https://www.sparkfun.com/products/19177
      Hobby Motor - Gear: https://www.sparkfun.com/products/11696
      Blower - Squirrel Cage (12V): https://www.sparkfun.com/products/11270
      12V LED RGB Strip - Bare (1m): https://www.sparkfun.com/products/12021
      Wall Adapter 12V/600mA, (Barrel Jack): https://www.sparkfun.com/products/15313

  Distributed as-is; no warranty is given.
******************************************************************************/

int loadPin = 16;

// the setup function runs once when you press reset or power the board
void setup() {

//Initialize Serial for Debugging if there is no built-in LED
Serial.begin(115200);
Serial.println("Analog fade in and out to slowly turn on/off load!");

// Set up the load pin to be an output and turn it off:
pinMode(loadPin, OUTPUT);
analogWrite(loadPin, 255);

Serial.println("OFF");

}  //END SETUP

// the loop function runs over and over again forever
void loop() {

Serial.println("<===== FADE IN =====>");
// fade in from min to max in increments of 5 points:
for (int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(loadPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);

Serial.println(fadeValue);
}

Serial.println("<===== FADE OUT =====>");
// fade out from max to min in increments of 5 points:
for (int fadeValue = 0; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(loadPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);

Serial.println(fadeValue);
}

}  //END LOOP
</code></pre>

<h3>What You Should See</h3>

<p>Once the code has uploaded, disconnect the USB cable from the IoT RedBoard - ESP32. Then insert the barrel jack from a power supply to the MOSFET Power Switch and Buck Regulator's barrel jack connector. In this case, we used a 12V wall adapter power supply.</p>

<p>The load will slowly turn on and slowly turn off. This will loop forever until power is removed from the board. If necessary, disconnect the 3.3V jumper wire from the IoT RedBoard - ESP32, reconnect the USB cable, and open the <a href="https://learn.sparkfun.com/tutorials/terminal-basics/arduino-serial-monitor-windows-mac-linux">Arduino Serial Monitor</a> at 115200 baud for debugging purposes.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/23979-MOSFET_Power_Switch_ESP32_LED_Strip_Red_Fading.gif"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/23979-MOSFET_Power_Switch_ESP32_LED_Strip_Red_Fading.gif" alt="LED Fading with your MOSFET" style="max-width: 100%;" /></a> </div></p>

<p>While this example was used to turn on one channel of a 12V RGB LED strip, you could also use this example with a DC motor. Try using a potentiometer (or any 3.3V analog sensor) with the <a href="https://www.arduino.cc/reference/en/language/functions/math/map/">map() function</a> to adjust the speed of the motor.</p>

<p> </p>

<hr />  <a name="#12v-rgb-led-strip"></a>
  <h2 id="12v-rgb-led-strip">12V RGB LED Strip</h2>
  <p>In this example, we will control all three channels of the RGB LED strip. Since we've already <a href="https://learn.sparkfun.com/tutorials/non-addressable-rgb-led-strip-hookup-guide">hooked up a 12V RGB LED strip before</a>, we will also a circuit with a potentiometer to cycle between each color and a photoresistor to turn on the LEDs whenever the light is below a certain light level. The following example code is based on the <a href="https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-experiment-guide---v41/circuit-1d-rgb-night-light">SparkFun Inventor's Kit v4.1 Night Light example</a>.</p>

<p><div class="center-block text-center"> 
<div class="tile-wrap">
  <div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-731">

  <a href="https://learn.sparkfun.com/tutorials/non-addressable-rgb-led-strip-hookup-guide">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com//assets/learn_tutorials/7/3/1/Non-Addressable_RGB_LED_Strip_Custom_Color_Cycling.gif)"></div>
      </div>
    
    
    <h3 class="title">Non-Addressable RGB LED Strip Hookup Guide</h3>
      </a>

      <div class="description">
      Add color to your projects with non-addressable LED strips! These are perfect if you want to control and power the entire strip with one color for your props, car, fish tank, room, wall, or perhaps under cabinet lighting in your home.    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="731">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">2</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-891">

  <a href="https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-experiment-guide---v41">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/8/9/1/SIK_Updates-Project_5-Overview.jpg)"></div>
      </div>
    
    
    <h3 class="title">SparkFun Inventor's Kit Experiment Guide - v4.1</h3>
      </a>

      <div class="description">
      The SparkFun Inventor's Kit (SIK) Experiment Guide contains all of the information needed to build all five projects, encompassing 16 circuits, in the latest version of the kit, v4.1.2 and v4.1.    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="891">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">10</span>
</span>  </div>

</div>
</div>

  <div class="clearfix"></div>
 </div></p>

<p> </p>

<h3>Parts Needed</h3>

<p>Grab the following quantities of each part listed to build this circuit:</p>

<ul>
<li>1x <a href="https://www.sparkfun.com/products/19177">SparkFun IoT RedBoard - ESP32 Development Board</a></li>
<li>1x <a href="https://www.sparkfun.com/products/15092">USB-C Cable</a></li>
<li>3x <a href="https://www.sparkfun.com/products/23979">SparkFun MOSFET Power Switch and Buck Regulator (Low-Side)</a></li>
<li>1x <a href="https://www.sparkfun.com/products/9146">SparkFun Mini Screwdriver</a></li>
<li>19x <a href="https://www.sparkfun.com/products/11026">M/M Jumper Wires</a>*</li>
<li>1x <a href="https://www.sparkfun.com/products/12002">Breadboard</a></li>
<li>1x <a href="https://www.sparkfun.com/products/9806">10kΩ Potentiometer with Knob</a></li>
<li>1x <a href="https://www.sparkfun.com/products/9088">Mini Photocell</a></li>
<li>1x <a href="https://www.sparkfun.com/products/14491">10kΩ Resistor</a></li>
<li>1x <a href="https://www.sparkfun.com/products/12021">12V RGB LED Strip</a></li>
<li>1x <a href="https://www.sparkfun.com/products/10287">DC Barrel Jack Adapter - Male</a></li>
<li>3x <a href="https://www.sparkfun.com/products/10288">DC Barrel Jack Adapter - Female</a></li>
<li>1x <a href="https://www.sparkfun.com/products/15313">12V Wall Adapter</a></li>
</ul>

<div class="alert alert-info">
*<b>Note:</b> You will need a minimum of 19x M/M jumper wires. Six jumper wires were stripped wires that connect the barrel jacks together for power and reference ground.</div>

<p> </p>

<h3>Hardware Hookup</h3>

<p>For this particular example, we will use three channels from a 12V RGB LED strip while also including a similar circuit from the SparkFun Inventor's Kit v4.1. The circuit diagram is shown below.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/3/4/2/SparkFun_Power_Control_Switch_N-Channel_MOSFET_Buck_Regulator_RedBoard_Arduino_IoT_ESP32_Nightlight_RGB_12V_LED_Strip_bb.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/3/4/2/SparkFun_Power_Control_Switch_N-Channel_MOSFET_Buck_Regulator_RedBoard_Arduino_IoT_ESP32_Nightlight_RGB_12V_LED_Strip_bb.jpg" alt="Three MOSFET Board Fritzing Hookup" style="max-width: 100%;" /></a> </div></p>

<div class="alert alert-info">
<b>Note:</b> When testing the non-addressable LED strip, the pin labeled "G" was actually blue and the "B" was actually green. Depending on the manufacturer, the label may vary. Try testing the LED strip out with a power supply to determine if the letter represents the color.</div>

<p>Keep in mind that instead of the RedBoard with ATmega328P, we are using the IoT RedBoard with ESP32. Since the hardware is different, the following code was modified:</p>

<pre><code>- analog and PWM pins were redefined in the example code
- threshold was modified due to the ADC's higher reso...</div></div>]]></description><link>https://learn.sparkfun.com/tutorials/fading-with-the-mosfet-power-switch-and-buck-regulator</link><guid isPermaLink="false">debdf5c63c59b64f6f2418bba16d217e</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Mon, 01 Jul 2024 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/4/3/0/3/COM-23979-MOSFET-Power-Switch-Feature.jpg"/></item><item><title><![CDATA[SparkFun Arduino UNO R4 WiFi Qwiic Kit Hookup Guide]]></title><description><![CDATA[<div><img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/8/0/4/22641-_KIT_-1.jpg" style="width: 100%;" /><div><h1>
  SparkFun Arduino UNO R4 WiFi Qwiic Kit Hookup Guide  <small>a <a href="https://learn.sparkfun.com/tutorials">learn.sparkfun.com tutorial</a></small>
</h1>

<h3>
  Available online at: <a href="http://sfe.io/t3243">http://sfe.io/t3243</a>
</h3>


  <a name="#introduction"></a>
  <h2 id="introduction">Introduction</h2>
  <p>The <a href="https://www.sparkfun.com/products/22641">SparkFun Arduino UNO R4 WiFi Qwiic Kit</a> is a great way to get started with Arduino and the Qwiic-connect system. This kit includes everything you need to build a WiFi-enabled project, including an Arduino UNO R4 board, an assortment of Qwiic-enabled sensors and input boards, a Qwiic OLED Display, and a variety of other components to get you connected. Hooking up a handful of inputs and outputs to a Arduino UNO R4 has never been so easy.</p>

<p>The UNO universe expands with the Arduino UNO R4 WiFi: the same industry-standard form factor at 5V operating voltage, but with the enhanced performance of a RA4M1 32-bit microcontroller by Renesas with ESP32-S3-MINI coprocessor – for increased computational power, memory and speed – as well as WiFi® and Bluetooth® connectivity, a 12 x 8 LED matrix, and a Qwiic connector.</p>

<p>The SparkFun Arduino UNO R4 WiFi Qwiic Kit is a great way to learn about Arduino, WiFi, and electronics. With this kit, you can build your own WiFi-enabled projects and start connecting your devices to the Internet of Things.</p>



<div >
<div class="tile product-tile has_addl_actions big grid " data-id="product-22641">
  <div class="actions-wrap">

          <a class="thumb" href="https://www.sparkfun.com/products/22641">
        <img src="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/8/0/4/22641-_KIT_-1.jpg" alt="SparkFun Arduino UNO R4 WiFi Qwiic Kit" height="500" style="max-width: 100%;">
      </a>
    
          <div class="actions" style="display:none">
        <form class="form-inline" action="https://www.sparkfun.com/cart/add" data-cart-action="add" method="post">
          <input type=hidden name=id value="22641">
          <input type=hidden name=qty value="1">
          <input type='hidden' name='csrf_token' value='$2y$04$AgY2vvm7JUOZCghECt0iT.0P3ZX5ZNYoU/rpsB5/JdNPHc9c/pKFu'>          <!-- Add to Cart -->
          <div class="quantity-container">
            <input aria-label="Quantity" type=text name=qty id="add_qty_22641" class="add_qty quantity form-control" data-spin-buttons='{"min": 1, "max": 10000}' value=1>
          </div>
                      <input type="submit" class="btn btn-cart btn-action" value="Add to Cart">
                  </form>
      </div>
      <div class="added_to_cart_22641 hide added_to_cart" style="display: none;">
        <p class="success-message">
          added <strong class="added_qty_22641"></strong> to your <a href="https://www.sparkfun.com/cart">cart</a>!
        </p>
      </div>
    
  </div><!--/.actions-wrap-->

  <div class="main">

    
    <h3 class="title">
              <a href="https://www.sparkfun.com/products/22641">
          <span>SparkFun Arduino UNO R4 WiFi Qwiic Kit</span>
        </a>
          </h3>

    <span class="bubbles" style="display:none">
      
  <a data-toggle="notify" href="https://www.sparkfun.com/static/bubbles/" title="only 6 left!"><span class=sfe-icon-stock-low><span class=visuallyhidden>Only 6 left!</span></span></a>
    </span>

    <span class="sku">
      KIT-22641    </span>

          <p class="description" style="display:none">
        The SparkFun Arduino UNO R4 WiFi Qwiic Kit has everything you need to start using the UNO R4 WiFi and Qwiic ecosystem togethe…      </p>
    
  </div>

      <div>
      <div class="prices">
                <span class="price-sale">
          <span class="price">$99.95</span>
        </span>
      </div>
    </div>
  
          <span class="star_rating">
      
<span class=product-rating title="4.5 stars">
          <span class="sfe-icon-star-full" data-star-index="0"></span>
          <span class="sfe-icon-star-full" data-star-index="1"></span>
          <span class="sfe-icon-star-full" data-star-index="2"></span>
          <span class="sfe-icon-star-full" data-star-index="3"></span>
          <span class="sfe-icon-star-half" data-star-index="4"></span>
  </span>
      <span class="count">2</span>
    </span>
  
  
      <div class="addl_actions">
      <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="products" data-entity-id="22641">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">10</span>
</span>      <div class="dropdown wishlist-dropdown simple ">
  <a class="btn btn-default btn-sm  dropdown-toggle" title="Add to wish list" data-toggle="dropdown"  data-product-id="22641" data-source="add_product_tile" href="#">
    <span class="glyphicon glyphicon-list"></span>
    <span class="name">Wish List</span>
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
</div>
    </div>
  
</div>
</div>




<h3>Parts List</h3>

<p>To follow this experiment, you will need the following materials. If you did not order the kit, you may need some of the items here. You may not need everything though, depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.</p>

<script src="https://www.sparkfun.com/wish_lists/171835.js"></script>

<h3>Suggested Reading</h3>

<p>If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.</p>

<table class="table table-bordered">
  <tr align="center">
   <td><center><a href="https://www.sparkfun.com/qwiic"><img src="https://cdn.sparkfun.com/assets/custom_pages/2/7/2/qwiic-logo.png" alt="Qwiic Connect System" title="Qwiic Connect System" style="max-width: 100%;"></a></center></td>
  </tr>
  <tr align="center">
    <td><i><a href="https://www.sparkfun.com/qwiic">Qwiic Connect System</a></i></td>
  </tr>
</table>


<div class="tile-wrap">
  <div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-50">

  <a href="https://learn.sparkfun.com/tutorials/what-is-an-arduino">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/3/b/6/e/b/512e66bece395f492b000000.jpg)"></div>
      </div>
    
    
    <h3 class="title">What is an Arduino?</h3>
      </a>

      <div class="description">
      What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.
    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="50">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">56</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-61">

  <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/6/1/arduinoThumb.jpg)"></div>
      </div>
    
    
    <h3 class="title">Installing Arduino IDE</h3>
      </a>

      <div class="description">
      A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.     </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="61">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">17</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-62">

  <a href="https://learn.sparkfun.com/tutorials/logic-levels">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/6/2/Input_Output_Logic_Level_Tolerances_tutorial_tile.png)"></div>
      </div>
    
    
    <h3 class="title">Logic Levels</h3>
      </a>

      <div class="description">
      Learn the difference between 3.3V and 5V devices and logic levels.     </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="62">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">91</span>
</span>  </div>

</div>
<div class="tile tutorial-tile has_addl_actions  grid " data-id="tutorial-82">

  <a href="https://learn.sparkfun.com/tutorials/i2c">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/264-148/assets/learn_tutorials/8/2/I2C-Block-Diagram.jpg)"></div>
      </div>
    
    
    <h3 class="title">I2C</h3>
      </a>

      <div class="description">
      An introduction to I2C, one of the main embedded communications protocols in use today.    </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="82">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">139</span>
</span>  </div>

</div>
</div>

  <div class="clearfix"></div>  <a name="#the-arduino-uno-r4-wifi-board"></a>
  <h2 id="the-arduino-uno-r4-wifi-board">The Arduino Uno R4 Wifi Board</h2>
  <p>This board is jam packed with functionality. We'll cover some of the basics here, but to read about the full shebang, refer to the <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/ABX00087-datasheet.pdf">Product Reference Manual</a>.</p>

<h3>Microcontroller</h3>

<p>The Arduino UNO R4 board is equipped with a powerful RA4M1 series 32-bit microcontroller from Renesas, which offers increased processing power, memory, and on-board peripherals. Importantly, these enhancements do not compromise compatibility with existing shields and accessories, nor do they require any changes to the standard form factor or 5V operating voltage.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-CPU.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-CPU.jpg" alt="The Renesas microcontroller is highlighted" style="max-width: 100%;" /></a> </div></p>

<h3>ESP32-S3-MINI CoProcessor</h3>

<p>The UNO R4 WiFi features an ESP32-S3-MINI coprocessor that enhances the capabilities of the RA4M1 microcontroller. With WiFi and Bluetooth connectivity, this board allows makers to easily connect to the internet and create IoT projects.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-Espressif.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-Espressif.jpg" alt="The ESP32 CoProcessor is highlighted here" style="max-width: 100%;" /></a> </div></p>

<h3>Power</h3>

<p>You can provide power via the USB-C connector or the Barrel Jack. A USB-C cable is included in the kit, the <a href="https://www.sparkfun.com/products/15312">Barrel Jack</a> can be purchased separately. The RA4M1's operating voltage is fixed at <strong>5 V</strong>, whereas the ESP32-S3 module is <strong>3.3 V</strong>. Communication between these two MCUs are performed via a logic level translator (TXB0108DQSR).</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-Power.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-Power.jpg" alt="Both the barrel jack and the USBC are highlighted" style="max-width: 100%;" /></a> </div></p>

<h3>LED Matrix</h3>

<p>The UNO R4 WiFi includes a bright 12x8 red LED matrix (96 dots total). This feature is ideal for creative projects using animations or for plotting sensor data, without the need for any additional hardware.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-LEDMatrix.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-LEDMatrix.jpg" alt="The LED Matrix is highlighted" style="max-width: 100%;" /></a> </div></p>

<h3>Qwiic Connector</h3>

<p>The UNO R4 WiFi includes an industry-standard Qwiic I<sup>2</sup>C connector that facilitates quick prototyping. With a wide variety of compatible modules that can be connected over I<sup>2</sup>C, makers can easily create custom projects and expand the capabilities of the UNO R4 WiFi.</p>

<div class="alert alert-warning" role="alert">
  <span class="glyphicon glyphicon-warning-sign"></span> <b>Warning:</b> The Qwiic connector on this board is connected to a secondary I<sup>2</sup>C bus on this board, IIC0. This connector is <b>3.3V</b> only, connecting higher voltages may damage your board. To initialize this bus, use Wire1.begin(). 
</div>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-QwiicConnector.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-QwiicConnector.jpg" alt="The Qwiic connector is highlighted" style="max-width: 100%;" /></a> </div></p>

<h3>GPIO</h3>

<p>The board features 14 digital I/O ports, 6 analog channels, dedicated pins for I<sup>2</sup>C, SPI and UART connections. The pins on either side of the board are highlighted here.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-GPIO.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-GPIO.jpg" alt="The GPIO pins are highlighted on either swide of the board" style="max-width: 100%;" /></a> </div></p>

<p>Their functionality is shown below; for more details, refer to the <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/ABX00087-datasheet.pdf">Product Reference Manual</a>.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/ABX00087-pinout.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/ABX00087-pinout.png" alt="Pinout definitions" style="max-width: 100%;" /></a> </div></p>

<p><div class="center-block text-center"><em>Image courtesy of Arduino</em></div>
<div class="center-block text-center"><em>Click the image for a closer view</em></div></p>  <a name="#installing-arduino"></a>
  <h2 id="installing-arduino">Installing Arduino</h2>
  <p>The following steps are a basic overview of getting started with the Arduino IDE. For more detailed, step-by-step instructions for setting up the Arduino IDE on your computer, please check out the following tutorial.</p>


<div class="tile-wrap">
  <div class="tile tutorial-tile has_addl_actions big grid " data-id="tutorial-61">

  <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">
          <div class="thumb-wrap">
        <div class="thumb" style="background-image:url(https://cdn.sparkfun.com/c/500-282/assets/learn_tutorials/6/1/arduinoThumb.jpg)"></div>
      </div>
    
    
    <h3 class="title">Installing Arduino IDE</h3>
    <h4 class="metaline">March 26, 2013</h4>  </a>

      <div class="description">
      A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.     </div>
  
  
  <div class="addl_actions">
    <span class="fave_widget simple">
  <a href="#" class="fave_btn " title="Add to favorites" data-entity="learn_tutorials" data-entity-id="61">
    <span class="fave_yes">
      <span class="glyphicon glyphicon-heart"></span>
      <span class="name">Favorited</span>
    </span>
    <span class="fave_no">
      <span class="glyphicon glyphicon-heart-empty"></span>
      <span class="name">Favorite</span>
    </span>
  </a>
  <span class="fave_count">17</span>
</span>  </div>

</div>
</div>

  <div class="clearfix"></div>


<h3>Download the Arduino IDE</h3>

<p>In order to get your microcontroller up and running, you'll need to download the newest version of the Arduino software first (it's free and open source!).</p>

<p><div class="center-block text-center"> <a href="https://www.arduino.cc/en/Main/Software" class="btn btn-default">Download the Arduino IDE</a> </div></p>

<p>This software, known as the Arduino IDE, will allow you to program the board to do exactly what you want. It’s like a word processor for writing code.</p>  <a name="#connecting-the-arduino-uno-r4-wifi"></a>
  <h2 id="connecting-the-arduino-uno-r4-wifi">Connecting the Arduino UNO R4 WiFi</h2>
  <p>Use the USB cable provided in the kit to connect the Arduino UNO R4 to one of your computer’s USB inputs.</p>

<h3>Install the Arduino Uno R4 Board Definition</h3>

<p>If you haven't already done so, make sure you have the Board Definitions installed for the Arduino Uno R4 boards. Go up to the <strong>Tools</strong> menu, hover over <strong>Board</strong>, and select <strong>Boards Manager</strong>.  Type in Arduino R4, and you should see the following. Click <strong>Install</strong> to install the board defs.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/InstallBoardDefFile.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/InstallBoardDefFile.png" alt="Arduino Uno R4 Board Def File" style="max-width: 100%;" /></a> </div></p>

<h3>Select Your Board: Arduino Uno R4</h3>

<p>Before we can start jumping into the experiments, there are a couple adjustments we need to make. This step is required to tell the Arduino IDE <em>which</em> of the <a href="https://learn.sparkfun.com/tutorials/choosing-an-arduino-for-your-project">many Arduino boards</a> we have. Go up to the <strong>Tools</strong> menu. Then hover over <strong>Board</strong> and subsequently the <strong>Arduino UNO R4 Boards</strong> menus, and make sure <strong>Arduino Uno R4 WiFi</strong> is selected.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/SelectingR4WiFiBoard.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/SelectingR4WiFiBoard.png" alt="Arduino IDE Board Selection" style="max-width: 100%;" /></a> </div></p>

<h3>Select a Serial Port</h3>

<p>Next up we need to tell the Arduino IDE which of our computer's serial ports the microcontroller is connected to. For this, again go up to <strong>Tools</strong>, then hover over <strong>Port</strong> and select your Arduino Uno R4 WiFi's serial port.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/R4WiFiPortSelection.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/R4WiFiPortSelection.png" alt="COM Port Selection" style="max-width: 100%;" /></a> </div></p>  <a name="#software"></a>
  <h2 id="software">Software</h2>
  <div class="alert alert-info">
<b>Note:</b> If this is your first time using Arduino, please review our tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-arduino-ide">installing the Arduino IDE.</a> If you have not previously installed an Arduino library, please check out our <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library">installation guide.</a>
</div>

<p>We have compiled a set of examples to show how the basics work on this board. You can download the examples here:</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Arduino_UNO_R4_Qwiic_Kit/archive/refs/heads/main.zip" class="btn btn-default">SparkFun Arduino UNO R4 Qwiic Examples Library (ZIP)</a> </div></p>

<p>These are just the ino files. Each of the examples requires a separate library to be installed. Each example in this guide will walk you through installing the required library. Let's get hacking!</p>  <a name="#example-1-qwiic-led-button"></a>
  <h2 id="example-1-qwiic-led-button">Example 1: Qwiic LED Button</h2>
  <p>This first example shows how the Qwiic LED Button can be hooked up and programmed to pulse while pressed.</p>

<h3>Library Installation</h3>

<p>In order for this example to work, you'll need to also install the library for the SparkFun Qwiic Button. The easiest way to install this library is to search for <b>SparkFun Qwiic Button</b> in the Arduino Library Manager tool. You can also manually install the Qwiic Button Library from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_Button_Arduino_Library">GitHub Repository</a> or you can download it by clicking the button below.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_Button_Arduino_Library/archive/master.zip" class="btn btn-default">Download the SparkFun Qwiic Button Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-LEDButton.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-LEDButton.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example - Pulse When Pressed</h3>

<p>The following example is taken from Example 3 of the SparkFun Qwiic Button library and is titled "Pulse When Pressed". The code connects the Qwiic Button to the I<sup>2</sup>C bus and runs the Button LED through a configured sequence when the button is pressed. The code configures the LED settings for brightness, cycleTime and offTime to pulse the Button LED while it is pressed. Try playing around with these settings to change the behavior of the LED.</p>

<pre><code>language:c
/******************************************************************************
  Checks whether the button is pressed, and light it up if it is! Also prints
  status to the serial monitor.

  Fischer Moseley @ SparkFun Electronics
  Original Creation Date: July 24, 2019

  This code is Lemonadeware; if you see me (or any other SparkFun employee) at the
  local, and you've found our code helpful, please buy us a round!

  Hardware Connections:
  Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
  Plug the button into the shield
  Print it to the serial monitor at 115200 baud.

  Distributed as-is; no warranty is given.
******************************************************************************/

#include <SparkFun_Qwiic_Button.h>
QwiicButton button;
//Define LED characteristics
uint8_t brightness = 250;   //The maximum brightness of the pulsing LED. Can be between 0 (min) and 255 (max)
uint16_t cycleTime = 1000;   //The total time for the pulse to take. Set to a bigger number for a slower pulse, or a smaller number for a faster pulse
uint16_t offTime = 200;     //The total time to stay off between pulses. Set to 0 to be pulsing continuously.

void setup() {
  Serial.begin(115200);
  Serial.println("Qwiic button examples");
  Wire1.begin(); //Join I2C bus

  //check if button will acknowledge over I2C
  if (button.begin(SFE_QWIIC_BUTTON_DEFAULT_ADDRESS, Wire1) == false) {
    Serial.println("Device did not acknowledge! Freezing.");
    while (1);
  }
  Serial.println("Button acknowledged.");
  button.LEDoff();  //start with the LED off
}

void loop() {
  //check if button is pressed, and tell us if it is!
  if (button.isPressed() == true) {
    Serial.println("The button is pressed!");
    button.LEDconfig(brightness, cycleTime, offTime);
    while (button.isPressed() == true)
      delay(10);  //wait for user to stop pressing
    Serial.println("The button is not pressed.");
    button.LEDoff();
  }
  delay(20); //let's not hammer too hard on the I2C bus
}
</code></pre>

<p>Notice that the code uses Wire1. The Qwiic connector on the Arduino UNO R4 WiFi Board is connected to a secondary I<sup>2</sup>C bus on this board, IIC0. This connector is <b>3.3V</b> only, connecting higher voltages may damage your board. To initialize this bus, use Wire1.begin() instead.</p>

<p>You should have the correct board and port selected, as per the Software section of this guide. Upload the code, and when you press the button you should see the button pulse as below:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641_QwiicButtonExample.gif"><img src="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641_QwiicButtonExample.gif" alt="GIF showing the button pulsing red when it is pushed" style="max-width: 100%;" /></a> </div></p>  <a name="#example-2-qwiic-twist"></a>
  <h2 id="example-2-qwiic-twist">Example 2: Qwiic Twist</h2>
  <h3>Library Installation</h3>

<p>We’ve written an easy to use Arduino library that covers the gamut of features on the Qwiic Twist. The easiest way to install the library is by searching <strong>SparkFun Twist</strong> within the Arduino library manager. We’ve even got a tutorial on <a href="https://learn.sparkfun.com/tutorials/installing-an-arduino-library/all">installing an Arduino library</a> if you need it. You can also manually install the <a href="https://github.com/sparkfun/SparkFun_Qwiic_Twist_Arduino_Library">Qwiic Twist library</a> by downloading a zip:</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_Twist_Arduino_Library/archive/master.zip" class="btn btn-default">Download the SparkFun Qwiic Twist Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-QwiicTwist.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-QwiicTwist.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example - Basic Readings</h3>

<p>This example is a basic one from the SparkFun Twist Library and just prints the number of times the knob has been turned to the serial output.</p>

<pre><code>language:c
/*
  Read and interact with the SparkFun Qwiic Twist digital RGB encoder
  By: Nathan Seidle
  SparkFun Electronics
  Date: December 3rd, 2018
  License: MIT. See license file for more information but you can
  basically do whatever you want with this code.

  This example prints the number of steps the encoder has been twisted.

  Feel like supporting open source hardware?
  Buy a board from SparkFun! https://www.sparkfun.com/products/15083

  Hardware Connections:
  Plug a Qwiic cable into the Qwiic Twist and a BlackBoard
  If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
  Open the serial monitor at 115200 baud to see the output
*/

#include "SparkFun_Qwiic_Twist_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_Twist
TWIST twist;                                      //Create instance of this object

void setup()
{
  Serial.begin(115200);
  Serial.println("Qwiic Twist Example");

  if (twist.begin(Wire1) == false)
  {
    Serial.println("Twist does not appear to be connected. Please check wiring. Freezing...");
    while (1)
      ;
  }
}

void loop()
{
  Serial.print("Count: ");
  Serial.print(twist.getCount());

  if (twist.isPressed())
    Serial.print(" Pressed!");

  Serial.println();

  delay(10);
}
</code></pre>

<p>As before, you should have the correct board and port selected in the <strong>Tools</strong> menu. Go ahead and upload the code, and open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a>. You should see something like the below:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/QwiicTwistExampleOutput.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/QwiicTwistExampleOutput.png" alt="Output of the software in the Serial Monitor" style="max-width: 100%;" /></a> </div></p>  <a name="#example-3-qwiic-oled"></a>
  <h2 id="example-3-qwiic-oled">Example 3: Qwiic OLED</h2>
  <h3>Library Installation</h3>

<p>The easiest way to install the Qwiic OLED library is to search for <b>SparkFun Qwiic OLED</b> in the Arduino Library Manager tool. You can also manually install the Qwiic OLED Library from the <a href="https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library">SparkFun Qwiic OLED Arduino GitHub Repository</a>. Alternatively, you can download by clicking the button below.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">Download the SparkFun Qwiic OLED Arduino Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-OLED.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-OLED.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example</h3>

<p>The following example is taken from Example 1 of the SparkFun Qwiic OLED library and is titled "Hello".</p>

<pre><code>language:c
/*

  Example-01_Hello.ino

  This demo shows the basic setup of the OLED library, generating simple graphics and displaying
  the results on the target device.

   Micro OLED             https://www.sparkfun.com/products/14532
   Transparent OLED       https://www.sparkfun.com/products/15173
   "Narrow" OLED          https://www.sparkfun.com/products/17153

  Written by Kirk Benell @ SparkFun Electronics, March 2022

  Repository:
     https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library

  Documentation:
     https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/

  SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/

#include <SparkFun_Qwiic_OLED.h> //http://librarymanager/All#SparkFun_Qwiic_Graphic_OLED

// The Library supports three different types of SparkFun boards. The demo uses the following
// defines to determine which device is being used. Uncomment the device being used for this demo.

// QwiicMicroOLED myOLED;
// QwiicTransparentOLED myOLED;
QwiicNarrowOLED myOLED;


void setup()
{
    Serial.begin(115200);
    Serial.println("Running OLED example");

    Wire1.begin();

    // Initalize the OLED device and related graphics system
    if (myOLED.begin(Wire1) == false)
    {
        Serial.println("Device begin failed. Freezing...");
        while (true)
            ;
    }
    Serial.println("Begin success");

    // Do a simple test - fill a rectangle on the screen and then print hello!

    // Fill a rectangle on the screen that has a 4 pixel board
    myOLED.rectangleFill(4, 4, myOLED.getWidth() - 8, myOLED.getHeight() - 8);

    String hello = "hello"; // our message

    // Center our message on the screen. Get the screen size of the "hello" string,
    // calling the getStringWidth() and getStringHeight() methods on the oled

    // starting x position - screen width minus string width  / 2
    int x0 = (myOLED.getWidth() - myOLED.getStringWidth(hello)) / 2;

    // starting y position - screen height minus string height / 2 
    int y0 = (myOLED.getHeight() - myOLED.getStringHeight(hello)) / 2;

    // Draw the text - color of black (0)
    myOLED.text(x0, y0, hello, 0);

    // There's nothing on the screen yet - Now send the graphics to the device
    myOLED.display();

    // That's it - HELLO!
}

void loop()
{
    delay(1000); // Do nothing
}
</code></pre>

<p>As before, make sure you select the correct board and port in the tools menu. Upload the code, and you should see something like the image below.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22632-_1.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22632-_1.jpg" alt="The OLED says hello!" style="max-width: 100%;" /></a> </div></p>

<p>Play with the settings, make your OLED say different things!</p>

<div class="alert alert-info" role="alert">
  <span class="glyphicon glyphicon-info"></span> <b>Note:</b> As in other examples, the Qwiic bus is connected to a secondary I<sup>2</sup>C bus on the Arduino board, IIC0. This connector is <b>3.3V</b> only, connecting higher voltages may damage your board. To initialize this bus, we use Wire1.begin(). In addition, this particular OLED requires the definition of "QwiicNarrowOLED". 
</div>  <a name="#example-4-qwiic-ambient-light-sensor-veml6030"></a>
  <h2 id="example-4-qwiic-ambient-light-sensor-veml6030">Example 4: Qwiic Ambient Light Sensor (VEML6030)</h2>
  <h3>Library Installation</h3>

<p>The Qwiic Ambient Light Sensor (VEML6030) library will give you the full functionality of the sensor and provides example code to get the most our of your project. You can obtain these libraries through the Arduino Library Manager by searching <strong>SparkFun Ambient Light Sensor</strong>. The second option is to download the ZIP file below from its <a href="https://github.com/sparkfun/SparkFun_Ambient_Light_Sensor_Arduino_Library">GitHub repository</a> to manually install.</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_Ambient_Light_Sensor_Arduino_Library/archive/master.zip" class="btn btn-default">SparkFun Ambient Light Sensor Arduino Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-LightSensor.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-LightSensor.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example</h3>

<p>In this example, we'll get you comfortable with gathering ambient light and setting two vital properties of the sensor's ability to read light: the <strong>gain</strong> and the <strong>integration time</strong>. These two properties determine the resolution (accuracy) of the reading and the available ranges of light that you can read! For example, a gain of 1/8 and 800ms integration time cannot read anything above 3775 Lux. This means you'll max out your sensor outdoors but would be a proper setting for dim rooms due to it's higher resolution.</p>

<pre><code>language:c
/*
  This example code will walk you through how to read ambient light values.
  Chances are good that you'll use this sensor in various environments so it'll
  also walk you through setting the gain and integration time that allow for
  different ranges of lux values. For example using the default gain of 100ms
  gives you a maximum reading of 30,199 Lux. This is great for daylight
  readings but not DIRECT sun. Higher integration times mean higher
  resoultions but lower lux values and vice versa: the lowest integration time
  and lowest gain should be used for mid day direct light. Check our hookup
  guide for more information. 

  SparkFun Electronics
  Author: Elias Santistevan
  Date: July 2019

    License: This code is public domain but if you use this and we meet someday, get me a beer! 

    Feel like supporting our work? Buy a board from Sparkfun!
    https://www.sparkfun.com/products/15436

*/

#include <Wire.h>
#include "SparkFun_VEML6030_Ambient_Light_Sensor.h"

#define AL_ADDR 0x48

SparkFun_Ambient_Light light(AL_ADDR);

// Possible values: .125, .25, 1, 2
// Both .125 and .25 should be used in most cases except darker rooms.
// A gain of 2 should only be used if the sensor will be covered by a dark
// glass.
float gain = .125;

// Possible integration times in milliseconds: 800, 400, 200, 100, 50, 25
// Higher times give higher resolutions and should be used in darker light. 
int timeLength = 100;
long luxVal = 0; 

void setup(){

  Wire1.begin();
  Serial.begin(115200);

  if(light.begin(Wire1))
    Serial.println("Ready to sense some light!"); 
  else
    Serial.println("Could not communicate with the sensor!");

  // Again the gain and integration times determine the resolution of the lux
  // value, and give different ranges of possible light readings. Check out
  // hoookup guide for more info. 
  light.setGain(gain);
  light.setIntegTime(timeLength);

  Serial.println("Reading settings..."); 
  Serial.print("Gain: ");
  float gainVal = light.readGain();
  Serial.print(gainVal, 3); 
  Serial.print(" Integration Time: ");
  int timeVal = light.readIntegTime();
  Serial.println(timeVal);

}

void loop(){

  luxVal = light.readLight();
  Serial.print("Ambient Light Reading: ");
  Serial.print(luxVal);
  Serial.println(" Lux");  
  delay(1000);

}
</code></pre>

<p>Make sure you have the correct board and port selected, and upload the code. Open a <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a> and you should see something like the below:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/LightSensorOutput.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/LightSensorOutput.png" alt="Output of the software in the Serial Monitor" style="max-width: 100%;" /></a> </div></p>  <a name="#example-5-triple-axis-accelerometer-breakout---bma400-qwiic"></a>
  <h2 id="example-5-triple-axis-accelerometer-breakout---bma400-qwiic">Example 5: Triple Axis Accelerometer Breakout - BMA400 (Qwiic)</h2>
  <h3>Library Installation</h3>

<p>The SparkFun BMA400 Arduino Library is based off the API for the sensor from Bosch to let users get started reading data from the sensor and using the various interrupt options. Install the library through the Arduino Library Manager tool by searching for <b>"SparkFun BMA400"</b>. Users who prefer to manually install the library can download a copy of it from the GitHub repository by clicking the button below:</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_BMA400_Arduino_Library/archive/refs/heads/main.zip" class="btn btn-default">SparkFun BMA400 Arduino Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-BMA400.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-ArduinoUnoR4WiFIKit-BMA400.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example</h3>

<p>This example demonstrates how to set the BMA400 up to communicate basic motion data over I<sup>2</sup>C.</p>

<pre><code>language:c
#include <Wire.h>
#include "SparkFun_BMA400_Arduino_Library.h"

// Create a new sensor object
BMA400 accelerometer;

// I2C address selection
uint8_t i2cAddress = BMA400_I2C_ADDRESS_DEFAULT; // 0x14
//uint8_t i2cAddress = BMA400_I2C_ADDRESS_SECONDARY; // 0x15

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("BMA400 Example 1 - Basic Readings I2C");

    // Initialize the I2C library
    Wire1.begin();

    // Check if sensor is connected and initialize
    // Address is optional (defaults to 0x14)
    while(accelerometer.beginI2C(i2cAddress, Wire1) != BMA400_OK)
    {
        // Not connected, inform user
        Serial.println("Error: BMA400 not connected, check wiring and I2C address!");

        // Wait a bit to see if connection is established
        delay(1000);
    }

    Serial.println("BMA400 connected!");
}

void loop()
{
    // Get measurements from the sensor. This must be called before accessing
    // the acceleration data, otherwise it will never update
    accelerometer.getSensorData();

    // Print acceleration data
    Serial.print("Acceleration in g's");
    Serial.print("\t");
    Serial.print("X: ");
    Serial.print(accelerometer.data.accelX, 3);
    Serial.print("\t");
    Serial.print("Y: ");
    Serial.print(accelerometer.data.accelY, 3);
    Serial.print("\t");
    Serial.print("Z: ");
    Serial.println(accelerometer.data.accelZ, 3);

    // Pause
    delay(2000);
}
</code></pre>

<p>Select your Board and Port and click Upload. Open the <a href="https://learn.sparkfun.com/tutorials/terminal-basics">serial monitor</a> after the upload completes with the baud set to <strong>115200</strong> to watch motion data print out.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/QwiicBMA400ExampleOutput.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/QwiicBMA400ExampleOutput.png" alt="Example output of the BMA400 in the serial monitor" style="max-width: 100%;" /></a> </div></p>

<p>Move the sensor around in different directions and watch the acceleration data change with the motion.</p>  <a name="#example-6-qwiic-atmospheric-sensor-bme280-"></a>
  <h2 id="example-6-qwiic-atmospheric-sensor-bme280-">Example 6: Qwiic Atmospheric Sensor (BME280) </h2>
  <h3>Library Installation</h3>

<p>We've written a library to easily get setup and take readings from the Qwiic Atmospheric Sensor, which you can install through the Arduino Library Manager. Search for <strong>SparkFun BME280 Arduino Library</strong> and you should be able to install the latest version. If you prefer manually downloading the libray from the <a href="https://github.com/sparkfun/SparkFun_BME280_Arduino_Library">GitHub repository</a>, you can grab it here:</p>

<p><div class="center-block text-center"> <a href="https://github.com/sparkfun/SparkFun_BME280_Arduino_Library/archive/master.zip" class="btn btn-default">Download the SparkFun BME280 Library (ZIP)</a> </div></p>

<h3>Hardware Hookup</h3>

<p>Plug one end of the Qwiic connector into the Qwiic port on the breakout board, and the other end into the Qwiic connector on the Arduino Uno R4 WiFi board like so:</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/22641-_KIT-_09.jpg"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/22641-_KIT-_09.jpg" alt="Plug one end of the qwiic connector into the qwiic port on the breakout board, and the other end into the qwiic connector on the Arduino Uno R4 WiFi board" style="max-width: 100%;" /></a> </div></p>

<h3>Software Example</h3>

<p>This basic example configures an BME280 on the I<sup>2</sup>C bus and reports out the data to the <a href="https://learn.sparkfun.com/tutorials/terminal-basics">Serial Monitor</a> at a baud rate of <strong>115200 baud</strong>.</p>

<pre><code>language:c
/*
  Get basic environmental readings from the BME280
  By: Nathan Seidle
  SparkFun Electronics
  Date: March 9th, 2018
  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/14348 - Qwiic Combo Board
  https://www.sparkfun.com/products/13676 - BME280 Breakout Board

  This example shows how to read humidity, pressure, and current temperature from the BME280 over I2C.

  Hardware connections:
  BME280 -> Arduino
  GND -> GND
  3.3 -> 3.3
  SDA -> A4
  SCL -> A5
*/

#include <Wire.h>

#include "SparkFunBME280.h"
BME280 mySensor;

void setup()
{
  Serial.begin(115200);
  Serial.println("Reading basic values from BME280");

  Wire1.begin();

  if (mySensor.beginI2C(Wire1) == false) //Begin communication over I2C
  {
    Serial.println("The sensor did not respond. Please check wiring.");
    while(1); //Freeze
  }
}

void loop()
{
  Serial.print("Humidity: ");
  Serial.print(mySensor.readFloatHumidity(), 0);

  Serial.print(" Pressure: ");
  Serial.print(mySensor.readFloatPressure(), 0);

  Serial.print(" Alt: ");
  //Serial.print(mySensor.readFloatAltitudeMeters(), 1);
  Serial.print(mySensor.readFloatAltitudeFeet(), 1);

  Serial.print(" Temp: ");
  //Serial.print(mySensor.readTempC(), 2);
  Serial.print(mySensor.readTempF(), 2);

  Serial.println();

  delay(50);
}
</code></pre>

<p>Select your Board and Port and click Upload. Open the <a href="https://learn.sparkfun.com/tutorials/terminal-basics">serial monitor</a> after the upload completes with the baud set to <strong>115200</strong> to watch data print out.</p>

<p><div class="center-block text-center"> <a href="https://cdn.sparkfun.com/assets/learn_tutorials/3/2/4/3/QwiicBME280ExampleOutput.png"><img src="https://cdn.sparkfun.com/r/600-600/assets/learn_tutorials/3/2/4/3/QwiicBME280ExampleOutput.png" alt="BME280 output" style="max-width: 100%;" /></a> </div></p>  <a name="#troubleshooting"></a>
  <h2 id="troubleshooting">Troubleshooting</h2>
  <!---
This section doesn't need any changes - it is our standard troubleshooting template as of 12/4/2019. 
--->

<div class="alert alert-info" role="alert">
  <span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
<strong> Need help? </strong>  <br /><br />

If your product is not working as you expected or you need technical assistance or information, head on over to the <a href="https://www.sparkfun.com/technical_assistance">SparkFun Technical Assistance</a> page for some initial troubleshooting. <br /><br />

If you don't find what you need there, the <a href="https://forum.sparkfun.com/index.php">SparkFun Forums</a> are a great place to find and ask for help. If this is your first visit, you'll need to <a href="https://forum.sparkfun.com/ucp.php?mode=register">create a Forum Account</a> to search product forums and post questions. </div>  <a name="#resources--going-further"></a>
  <h2 id="resources--going-further">Resources and Going Further</h2>
  <p>This is a basic guide to get you started with your SparkFun Arduino UNO R4 WiFi Kit. For more information, check out the resources below:</p>

<h4>Qwiic LED Button</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/8/b/a/2/f/Qwiic_Button.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/2/9/c/e/7/Qwiic_Button.zip">Eagle Files (ZIP)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/learn_tutorials/1/1/0/8/SparkFun_Qwiic_Button_Board_Dimensions.png">Board Dimensions (PNG)</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Qwiic_Button_Arduino_Library">Qwiic Button Arduino Library</a></li>
<li><a href="https://github.com/sparkfun/Qwiic_Button">GitHub Hardware Repo</a></li>
</ul>

<h4>Qwiic Twist</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/2/f/2/c/c/Qwiic_Twist.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/d/f/5/1/2/SparkFun_Qwiic_Twist.zip">Eagle (ZIP)</a></li>
<li><a href="https://cdn.sparkfun.com/r/600-600/assets/5/3/d/5/6/RegisterMap.jpg">Qwiic Twist Register Map</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Qwiic_Twist_Arduino_Library">SparkFun Qwiic Twist Arduino Library</a></li>
<li><a href="https://github.com/sparkfun/Qwiic_Twist">GitHub Hardware Repo</a> - For Qwiic Twist that includes the firmware for the ATtiny84</li>
</ul>

<h4>Qwiic OLED</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/5/9/0/6/f/OLED_Display.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/3/7/f/9/b/SparkFun_Qwiic_OLED_Display__0.91_in__128x32_.zip">Eagle Files (ZIP)</a></li>
<li><a href="https://www.smart-prototyping.com/blog/Zio-OLED-Display-Qwiic-Guide">Quick Start Guide</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library">SparkFun Arduino Library</a></li>
</ul>

<h4>Qwiic Ambient Light Sensor (VEML6030)</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/learn_tutorials/9/1/5/SparkFun_Ambient_Light_Sensor_VEML6030.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/a/f/c/5/5/SparkFun_Ambient_Light_Sensor_VEML6030_V10.zip">Eagle Files (ZIP)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/d/7/4/2/9/veml6030_datasheet.pdf">Datasheet (PDF)</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Ambient_Light_Sensor_Arduino_Library">SparkFun Ambient Light Sensor Arduino LIbrary</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Ambient_Sensor_VEML6030">GitHub Hardware Repo</a></li>
</ul>

<h4>Triple Axis Accelerometer Breakout - BMA400 (Qwiic)</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/0/2/5/5/b/SparkFun_Triple_Axis_Accelerometer_Breakout_-_BMA400__Qwiic_.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/6/b/9/5/3/SparkFun_Triple_Axis_Accelerometer_Breakout_-_BMA400__Qwiic_.zip">Eagle Files (ZIP)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/7/a/3/1/e/SparkFun_Triple_Axis_Accelerometer_Breakout_-_BMA400__Qwiic__Dimensions.png">Board Dimensions (PNG)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/e/9/e/6/0/BMA400-Datasheet.pdf">Datasheet</a> (BMA400)</li>
<li><a href="https://github.com/sparkfun/SparkFun_BMA400_Arduino_Library">BMA400 Arduino Library</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_Qwiic_Accelerometer_BMA400">GitHub Hardware Repo</a></li>
</ul>

<h4>Qwiic Atmospheric Sensor (BME280)</h4>

<ul>
<li><a href="https://cdn.sparkfun.com/assets/0/9/6/b/4/Qwiic_BME280_Schematic_attempt2.pdf">Schematic (PDF)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/7/e/6/e/c/Qwiic_Atmospheric_Sensor__BME280_.zip">Eagle Files (ZIP)</a></li>
<li><a href="https://cdn.sparkfun.com/assets/e/7/3/b/1/BME280_Datasheet.pdf">BME280 Datasheet</a></li>
<li><a href="https://github.com/sparkfun/SparkFun_BME280_Arduino_Library">SparkFun BME280 Arduino Library</a></li>
<li><a href="https://github.com/sparkfun/Qwiic_Atmospheric_Sensor_Breakout_BME280">GitHub Hardware Repo</a></li>
</ul>

<p>Need help getting started with Arduino and I<sup>2</sup>C? Check out these resources:</p>

<ul>
<li><a href="https://playground.arduino.cc/Main/I2cScanner">Arduino I<sup>2</sup>C Scanner Example</a></li>
<li><a href="https://www.arduino.cc/en/reference/wire">Arduino Wire Library Reference Page</a></li>
<li><a href="https://playground.arduino.cc/Main/WireLibraryDetailedReference">Arduino Wire Library (In-Depth) Reference</a></li>
<li><a href="https://www.sparkfun.com/qwiic">Qwiic Info Page</a></li>
</ul>
<hr>

<p><a href="https://learn.sparkfun.com">learn.sparkfun.com</a> |
<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
| SparkFun Electronics | Niwot, Colorado</p></div></div>]]></description><link>https://learn.sparkfun.com/tutorials/sparkfun-arduino-uno-r4-wifi-qwiic-kit-hookup-guide</link><guid isPermaLink="false">c76f3f51750979928b32cdfa47ffd3f6</guid><dc:creator><![CDATA[learn.sparkfun.com]]></dc:creator><pubDate>Tue, 11 Jul 2023 06:00:00 GMT</pubDate><media:content medium="image" url="https://cdn.sparkfun.com/r/500-500/assets/parts/2/2/8/0/4/22641-_KIT_-1.jpg"/></item></channel></rss>