<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>tronixstuff.com</title>
	<atom:link href="https://tronixstuff.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://tronixstuff.com</link>
	<description>fun and learning with electronics since 2010</description>
	<lastBuildDate>Wed, 23 Apr 2025 05:05:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>

<image>
	<url>https://tronixstuff.com/wp-content/uploads/2022/04/favicon-32x32-1.png?w=32</url>
	<title>tronixstuff.com</title>
	<link>https://tronixstuff.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">12478855</site><cloud domain='tronixstuff.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<atom:link rel="search" type="application/opensearchdescription+xml" href="https://tronixstuff.com/osd.xml" title="tronixstuff.com" />
	<atom:link rel='hub' href='https://tronixstuff.com/?pushpress=hub'/>
	<item>
		<title>Tutorial &#8211; Using Long Range 315MHz RF Wireless Transceivers with Arduino</title>
		<link>https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Wed, 23 Apr 2025 05:05:43 +0000</pubDate>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[wireless]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=17186</guid>

					<description><![CDATA[You can send data from one Arduino to another, or create a wireless remote-control system using inexpensive long-range 315MHz or 433MHz wireless data units. Using this tutorial so you can quickly test and use your units, giving you the knowledge to build upon and make your own projects. So let&#8217;s get started! Testing the modules [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>You can send data from one Arduino to another, or create a wireless remote-control system using inexpensive long-range 315MHz or 433MHz <a href="https://pmdway.com/search?q=Long*%20Range*%20315MHz*%20RF*%20Wireless*%20Transceiver*%20Kit*&amp;type=article,page,product" target="_blank" rel="noreferrer noopener">wireless data units</a>.</p>



<p>Using this tutorial so you can quickly test and use your units, giving you the knowledge to build upon and make your own projects. So let&#8217;s get started!</p>



<h4 class="wp-block-heading">Testing the modules</h4>



<p>Our first guide is to simply test that data can be sent and received from one module to another. This is also an ideal setup for testing the radio range of the units in your area.</p>



<p>You will need:</p>



<ul class="wp-block-list">
<li>One set of 315MHz or 433MHz <a href="https://pmdway.com/search?q=Long*%20Range*%20315MHz*%20RF*%20Wireless*%20Transceiver*%20Kit*&amp;type=article,page,product" target="_blank" rel="noreferrer noopener">wireless data units</a></li>



<li>Two <a href="https://amzn.to/3YEg2DS" target="_blank" rel="noreferrer noopener">Arduino Uno</a> or similar boards and USB cables</li>



<li>Two <a href="https://amzn.to/42mUU7w" target="_blank" rel="noreferrer noopener">solderless breadboards</a></li>



<li>Some male to male <a href="https://amzn.to/42nzXJB" target="_blank" rel="noreferrer noopener">jumper wires</a></li>



<li><a href="https://amzn.to/3Ev2Ni6" target="_blank" rel="noreferrer noopener">One LED</a> and a <a href="https://amzn.to/4lyQZMi">resistor</a> of between 330 and 560 Ohms</li>



<li>An external power supply for one Arduino. This can be an AC-DC wall wart, USB power bank, anything to power it without using the PC that has the receiving Arduino connected to it.</li>
</ul>



<p>You also need to install the VirtualWire Arduino library. To do this:</p>



<ul class="wp-block-list">
<li>Download <a href="https://cdn.shopify.com/s/files/1/2386/9605/files/VirtualWire.zip?2199">this .zip file</a> into a temporary or your download directory.</li>



<li>Open the Arduino IDE and select Sketch &gt; Include Library &gt; Add .zip Library…</li>
</ul>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp"><img width="480" height="240" data-attachment-id="17190" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/install-library-1_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp" data-orig-size="480,240" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="install-library-1_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=480" alt="" class="wp-image-17190" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<ul class="wp-block-list">
<li>Navigate to the library .zip download and click &#8220;Open&#8221;:</li>
</ul>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp"><img width="480" height="284" data-attachment-id="17191" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/install-library-2_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp" data-orig-size="480,284" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="install-library-2_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=480" alt="" class="wp-image-17191" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<p>After a few moments the library will be installed. You can check that this has completed by selecting&nbsp;<em>Sketch &gt; Include Library&gt;&nbsp;</em>then scroll down the long pop-up menu until you see &#8220;VirtualWire&#8221; as shown below:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif"><img width="411" height="189" data-attachment-id="17193" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/install-library-3_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif" data-orig-size="411,189" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="install-library-3_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=411" src="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=411" alt="" class="wp-image-17193" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif 411w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=300 300w" sizes="(max-width: 411px) 100vw, 411px" /></a></figure>



<p>Now &#8211; back to the hardware. Allocate one Arduino to be the transmitter, and one the receiver. Upload the following sketch to the transmitter board:</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573750" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-transmitter-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="transmitter.ino content, created by johnaboxall on 04:51AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="transmitter.ino">
        <tr>
          <td id="file-transmitter-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-transmitter-ino-LC1" class="blob-code blob-code-inner js-file-line">// transmitter.ino</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-transmitter-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-transmitter-ino-LC3" class="blob-code blob-code-inner js-file-line">// Simple example of how to use VirtualWire to transmit messages</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-transmitter-ino-LC4" class="blob-code blob-code-inner js-file-line">// Implements a simplex (one-way) transmitter with an TX-C1 module</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-transmitter-ino-LC5" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-transmitter-ino-LC6" class="blob-code blob-code-inner js-file-line">// See VirtualWire.h for detailed API docs</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-transmitter-ino-LC7" class="blob-code blob-code-inner js-file-line">// Author: Mike McCauley (mikem@airspayce.com)</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-transmitter-ino-LC8" class="blob-code blob-code-inner js-file-line">// Copyright (C) 2008 Mike McCauley</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-transmitter-ino-LC9" class="blob-code blob-code-inner js-file-line">// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-transmitter-ino-LC10" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-transmitter-ino-LC11" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-transmitter-ino-LC12" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-transmitter-ino-LC13" class="blob-code blob-code-inner js-file-line">const int led_pin = 11;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-transmitter-ino-LC14" class="blob-code blob-code-inner js-file-line">const int transmit_pin = 12;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-transmitter-ino-LC15" class="blob-code blob-code-inner js-file-line">const int receive_pin = 2;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-transmitter-ino-LC16" class="blob-code blob-code-inner js-file-line">const int transmit_en_pin = 3;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-transmitter-ino-LC17" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-transmitter-ino-LC18" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-transmitter-ino-LC19" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-transmitter-ino-LC20" class="blob-code blob-code-inner js-file-line">    // Initialise the IO and ISR</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-transmitter-ino-LC21" class="blob-code blob-code-inner js-file-line">    vw_set_tx_pin(transmit_pin);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-transmitter-ino-LC22" class="blob-code blob-code-inner js-file-line">    vw_set_rx_pin(receive_pin);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-transmitter-ino-LC23" class="blob-code blob-code-inner js-file-line">    vw_set_ptt_pin(transmit_en_pin);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-transmitter-ino-LC24" class="blob-code blob-code-inner js-file-line">    vw_set_ptt_inverted(true); // Required for DR3100</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-transmitter-ino-LC25" class="blob-code blob-code-inner js-file-line">    vw_setup(2000);       // Bits per sec</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-transmitter-ino-LC26" class="blob-code blob-code-inner js-file-line">    pinMode(led_pin, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-transmitter-ino-LC27" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-transmitter-ino-LC28" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-transmitter-ino-LC29" class="blob-code blob-code-inner js-file-line">byte count = 1;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-transmitter-ino-LC30" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-transmitter-ino-LC31" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-transmitter-ino-LC32" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-transmitter-ino-LC33" class="blob-code blob-code-inner js-file-line">  char msg[7] = {&#39;h&#39;,&#39;e&#39;,&#39;l&#39;,&#39;l&#39;,&#39;o&#39;,&#39; &#39;,&#39;#&#39;};</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-transmitter-ino-LC34" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-transmitter-ino-LC35" class="blob-code blob-code-inner js-file-line">  msg[6] = count;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-transmitter-ino-LC36" class="blob-code blob-code-inner js-file-line">  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-transmitter-ino-LC37" class="blob-code blob-code-inner js-file-line">  vw_send((uint8_t *)msg, 7);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-transmitter-ino-LC38" class="blob-code blob-code-inner js-file-line">  vw_wait_tx(); // Wait until the whole message is gone</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-transmitter-ino-LC39" class="blob-code blob-code-inner js-file-line">  digitalWrite(led_pin, LOW);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-transmitter-ino-LC40" class="blob-code blob-code-inner js-file-line">  delay(1000);</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-transmitter-ino-LC41" class="blob-code blob-code-inner js-file-line">  count = count + 1;</td>
        </tr>
        <tr>
          <td id="file-transmitter-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-transmitter-ino-LC42" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/9e450a5fd9226b5ac9f4f1b134182776/raw/8e203798607717478ce3c3bd9220eba5080bd747/transmitter.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/9e450a5fd9226b5ac9f4f1b134182776#file-transmitter-ino" class="Link--inTextBlock">
          transmitter.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>… and upload the following sketch to the receiver board:</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573759" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-receiver-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="receiver.ino content, created by johnaboxall on 04:52AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="receiver.ino">
        <tr>
          <td id="file-receiver-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-receiver-ino-LC1" class="blob-code blob-code-inner js-file-line">// receiver.ino</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-receiver-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-receiver-ino-LC3" class="blob-code blob-code-inner js-file-line">// Simple example of how to use VirtualWire to receive messages</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-receiver-ino-LC4" class="blob-code blob-code-inner js-file-line">// Implements a simplex (one-way) receiver with an Rx-B1 module</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-receiver-ino-LC5" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-receiver-ino-LC6" class="blob-code blob-code-inner js-file-line">// See VirtualWire.h for detailed API docs</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-receiver-ino-LC7" class="blob-code blob-code-inner js-file-line">// Author: Mike McCauley (mikem@airspayce.com)</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-receiver-ino-LC8" class="blob-code blob-code-inner js-file-line">// Copyright (C) 2008 Mike McCauley</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-receiver-ino-LC9" class="blob-code blob-code-inner js-file-line">// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-receiver-ino-LC10" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-receiver-ino-LC11" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-receiver-ino-LC12" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-receiver-ino-LC13" class="blob-code blob-code-inner js-file-line">const int led_pin = 2;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-receiver-ino-LC14" class="blob-code blob-code-inner js-file-line">const int transmit_pin = 12;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-receiver-ino-LC15" class="blob-code blob-code-inner js-file-line">const int receive_pin = 11;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-receiver-ino-LC16" class="blob-code blob-code-inner js-file-line">const int transmit_en_pin = 3;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-receiver-ino-LC17" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-receiver-ino-LC18" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-receiver-ino-LC19" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-receiver-ino-LC20" class="blob-code blob-code-inner js-file-line">  delay(1000);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-receiver-ino-LC21" class="blob-code blob-code-inner js-file-line">  Serial.begin(9600);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-receiver-ino-LC22" class="blob-code blob-code-inner js-file-line">  Serial.println(&quot;setup&quot;);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-receiver-ino-LC23" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-receiver-ino-LC24" class="blob-code blob-code-inner js-file-line">  // Initialise the IO and ISR</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-receiver-ino-LC25" class="blob-code blob-code-inner js-file-line">  vw_set_tx_pin(transmit_pin);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-receiver-ino-LC26" class="blob-code blob-code-inner js-file-line">  vw_set_rx_pin(receive_pin);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-receiver-ino-LC27" class="blob-code blob-code-inner js-file-line">  vw_set_ptt_pin(transmit_en_pin);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-receiver-ino-LC28" class="blob-code blob-code-inner js-file-line">  vw_set_ptt_inverted(true); // Required for DR3100</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-receiver-ino-LC29" class="blob-code blob-code-inner js-file-line">  vw_setup(2000);	 // Bits per sec</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-receiver-ino-LC30" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-receiver-ino-LC31" class="blob-code blob-code-inner js-file-line">  vw_rx_start();       // Start the receiver PLL running</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-receiver-ino-LC32" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-receiver-ino-LC33" class="blob-code blob-code-inner js-file-line">  pinMode(led_pin, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-receiver-ino-LC34" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-receiver-ino-LC35" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-receiver-ino-LC36" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-receiver-ino-LC37" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-receiver-ino-LC38" class="blob-code blob-code-inner js-file-line">  uint8_t buf[VW_MAX_MESSAGE_LEN];</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-receiver-ino-LC39" class="blob-code blob-code-inner js-file-line">  uint8_t buflen = VW_MAX_MESSAGE_LEN;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-receiver-ino-LC40" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-receiver-ino-LC41" class="blob-code blob-code-inner js-file-line">  if (vw_get_message(buf, &amp;buflen)) // Non-blocking</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-receiver-ino-LC42" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L43" class="blob-num js-line-number js-blob-rnum" data-line-number="43"></td>
          <td id="file-receiver-ino-LC43" class="blob-code blob-code-inner js-file-line">    int i;</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L44" class="blob-num js-line-number js-blob-rnum" data-line-number="44"></td>
          <td id="file-receiver-ino-LC44" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L45" class="blob-num js-line-number js-blob-rnum" data-line-number="45"></td>
          <td id="file-receiver-ino-LC45" class="blob-code blob-code-inner js-file-line">    digitalWrite(led_pin, HIGH); // Flash a light to show received good message</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L46" class="blob-num js-line-number js-blob-rnum" data-line-number="46"></td>
          <td id="file-receiver-ino-LC46" class="blob-code blob-code-inner js-file-line">    // Message with a good checksum received, dump it.</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L47" class="blob-num js-line-number js-blob-rnum" data-line-number="47"></td>
          <td id="file-receiver-ino-LC47" class="blob-code blob-code-inner js-file-line">    Serial.print(&quot;Got: &quot;);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L48" class="blob-num js-line-number js-blob-rnum" data-line-number="48"></td>
          <td id="file-receiver-ino-LC48" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L49" class="blob-num js-line-number js-blob-rnum" data-line-number="49"></td>
          <td id="file-receiver-ino-LC49" class="blob-code blob-code-inner js-file-line">    for (i = 0; i &lt; buflen; i++)</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L50" class="blob-num js-line-number js-blob-rnum" data-line-number="50"></td>
          <td id="file-receiver-ino-LC50" class="blob-code blob-code-inner js-file-line">    {</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L51" class="blob-num js-line-number js-blob-rnum" data-line-number="51"></td>
          <td id="file-receiver-ino-LC51" class="blob-code blob-code-inner js-file-line">      Serial.print(buf[i], HEX);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L52" class="blob-num js-line-number js-blob-rnum" data-line-number="52"></td>
          <td id="file-receiver-ino-LC52" class="blob-code blob-code-inner js-file-line">      Serial.print(&#39; &#39;);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L53" class="blob-num js-line-number js-blob-rnum" data-line-number="53"></td>
          <td id="file-receiver-ino-LC53" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L54" class="blob-num js-line-number js-blob-rnum" data-line-number="54"></td>
          <td id="file-receiver-ino-LC54" class="blob-code blob-code-inner js-file-line">    Serial.println();</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L55" class="blob-num js-line-number js-blob-rnum" data-line-number="55"></td>
          <td id="file-receiver-ino-LC55" class="blob-code blob-code-inner js-file-line">    digitalWrite(led_pin, LOW);</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L56" class="blob-num js-line-number js-blob-rnum" data-line-number="56"></td>
          <td id="file-receiver-ino-LC56" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-receiver-ino-L57" class="blob-num js-line-number js-blob-rnum" data-line-number="57"></td>
          <td id="file-receiver-ino-LC57" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/d2dfd96fadd86cc04cc74da57ba4f06f/raw/b155f4e00ae6c9167cc47feb2ce7d2ea72e9a5f1/receiver.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/d2dfd96fadd86cc04cc74da57ba4f06f#file-receiver-ino" class="Link--inTextBlock">
          receiver.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>Wiring the modules is very easy, they are labelled well and drop straight into a solderless breadboard:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp"><img loading="lazy" width="480" height="480" data-attachment-id="17196" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp" data-orig-size="480,480" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=480" alt="" class="wp-image-17196" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<p>Now connect the transmitter module to your transmitter Arduino as such:</p>



<ul class="wp-block-list">
<li>Arduino GND to transmitter GND</li>



<li>Arduino 5V to transmitter Vcc</li>



<li>Arduino digital pin 12 to transmitter SIG:</li>
</ul>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp"><img loading="lazy" width="600" height="380" data-attachment-id="17197" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/transmitterbuild_grande/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp" data-orig-size="600,380" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="transmitterbuild_grande" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=600" src="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=600" alt="" class="wp-image-17197" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp 600w, https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=300 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></figure>



<p>Next,&nbsp;connect the receiver module to your transmitter Arduino as such:</p>



<ul class="wp-block-list">
<li>Arduino GND to receiver GND</li>



<li>Arduino 5V to receiver Vcc</li>



<li>Arduino digital pin 11 to receiver SIG</li>



<li>LED and resistor in series between Arduino digital pin 2 and GND</li>
</ul>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp"><img loading="lazy" width="600" height="333" data-attachment-id="17199" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/receiverbuild_grande/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp" data-orig-size="600,333" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="receiverbuild_grande" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=600" src="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=600" alt="" class="wp-image-17199" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp 600w, https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=300 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></figure>



<p>Now that you&#8217;ve assembled both circuits, and uploaded the transmitter and receiver sketches to each board &#8211; it&#8217;s time to test.&nbsp;</p>



<p>Connect the transmitter board to power, and connect the receiver board to the PC. If not already open, run the Arduino IDE and open the serial monitor. You should notice two things:</p>



<ol class="wp-block-list">
<li>The LED on your receiver circuit should blink around once per second. When the LED blinks, this indicates the receiver circuit has successfully received a complete message from the transmitter</li>



<li>The data sent from the transmitter is displayed in the serial monitor.</li>
</ol>



<p>You can see this in action through the following <a href="https://www.youtube.com/watch?v=wMJEjJSierU" target="_blank" rel="noreferrer noopener">video</a>:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="embed-youtube"><iframe title="Testing wireless data links with Arduino" width="500" height="281" src="https://www.youtube.com/embed/wMJEjJSierU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<p>Our camera had trouble capturing the LED blink in some moments, but that&#8217;s ok.</p>



<p>You can also use this two Arduino setup to test the radio range &#8211; simply power the transmitter, and power the receiver circuit with a portable source of energy, such as a USB power bank &#8211; then walk away from the transmitter. The LED will stop blinking when you&#8217;re out of radio range.&nbsp;</p>



<p>You can increase the radio range by increasing the voltage to the transmitter unit &#8211; up to 12V DC.&nbsp;</p>



<p><strong>Wireless Remote Control</strong></p>



<p>Now to do something useful &#8211; create a wireless digital output control. Our transmitter will have two buttons, and our receiver will control two LEDs via digital outputs. Naturally this is an example, you can use this as a base to control other devices if required.&nbsp;</p>



<p>You will need:</p>



<ul class="wp-block-list">
<li>One set of 315MHz or 433MHz <a href="https://pmdway.com/search?q=Long*%20Range*%20315MHz*%20RF*%20Wireless*%20Transceiver*%20Kit*&amp;type=article,page,product" target="_blank" rel="noreferrer noopener">wireless data units</a></li>



<li>Two <a href="https://amzn.to/3YEg2DS" target="_blank" rel="noreferrer noopener">Arduino Uno</a> or similar boards and USB cables</li>



<li>Two <a href="https://amzn.to/42mUU7w" target="_blank" rel="noreferrer noopener">solderless breadboards</a></li>



<li>Some male to male <a href="https://amzn.to/42nzXJB" target="_blank" rel="noreferrer noopener">jumper wires</a></li>



<li><a href="https://amzn.to/3Ev2Ni6" target="_blank" rel="noreferrer noopener">Two LEDs</a> and two <a href="https://amzn.to/4lyQZMi" target="_blank" rel="noreferrer noopener">resistors</a> of between 330 and 560 Ohms</li>



<li>Two <a href="https://amzn.to/3YJnPjH" target="_blank" rel="noreferrer noopener">tactile buttons</a> and two 10k resistors OR two <a href="https://pmdway.com/products/tactile-button-breakout-boards-5-pack" target="_blank" rel="noreferrer noopener">button breakouts</a></li>



<li>An external power supply for one Arduino. This can be an AC-DC wall wart, USB power bank, anything to power it without using the PC that has the receiving Arduino connected to it.</li>
</ul>



<p>We will use two tactile buttons and 10k Ohm pull-down resistors for input. If you&#8217;re not familiar with digital inputs and buttons, the building block for this is shown below.</p>



<p>The example diagram uses D12 as the input pin, however for this project your transmitter circuit will need two button circuits, using D8 and D7:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp"><img loading="lazy" width="471" height="600" data-attachment-id="17201" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/button_grande/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp" data-orig-size="471,600" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="button_grande" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=236" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=471" src="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=471" alt="" class="wp-image-17201" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp 471w, https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=118 118w, https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=236 236w" sizes="(max-width: 471px) 100vw, 471px" /></a></figure>



<p>To save time we will use button breakout boards which combine the circuit into a neat unit ideal for prototyping:</p>



<p>Your receiver circuit is the same as the test circuit at the start of this tutorial, except&nbsp;that anothe LED circuit is added to digital pin 3.</p>



<p>Now for the sketches. Upload the following sketch to the transmitter (buttons) Arduino&#8230;</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573817" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-tx-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="tx.ino content, created by johnaboxall on 04:56AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="tx.ino">
        <tr>
          <td id="file-tx-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-tx-ino-LC1" class="blob-code blob-code-inner js-file-line">// transmitter sketch</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-tx-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-tx-ino-LC3" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-tx-ino-LC4" class="blob-code blob-code-inner js-file-line">uint8_t buf[VW_MAX_MESSAGE_LEN];</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-tx-ino-LC5" class="blob-code blob-code-inner js-file-line">uint8_t buflen = VW_MAX_MESSAGE_LEN;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-tx-ino-LC6" class="blob-code blob-code-inner js-file-line">const char *on2 = &quot;a&quot;;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-tx-ino-LC7" class="blob-code blob-code-inner js-file-line">const char *off2 = &quot;b&quot;;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-tx-ino-LC8" class="blob-code blob-code-inner js-file-line">const char *on3 = &quot;c&quot;;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-tx-ino-LC9" class="blob-code blob-code-inner js-file-line">const char *off3 = &quot;d&quot;;</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-tx-ino-LC10" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-tx-ino-LC11" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-tx-ino-LC12" class="blob-code blob-code-inner js-file-line">  vw_set_ptt_inverted(true); // Required for RF Link modules</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-tx-ino-LC13" class="blob-code blob-code-inner js-file-line">  vw_setup(300); // set data speed</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-tx-ino-LC14" class="blob-code blob-code-inner js-file-line">  vw_set_tx_pin(12);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-tx-ino-LC15" class="blob-code blob-code-inner js-file-line">  pinMode(8, INPUT);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-tx-ino-LC16" class="blob-code blob-code-inner js-file-line">  pinMode(7, INPUT);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-tx-ino-LC17" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-tx-ino-LC18" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-tx-ino-LC19" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-tx-ino-LC20" class="blob-code blob-code-inner js-file-line">  if (digitalRead(8)==HIGH)</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-tx-ino-LC21" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-tx-ino-LC22" class="blob-code blob-code-inner js-file-line">    vw_send((uint8_t *)on2, strlen(on2)); // send the data out to the world</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-tx-ino-LC23" class="blob-code blob-code-inner js-file-line">    vw_wait_tx(); // wait a moment</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-tx-ino-LC24" class="blob-code blob-code-inner js-file-line">    delay(200);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-tx-ino-LC25" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-tx-ino-LC26" class="blob-code blob-code-inner js-file-line">  if (digitalRead(8)==LOW)</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-tx-ino-LC27" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-tx-ino-LC28" class="blob-code blob-code-inner js-file-line">    vw_send((uint8_t *)off2, strlen(off2));</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-tx-ino-LC29" class="blob-code blob-code-inner js-file-line">    vw_wait_tx();</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-tx-ino-LC30" class="blob-code blob-code-inner js-file-line">    delay(200);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-tx-ino-LC31" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-tx-ino-LC32" class="blob-code blob-code-inner js-file-line">  if (digitalRead(7)==HIGH)</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-tx-ino-LC33" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-tx-ino-LC34" class="blob-code blob-code-inner js-file-line">    vw_send((uint8_t *)on3, strlen(on3));</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-tx-ino-LC35" class="blob-code blob-code-inner js-file-line">    vw_wait_tx();</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-tx-ino-LC36" class="blob-code blob-code-inner js-file-line">    delay(200);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-tx-ino-LC37" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-tx-ino-LC38" class="blob-code blob-code-inner js-file-line">  if (digitalRead(7)==LOW)</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-tx-ino-LC39" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-tx-ino-LC40" class="blob-code blob-code-inner js-file-line">    vw_send((uint8_t *)off3, strlen(off3));</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-tx-ino-LC41" class="blob-code blob-code-inner js-file-line">    vw_wait_tx();</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-tx-ino-LC42" class="blob-code blob-code-inner js-file-line">    delay(200);</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L43" class="blob-num js-line-number js-blob-rnum" data-line-number="43"></td>
          <td id="file-tx-ino-LC43" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-tx-ino-L44" class="blob-num js-line-number js-blob-rnum" data-line-number="44"></td>
          <td id="file-tx-ino-LC44" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/2e994de9d1dde882ed80f11aac7ce1cd/raw/45dc77946eee8ae501162e3bca32bc0016826f06/tx.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/2e994de9d1dde882ed80f11aac7ce1cd#file-tx-ino" class="Link--inTextBlock">
          tx.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>… and upload the following sketch to the receiver (LEDs) Arduino:</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573824" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-rx2-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="rx2.ino content, created by johnaboxall on 04:57AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="rx2.ino">
        <tr>
          <td id="file-rx2-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-rx2-ino-LC1" class="blob-code blob-code-inner js-file-line">// receiver sketch</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-rx2-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-rx2-ino-LC3" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-rx2-ino-LC4" class="blob-code blob-code-inner js-file-line">uint8_t buf[VW_MAX_MESSAGE_LEN];</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-rx2-ino-LC5" class="blob-code blob-code-inner js-file-line">uint8_t buflen = VW_MAX_MESSAGE_LEN;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-rx2-ino-LC6" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-rx2-ino-LC7" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-rx2-ino-LC8" class="blob-code blob-code-inner js-file-line">  vw_set_ptt_inverted(true); // Required for RF link modules</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-rx2-ino-LC9" class="blob-code blob-code-inner js-file-line">  vw_setup(300);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-rx2-ino-LC10" class="blob-code blob-code-inner js-file-line">  vw_set_rx_pin(11);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-rx2-ino-LC11" class="blob-code blob-code-inner js-file-line">  vw_rx_start();</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-rx2-ino-LC12" class="blob-code blob-code-inner js-file-line">  pinMode(3, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-rx2-ino-LC13" class="blob-code blob-code-inner js-file-line">  pinMode(2, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-rx2-ino-LC14" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-rx2-ino-LC15" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-rx2-ino-LC16" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-rx2-ino-LC17" class="blob-code blob-code-inner js-file-line">  if (vw_get_message(buf, &amp;buflen))</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-rx2-ino-LC18" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-rx2-ino-LC19" class="blob-code blob-code-inner js-file-line">    switch(buf[0])</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-rx2-ino-LC20" class="blob-code blob-code-inner js-file-line">    {</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-rx2-ino-LC21" class="blob-code blob-code-inner js-file-line">    case &#39;a&#39;:</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-rx2-ino-LC22" class="blob-code blob-code-inner js-file-line">      digitalWrite(2, HIGH);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-rx2-ino-LC23" class="blob-code blob-code-inner js-file-line">      break;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-rx2-ino-LC24" class="blob-code blob-code-inner js-file-line">    case &#39;b&#39;:</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-rx2-ino-LC25" class="blob-code blob-code-inner js-file-line">      digitalWrite(2, LOW);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-rx2-ino-LC26" class="blob-code blob-code-inner js-file-line">      break;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-rx2-ino-LC27" class="blob-code blob-code-inner js-file-line">    case &#39;c&#39;:</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-rx2-ino-LC28" class="blob-code blob-code-inner js-file-line">      digitalWrite(3, HIGH);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-rx2-ino-LC29" class="blob-code blob-code-inner js-file-line">      break;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-rx2-ino-LC30" class="blob-code blob-code-inner js-file-line">    case &#39;d&#39;:</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-rx2-ino-LC31" class="blob-code blob-code-inner js-file-line">      digitalWrite(3, LOW);</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-rx2-ino-LC32" class="blob-code blob-code-inner js-file-line">      break;</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-rx2-ino-LC33" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-rx2-ino-LC34" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-rx2-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-rx2-ino-LC35" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/35eb7af8afa9bfa63d13d9b99c7c2372/raw/05e7270f18266668e848186cb94f762db4e7f102/rx2.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/35eb7af8afa9bfa63d13d9b99c7c2372#file-rx2-ino" class="Link--inTextBlock">
          rx2.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>You can see a quick demonstration in the following <a href="https://www.youtube.com/watch?v=Jadv5lsA8CE">video</a>:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="embed-youtube"><iframe title="Arduino Wireless Remote Control Test" width="500" height="281" src="https://www.youtube.com/embed/Jadv5lsA8CE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<p><em>So how did that work?&nbsp;</em></p>



<p>Review the transmitter sketch. A character is sent over the wireless link which determines the latest operation of the buttons &#8211; a, b, c or d (button one high/low, button two high/low).</p>



<p>Review the receiver sketch &#8211; on line 19 the <em>switch-case</em> function interrogates the incoming character from the wireless link and determines the action &#8211; in this case, controlling the digital outputs which have the two LEDs. </p>



<p>The response speed may seem a little slow &#8211; this will be affected by the data speed (300 bps). You can experiment with data speed and radio range (and voltage to the transmitter unit)</p>



<p>You can then alter this for your own means. You may not want to continuously send data as our example does, depending on your needs. As always, have fun and experiment.&nbsp;</p>



<p><strong>Sending data wirelessly from one Arduino to another</strong></p>



<p>Now we&#8217;ll show how to send some data in the form of an integer over our wireless link. This is ideal for sending the values of analog inputs, or other data that can be represented as an integer.</p>



<p>The hardware is the same as before &#8211; one Arduino transmitting and one Arduino receiving &#8211; with the receiver unit connected to a PC so we can use the Serial Monitor to display the received data.&nbsp;</p>



<p>Upload the following sketch to the transmitter Arduino&#8230;</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573843" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-dtx1-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="dtx1.ino content, created by johnaboxall on 04:58AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="dtx1.ino">
        <tr>
          <td id="file-dtx1-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-dtx1-ino-LC1" class="blob-code blob-code-inner js-file-line">// data transmitter sketch//</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-dtx1-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-dtx1-ino-LC3" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-dtx1-ino-LC4" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-dtx1-ino-LC5" class="blob-code blob-code-inner js-file-line">// use onboard LED for status</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-dtx1-ino-LC6" class="blob-code blob-code-inner js-file-line">const int ledPin = 13;</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-dtx1-ino-LC7" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-dtx1-ino-LC8" class="blob-code blob-code-inner js-file-line">// we&#39;ll send the value of analog pin 1</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-dtx1-ino-LC9" class="blob-code blob-code-inner js-file-line">const int Sensor1Pin = A1;</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-dtx1-ino-LC10" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-dtx1-ino-LC11" class="blob-code blob-code-inner js-file-line">int Sensor1Data;</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-dtx1-ino-LC12" class="blob-code blob-code-inner js-file-line">char Sensor1CharMsg[4];</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-dtx1-ino-LC13" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-dtx1-ino-LC14" class="blob-code blob-code-inner js-file-line">void setup() </td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-dtx1-ino-LC15" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-dtx1-ino-LC16" class="blob-code blob-code-inner js-file-line">  pinMode(ledPin, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-dtx1-ino-LC17" class="blob-code blob-code-inner js-file-line">  pinMode(A1, INPUT);</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-dtx1-ino-LC18" class="blob-code blob-code-inner js-file-line">  vw_setup(2000); // data speed in bps</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-dtx1-ino-LC19" class="blob-code blob-code-inner js-file-line">  vw_set_tx_pin(12); //digital pin to data transmitter</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-dtx1-ino-LC20" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-dtx1-ino-LC21" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-dtx1-ino-LC22" class="blob-code blob-code-inner js-file-line">void loop() </td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-dtx1-ino-LC23" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-dtx1-ino-LC24" class="blob-code blob-code-inner js-file-line">  // get data from analog pin 1</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-dtx1-ino-LC25" class="blob-code blob-code-inner js-file-line">  Sensor1Data = analogRead(Sensor1Pin);</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-dtx1-ino-LC26" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-dtx1-ino-LC27" class="blob-code blob-code-inner js-file-line">  // convert data from integer to character array</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-dtx1-ino-LC28" class="blob-code blob-code-inner js-file-line">  itoa(Sensor1Data, Sensor1CharMsg, 10);</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-dtx1-ino-LC29" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-dtx1-ino-LC30" class="blob-code blob-code-inner js-file-line">  digitalWrite(13, true); // onboard LED on to indicate transmitting</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-dtx1-ino-LC31" class="blob-code blob-code-inner js-file-line">  vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg)); // send array</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-dtx1-ino-LC32" class="blob-code blob-code-inner js-file-line">  vw_wait_tx(); // wait until data is sent</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-dtx1-ino-LC33" class="blob-code blob-code-inner js-file-line">  digitalWrite(13, false); // onboard LED off to indicate finished transmitting</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-dtx1-ino-LC34" class="blob-code blob-code-inner js-file-line">  delay(1000); // wait</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-dtx1-ino-LC35" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-dtx1-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-dtx1-ino-LC36" class="blob-code blob-code-inner js-file-line">} </td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/6139654bcdf7c3507b659697f8304163/raw/b6d29ad46ad07d6d168c2a45058b32f90f5d35e7/dtx1.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/6139654bcdf7c3507b659697f8304163#file-dtx1-ino" class="Link--inTextBlock">
          dtx1.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>… and the following sketch to the receiver Arduino.</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137573848" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-drx2-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="drx2.ino content, created by johnaboxall on 04:59AM on April 23, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="drx2.ino">
        <tr>
          <td id="file-drx2-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-drx2-ino-LC1" class="blob-code blob-code-inner js-file-line">// data receiver sketch</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-drx2-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-drx2-ino-LC3" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-drx2-ino-LC4" class="blob-code blob-code-inner js-file-line">#include &lt;VirtualWire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-drx2-ino-LC5" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-drx2-ino-LC6" class="blob-code blob-code-inner js-file-line">// use onboard LED for status</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-drx2-ino-LC7" class="blob-code blob-code-inner js-file-line">const int ledPin = 13;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-drx2-ino-LC8" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-drx2-ino-LC9" class="blob-code blob-code-inner js-file-line">int Sensor1Data;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-drx2-ino-LC10" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-drx2-ino-LC11" class="blob-code blob-code-inner js-file-line">// holds data from receiver</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-drx2-ino-LC12" class="blob-code blob-code-inner js-file-line">char Sensor1CharMsg[4];</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-drx2-ino-LC13" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-drx2-ino-LC14" class="blob-code blob-code-inner js-file-line">void setup() {</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-drx2-ino-LC15" class="blob-code blob-code-inner js-file-line">  Serial.begin(9600);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-drx2-ino-LC16" class="blob-code blob-code-inner js-file-line">  pinMode(ledPin, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-drx2-ino-LC17" class="blob-code blob-code-inner js-file-line">  vw_set_ptt_inverted(true);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-drx2-ino-LC18" class="blob-code blob-code-inner js-file-line">  vw_setup(2000);     // data speed in bps</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-drx2-ino-LC19" class="blob-code blob-code-inner js-file-line">  vw_set_rx_pin(11);  // receiver data pin to digital 11</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-drx2-ino-LC20" class="blob-code blob-code-inner js-file-line">  vw_rx_start();</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-drx2-ino-LC21" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-drx2-ino-LC22" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-drx2-ino-LC23" class="blob-code blob-code-inner js-file-line">void loop() {</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-drx2-ino-LC24" class="blob-code blob-code-inner js-file-line">  uint8_t buf[VW_MAX_MESSAGE_LEN];</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-drx2-ino-LC25" class="blob-code blob-code-inner js-file-line">  uint8_t buflen = VW_MAX_MESSAGE_LEN;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-drx2-ino-LC26" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-drx2-ino-LC27" class="blob-code blob-code-inner js-file-line">  if (vw_get_message(buf, &amp;buflen))</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-drx2-ino-LC28" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-drx2-ino-LC29" class="blob-code blob-code-inner js-file-line">    int i;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-drx2-ino-LC30" class="blob-code blob-code-inner js-file-line">    // LED on to indicate message coming in</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-drx2-ino-LC31" class="blob-code blob-code-inner js-file-line">    digitalWrite(13, true);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-drx2-ino-LC32" class="blob-code blob-code-inner js-file-line">    for (i = 0; i &lt; buflen; i++)</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-drx2-ino-LC33" class="blob-code blob-code-inner js-file-line">    {</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-drx2-ino-LC34" class="blob-code blob-code-inner js-file-line">      // fill array with data from receiver</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-drx2-ino-LC35" class="blob-code blob-code-inner js-file-line">      Sensor1CharMsg[i] = char(buf[i]);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-drx2-ino-LC36" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-drx2-ino-LC37" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-drx2-ino-LC38" class="blob-code blob-code-inner js-file-line">    // null terminate the char array, indicates the end of the data</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-drx2-ino-LC39" class="blob-code blob-code-inner js-file-line">    Sensor1CharMsg[buflen] = &#39;\0&#39;;</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-drx2-ino-LC40" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-drx2-ino-LC41" class="blob-code blob-code-inner js-file-line">    // convert data in array to a usable integer</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-drx2-ino-LC42" class="blob-code blob-code-inner js-file-line">    Sensor1Data = atoi(Sensor1CharMsg);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L43" class="blob-num js-line-number js-blob-rnum" data-line-number="43"></td>
          <td id="file-drx2-ino-LC43" class="blob-code blob-code-inner js-file-line">    // send data to serial monitor</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L44" class="blob-num js-line-number js-blob-rnum" data-line-number="44"></td>
          <td id="file-drx2-ino-LC44" class="blob-code blob-code-inner js-file-line">    Serial.print(&quot;tx analog pin 1 reads: &quot;);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L45" class="blob-num js-line-number js-blob-rnum" data-line-number="45"></td>
          <td id="file-drx2-ino-LC45" class="blob-code blob-code-inner js-file-line">    Serial.println(Sensor1Data);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L46" class="blob-num js-line-number js-blob-rnum" data-line-number="46"></td>
          <td id="file-drx2-ino-LC46" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L47" class="blob-num js-line-number js-blob-rnum" data-line-number="47"></td>
          <td id="file-drx2-ino-LC47" class="blob-code blob-code-inner js-file-line">    // message reception finished, turn off onboard LED</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L48" class="blob-num js-line-number js-blob-rnum" data-line-number="48"></td>
          <td id="file-drx2-ino-LC48" class="blob-code blob-code-inner js-file-line">    digitalWrite(13, false);</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L49" class="blob-num js-line-number js-blob-rnum" data-line-number="49"></td>
          <td id="file-drx2-ino-LC49" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-drx2-ino-L50" class="blob-num js-line-number js-blob-rnum" data-line-number="50"></td>
          <td id="file-drx2-ino-LC50" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/7d7d95c6f22799d95d4f13631d4e2d52/raw/a0f103882173a58dcce431f801a62393f24d5e3e/drx2.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/7d7d95c6f22799d95d4f13631d4e2d52#file-drx2-ino" class="Link--inTextBlock">
          drx2.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>Once operating and in radio range, the onboard LEDs will indicate successful transmission and reception of data. Open the serial monitor, and after a moment you will be presented with the data from analogue pin 1 of the transmitter Arduino &#8211; for example:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp"><img loading="lazy" width="480" height="265" data-attachment-id="17205" data-permalink="https://tronixstuff.com/2025/04/23/tutorial-315mhz-wireless-arduino/integer-results_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp" data-orig-size="480,265" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="integer-results_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=480" alt="" class="wp-image-17205" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<p><em>So how did that work?&nbsp;</em></p>



<p>Review the trasmitter sketch. We took a value from analog pin 1, and stored it into an integer variable on line 25. The VirtualWire library is geared to send data as characters so we convert the integer to a character array on line 28 &#8211; which is then sent as usual as shown in line 31.</p>



<p>Now review the receiver sketch. Nothing unusual, and the data from the receiver (in character form) is fed into the array at line 35. Once completed, we add &#8220;\0&#8221; to the end of the array to signify the end of the data. </p>



<p>The array is then converted back to an integer on line 42, then sent to the Serial Monitor. </p>



<p>So there you have it, we&#8217;ve sent integers across the airwaves. You can use your own &#8220;codes&#8221; with integers to mean all sorts of things and send them across. Ideal for temperature sensors, or anything really. </p>



<p>I hope you had fun experimenting with wireless units, or at least enjoyed reading about the possibilities. To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x – <a href="https://twitter.com/tronixstuff" target="_blank" rel="noreferrer noopener">@tronixstuff</a>.</p>



<p>If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>:</p>



<figure class="wp-block-image"><a href="https://amzn.to/42pngN1" target="_blank" rel="noreferrer noopener"><img data-attachment-id="17129" data-permalink="https://tronixstuff.com/tutorials/screenshot-2025-04-13-113628/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" data-orig-size="885,392" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screenshot 2025-04-13 113628" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=885" src="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" alt="" class="wp-image-17129" /></a></figure>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">17186</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp" medium="image">
			<media:title type="html">transmitterbuild_grande</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-1_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-2_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/install-library-3_large.avif?w=411" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/315mhz-long-range-ook-rf-module-pmdway-1_1800x1800_fda2ab3b-3abb-40a2-b05b-1a4b1813bc4e_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/transmitterbuild_grande.webp?w=600" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/receiverbuild_grande.webp?w=600" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/button_grande.webp?w=471" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/integer-results_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" medium="image" />
	</item>
		<item>
		<title>Project &#8211; Fun with Arduino-controlled Traffic Lights</title>
		<link>https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Tue, 15 Apr 2025 03:24:15 +0000</pubDate>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[traffic]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=17166</guid>

					<description><![CDATA[The goal of this project is to make a pair of traffic lights that can be used for learning about Arduino digital inputs and outputs &#8211; or as the prototype for your own traffic lights in model layouts such as trains, dioramas, LEGO and so on.&#160; Imagine a two-way road that has a single-lane bridge [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The goal of this project is to make a pair of traffic lights that can be used for learning about Arduino digital inputs and outputs &#8211; or as the prototype for your own traffic lights in model layouts such as trains, dioramas, LEGO and so on.&nbsp;</p>



<p>Imagine a two-way road that has a single-lane bridge &#8211; cars can only travel in one direction at a time. You need to build a system to stop drivers being impatient and risking their lives by approaching the bridge from both sides at the same time.&nbsp;</p>



<p>Your solution is a set of traffic lights. One set at each end of the bridge &#8211; east and west, and a sensor to detect cars approaching the lights. We&#8217;ll use our traffic light and button modules to keep things simple:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp"><img loading="lazy" width="479" height="145" data-attachment-id="17173" data-permalink="https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/traffic-prototype-2_large/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp" data-orig-size="479,145" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="traffic-prototype-2_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=479" src="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=479" alt="" class="wp-image-17173" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp 479w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=300 300w" sizes="(max-width: 479px) 100vw, 479px" /></a></figure>



<p>When a car approaches one side &#8211; and the lights are red, the car must wait until the light changes. The sensor detects the car and the system changes the lights at the other end from green to yellow to red.</p>



<p>Then the lights at the other side hold red and flash yellow, to give the awaiting motorists a little notice before crossing the bridge &#8211; which they can do when the lights change to green. And vice-versa! So let&#8217;s get started.</p>



<p><strong>Parts List</strong></p>



<ul class="wp-block-list">
<li>Arduino <a href="https://amzn.to/4juWmKu" target="_blank" rel="noreferrer noopener">Uno-compatible board</a> and USB cable</li>



<li>Two sets of <a href="https://amzn.to/4jrlfa4" target="_blank" rel="noreferrer noopener">LED traffic lights</a></li>



<li>Two <a href="https://amzn.to/4ctIWMy" target="_blank" rel="noreferrer noopener">solderless breadboards</a> (any size is fine)</li>



<li>Pack of male to female <a href="https://amzn.to/4jyZLYZ" target="_blank" rel="noreferrer noopener">jumper wires</a></li>



<li>Pack of male to male <a href="https://amzn.to/4jyZLYZ" target="_blank" rel="noreferrer noopener">jumper wires</a></li>



<li>Tactile button <a href="https://amzn.to/3E9ghzZ" target="_blank" rel="noreferrer noopener">breakout boards</a></li>
</ul>



<p>We use the tactile button boards as they are the equivalent to a button circuit with a 10k pull-down resistor; and we use the traffic lights as they are the equivalent of three LEDs with current-limiting resistors&#8230; that are much more convenient.</p>



<p><strong>﻿Putting it all together</strong></p>



<p>Thanks to the modules we&#8217;re using, the whole system is plug-and-play. The following image is our example in action. But don&#8217;t panic &#8211; we&#8217;ll go through it step-by-step.</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg"><img loading="lazy" width="1024" height="768" data-attachment-id="17174" data-permalink="https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/final-traffic-lights/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg" data-orig-size="4032,3024" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;SM-N960F&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1566383239&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.3&quot;,&quot;iso&quot;:&quot;320&quot;,&quot;shutter_speed&quot;:&quot;0.016666666666667&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="final-traffic-lights" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=1024" src="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=1024" alt="" class="wp-image-17174" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=1024 1024w, https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=2048 2048w, https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=300 300w, https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=768 768w, https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=1440 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>First we&#8217;ll connect the traffic lights. When you look at the bottom, you can see the pinout labels as such:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg"><img loading="lazy" width="1024" height="580" data-attachment-id="17175" data-permalink="https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/traffic-light-pinouts/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg" data-orig-size="2453,1391" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;SM-N960F&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1566383261&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.3&quot;,&quot;iso&quot;:&quot;250&quot;,&quot;shutter_speed&quot;:&quot;0.02&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="traffic-light-pinouts" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=1024" src="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=1024" alt="" class="wp-image-17175" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=1024 1024w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=2048 2048w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=300 300w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=768 768w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=1440 1440w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>We&#8217;ll call this the east side. Plug the traffic light module into a solderless breadboard, with the pins across the numerical columns as shown in the final image. Then connect four jumper wires from the solderless breadboard columns matching R Y G GND to the Arduino&#8217;s D11, D10, D9 and GND respectively.&nbsp;</p>



<p>Repeat this with another solderless breadboard (we&#8217;ll call it the west side) &#8211;&nbsp;connect&nbsp;four&nbsp;more&nbsp;jumper wires from the solderless breadboard columns matching R Y G GND to the Arduino&#8217;s D4, D3, D2 and GND respectively.</p>



<p>Now for the buttons. They have three pins &#8211; 5V, OUT and GND. When the button is pressed, the OUT pin goes from LOW to HIGH:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg"><img loading="lazy" width="1024" height="845" data-attachment-id="17176" data-permalink="https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/traffic-light-button/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg" data-orig-size="1380,1139" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;SM-N960F&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1566383298&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.3&quot;,&quot;iso&quot;:&quot;320&quot;,&quot;shutter_speed&quot;:&quot;0.02&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="traffic-light-button" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=1024" src="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=1024" alt="" class="wp-image-17176" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=1024 1024w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=300 300w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=768 768w, https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg 1380w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>First, run a jumper wire from the 5V on the Arduino to a blank column on one solderless breadboard. Then run another wire from that column over to the the other solderless breadboard. This gives you 5V on both breadboards.</p>



<p>Next, on each breadboard, run a jumper wire from the traffic lights&#8217; GND pin column to a column next to your 5V column on the breadboard. This gives you 5V and GND on each breadboard.&nbsp;</p>



<p>To connect&nbsp;the west button &#8211; connect 5V and GND to the new spots on the solderless breadboard, and the OUT pin to Arduino D5.&nbsp;</p>



<p>And for the east button &#8211; connect 5V and GND to the new spots on the solderless breadboard, and the OUT pin to Arduino D12.&nbsp;</p>



<p>Now go back and double-check your wiring &#8211; once you&#8217;re satisfied it&#8217;s time to upload the sketch.&nbsp;</p>



<p><strong>The Arduino sketch</strong></p>



<p>Time for the brains of the operation. Copy the sketch below and upload to your Arduino:</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137423654" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-traffic-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="traffic.ino content, created by johnaboxall on 01:57AM on April 15, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="traffic.ino">
        <tr>
          <td id="file-traffic-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-traffic-ino-LC1" class="blob-code blob-code-inner js-file-line">// <a href="https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/">https://tronixstuff.com/2025/04/15/project-arduino-controlled-traffic-lights/</a></td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-traffic-ino-LC2" class="blob-code blob-code-inner js-file-line">//</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-traffic-ino-LC3" class="blob-code blob-code-inner js-file-line">// define the I/O pins that are used on the Arduino</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-traffic-ino-LC4" class="blob-code blob-code-inner js-file-line">// &#8230; the buttons</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-traffic-ino-LC5" class="blob-code blob-code-inner js-file-line">#define westButton 5</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-traffic-ino-LC6" class="blob-code blob-code-inner js-file-line">#define eastButton 12</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-traffic-ino-LC7" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-traffic-ino-LC8" class="blob-code blob-code-inner js-file-line">// the LEDs on the traffic light modules</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-traffic-ino-LC9" class="blob-code blob-code-inner js-file-line">#define westRed 4</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-traffic-ino-LC10" class="blob-code blob-code-inner js-file-line">#define westYellow 3</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-traffic-ino-LC11" class="blob-code blob-code-inner js-file-line">#define westGreen 2</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-traffic-ino-LC12" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-traffic-ino-LC13" class="blob-code blob-code-inner js-file-line">#define eastRed 11</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-traffic-ino-LC14" class="blob-code blob-code-inner js-file-line">#define eastYellow 10</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-traffic-ino-LC15" class="blob-code blob-code-inner js-file-line">#define eastGreen 9</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-traffic-ino-LC16" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-traffic-ino-LC17" class="blob-code blob-code-inner js-file-line">#define yellowBlinkTime 500 // 0.5 seconds for yellow light blink</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-traffic-ino-LC18" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-traffic-ino-LC19" class="blob-code blob-code-inner js-file-line">boolean trafficWest = true; // west = true, east = false</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-traffic-ino-LC20" class="blob-code blob-code-inner js-file-line">int flowTime = 5000; // amount of time to let traffic flow</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-traffic-ino-LC21" class="blob-code blob-code-inner js-file-line">int changeDelay = 2000; // amount of time between color changes</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-traffic-ino-LC22" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-traffic-ino-LC23" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-traffic-ino-LC24" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-traffic-ino-LC25" class="blob-code blob-code-inner js-file-line">  // this code runs when the Arduino first powers-up</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-traffic-ino-LC26" class="blob-code blob-code-inner js-file-line">  // or after a reset</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-traffic-ino-LC27" class="blob-code blob-code-inner js-file-line">  </td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-traffic-ino-LC28" class="blob-code blob-code-inner js-file-line">  // setup digital I/O pins</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-traffic-ino-LC29" class="blob-code blob-code-inner js-file-line">  // buttons are INPUTs</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-traffic-ino-LC30" class="blob-code blob-code-inner js-file-line">  pinMode(westButton, INPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-traffic-ino-LC31" class="blob-code blob-code-inner js-file-line">  pinMode(eastButton, INPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-traffic-ino-LC32" class="blob-code blob-code-inner js-file-line">  // LEDs are OUTPUTs</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-traffic-ino-LC33" class="blob-code blob-code-inner js-file-line">  pinMode(westRed, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-traffic-ino-LC34" class="blob-code blob-code-inner js-file-line">  pinMode(westYellow, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-traffic-ino-LC35" class="blob-code blob-code-inner js-file-line">  pinMode(westGreen, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-traffic-ino-LC36" class="blob-code blob-code-inner js-file-line">  pinMode(eastRed, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-traffic-ino-LC37" class="blob-code blob-code-inner js-file-line">  pinMode(eastYellow, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-traffic-ino-LC38" class="blob-code blob-code-inner js-file-line">  pinMode(eastGreen, OUTPUT);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-traffic-ino-LC39" class="blob-code blob-code-inner js-file-line">  </td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-traffic-ino-LC40" class="blob-code blob-code-inner js-file-line">  // set initial state for lights &#8211; west side is green first</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-traffic-ino-LC41" class="blob-code blob-code-inner js-file-line">  digitalWrite(westRed, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-traffic-ino-LC42" class="blob-code blob-code-inner js-file-line">  digitalWrite(westYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L43" class="blob-num js-line-number js-blob-rnum" data-line-number="43"></td>
          <td id="file-traffic-ino-LC43" class="blob-code blob-code-inner js-file-line">  digitalWrite(westGreen, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L44" class="blob-num js-line-number js-blob-rnum" data-line-number="44"></td>
          <td id="file-traffic-ino-LC44" class="blob-code blob-code-inner js-file-line">  digitalWrite(eastRed, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L45" class="blob-num js-line-number js-blob-rnum" data-line-number="45"></td>
          <td id="file-traffic-ino-LC45" class="blob-code blob-code-inner js-file-line">  digitalWrite(eastYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L46" class="blob-num js-line-number js-blob-rnum" data-line-number="46"></td>
          <td id="file-traffic-ino-LC46" class="blob-code blob-code-inner js-file-line">  digitalWrite(eastGreen, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L47" class="blob-num js-line-number js-blob-rnum" data-line-number="47"></td>
          <td id="file-traffic-ino-LC47" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L48" class="blob-num js-line-number js-blob-rnum" data-line-number="48"></td>
          <td id="file-traffic-ino-LC48" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L49" class="blob-num js-line-number js-blob-rnum" data-line-number="49"></td>
          <td id="file-traffic-ino-LC49" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L50" class="blob-num js-line-number js-blob-rnum" data-line-number="50"></td>
          <td id="file-traffic-ino-LC50" class="blob-code blob-code-inner js-file-line">// this code runs continuously until power-off or a reset</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L51" class="blob-num js-line-number js-blob-rnum" data-line-number="51"></td>
          <td id="file-traffic-ino-LC51" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L52" class="blob-num js-line-number js-blob-rnum" data-line-number="52"></td>
          <td id="file-traffic-ino-LC52" class="blob-code blob-code-inner js-file-line">  if ( digitalRead(westButton) == HIGH ) </td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L53" class="blob-num js-line-number js-blob-rnum" data-line-number="53"></td>
          <td id="file-traffic-ino-LC53" class="blob-code blob-code-inner js-file-line">  // request west to east traffic flow</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L54" class="blob-num js-line-number js-blob-rnum" data-line-number="54"></td>
          <td id="file-traffic-ino-LC54" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L55" class="blob-num js-line-number js-blob-rnum" data-line-number="55"></td>
          <td id="file-traffic-ino-LC55" class="blob-code blob-code-inner js-file-line">    if ( trafficWest != true )</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L56" class="blob-num js-line-number js-blob-rnum" data-line-number="56"></td>
          <td id="file-traffic-ino-LC56" class="blob-code blob-code-inner js-file-line">      // only continue if traffic flowing in the opposite (east) direction</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L57" class="blob-num js-line-number js-blob-rnum" data-line-number="57"></td>
          <td id="file-traffic-ino-LC57" class="blob-code blob-code-inner js-file-line">    {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L58" class="blob-num js-line-number js-blob-rnum" data-line-number="58"></td>
          <td id="file-traffic-ino-LC58" class="blob-code blob-code-inner js-file-line">      trafficWest = true; // change traffic flow flag to west&gt;east</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L59" class="blob-num js-line-number js-blob-rnum" data-line-number="59"></td>
          <td id="file-traffic-ino-LC59" class="blob-code blob-code-inner js-file-line">      delay(flowTime); // give time for traffic to clear the bridge</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L60" class="blob-num js-line-number js-blob-rnum" data-line-number="60"></td>
          <td id="file-traffic-ino-LC60" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastGreen, LOW); // change east-facing lights from green&#8230;</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L61" class="blob-num js-line-number js-blob-rnum" data-line-number="61"></td>
          <td id="file-traffic-ino-LC61" class="blob-code blob-code-inner js-file-line">      // to yellow to red</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L62" class="blob-num js-line-number js-blob-rnum" data-line-number="62"></td>
          <td id="file-traffic-ino-LC62" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastYellow, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L63" class="blob-num js-line-number js-blob-rnum" data-line-number="63"></td>
          <td id="file-traffic-ino-LC63" class="blob-code blob-code-inner js-file-line">      delay(changeDelay);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L64" class="blob-num js-line-number js-blob-rnum" data-line-number="64"></td>
          <td id="file-traffic-ino-LC64" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L65" class="blob-num js-line-number js-blob-rnum" data-line-number="65"></td>
          <td id="file-traffic-ino-LC65" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastRed, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L66" class="blob-num js-line-number js-blob-rnum" data-line-number="66"></td>
          <td id="file-traffic-ino-LC66" class="blob-code blob-code-inner js-file-line">      delay(changeDelay);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L67" class="blob-num js-line-number js-blob-rnum" data-line-number="67"></td>
          <td id="file-traffic-ino-LC67" class="blob-code blob-code-inner js-file-line">      for ( int a = 0; a &lt; 5; a++ ) // blink yellow light</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L68" class="blob-num js-line-number js-blob-rnum" data-line-number="68"></td>
          <td id="file-traffic-ino-LC68" class="blob-code blob-code-inner js-file-line">      {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L69" class="blob-num js-line-number js-blob-rnum" data-line-number="69"></td>
          <td id="file-traffic-ino-LC69" class="blob-code blob-code-inner js-file-line">        digitalWrite(westYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L70" class="blob-num js-line-number js-blob-rnum" data-line-number="70"></td>
          <td id="file-traffic-ino-LC70" class="blob-code blob-code-inner js-file-line">        delay(yellowBlinkTime);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L71" class="blob-num js-line-number js-blob-rnum" data-line-number="71"></td>
          <td id="file-traffic-ino-LC71" class="blob-code blob-code-inner js-file-line">        digitalWrite(westYellow, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L72" class="blob-num js-line-number js-blob-rnum" data-line-number="72"></td>
          <td id="file-traffic-ino-LC72" class="blob-code blob-code-inner js-file-line">        delay(yellowBlinkTime);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L73" class="blob-num js-line-number js-blob-rnum" data-line-number="73"></td>
          <td id="file-traffic-ino-LC73" class="blob-code blob-code-inner js-file-line">      }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L74" class="blob-num js-line-number js-blob-rnum" data-line-number="74"></td>
          <td id="file-traffic-ino-LC74" class="blob-code blob-code-inner js-file-line">      digitalWrite(westYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L75" class="blob-num js-line-number js-blob-rnum" data-line-number="75"></td>
          <td id="file-traffic-ino-LC75" class="blob-code blob-code-inner js-file-line">      digitalWrite(westRed, LOW); // change west-facing lights from red to green</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L76" class="blob-num js-line-number js-blob-rnum" data-line-number="76"></td>
          <td id="file-traffic-ino-LC76" class="blob-code blob-code-inner js-file-line">      digitalWrite(westGreen, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L77" class="blob-num js-line-number js-blob-rnum" data-line-number="77"></td>
          <td id="file-traffic-ino-LC77" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L78" class="blob-num js-line-number js-blob-rnum" data-line-number="78"></td>
          <td id="file-traffic-ino-LC78" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L79" class="blob-num js-line-number js-blob-rnum" data-line-number="79"></td>
          <td id="file-traffic-ino-LC79" class="blob-code blob-code-inner js-file-line">  if ( digitalRead(eastButton) == HIGH ) // request east to west traffic flow</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L80" class="blob-num js-line-number js-blob-rnum" data-line-number="80"></td>
          <td id="file-traffic-ino-LC80" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L81" class="blob-num js-line-number js-blob-rnum" data-line-number="81"></td>
          <td id="file-traffic-ino-LC81" class="blob-code blob-code-inner js-file-line">    if ( trafficWest == true )</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L82" class="blob-num js-line-number js-blob-rnum" data-line-number="82"></td>
          <td id="file-traffic-ino-LC82" class="blob-code blob-code-inner js-file-line">      // only continue if traffic flow is in the opposite (west) direction</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L83" class="blob-num js-line-number js-blob-rnum" data-line-number="83"></td>
          <td id="file-traffic-ino-LC83" class="blob-code blob-code-inner js-file-line">    {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L84" class="blob-num js-line-number js-blob-rnum" data-line-number="84"></td>
          <td id="file-traffic-ino-LC84" class="blob-code blob-code-inner js-file-line">      trafficWest = false; // change traffic flow flag to east&gt;west</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L85" class="blob-num js-line-number js-blob-rnum" data-line-number="85"></td>
          <td id="file-traffic-ino-LC85" class="blob-code blob-code-inner js-file-line">      delay(flowTime); // give time for traffic to clear the bridge</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L86" class="blob-num js-line-number js-blob-rnum" data-line-number="86"></td>
          <td id="file-traffic-ino-LC86" class="blob-code blob-code-inner js-file-line">      digitalWrite(westGreen, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L87" class="blob-num js-line-number js-blob-rnum" data-line-number="87"></td>
          <td id="file-traffic-ino-LC87" class="blob-code blob-code-inner js-file-line">      // change west lights from green to yellow to red</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L88" class="blob-num js-line-number js-blob-rnum" data-line-number="88"></td>
          <td id="file-traffic-ino-LC88" class="blob-code blob-code-inner js-file-line">      digitalWrite(westYellow, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L89" class="blob-num js-line-number js-blob-rnum" data-line-number="89"></td>
          <td id="file-traffic-ino-LC89" class="blob-code blob-code-inner js-file-line">      delay(changeDelay);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L90" class="blob-num js-line-number js-blob-rnum" data-line-number="90"></td>
          <td id="file-traffic-ino-LC90" class="blob-code blob-code-inner js-file-line">      digitalWrite(westYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L91" class="blob-num js-line-number js-blob-rnum" data-line-number="91"></td>
          <td id="file-traffic-ino-LC91" class="blob-code blob-code-inner js-file-line">      digitalWrite(westRed, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L92" class="blob-num js-line-number js-blob-rnum" data-line-number="92"></td>
          <td id="file-traffic-ino-LC92" class="blob-code blob-code-inner js-file-line">      delay(changeDelay);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L93" class="blob-num js-line-number js-blob-rnum" data-line-number="93"></td>
          <td id="file-traffic-ino-LC93" class="blob-code blob-code-inner js-file-line">      for ( int a = 0 ; a &lt; 5 ; a++ ) // blink yellow light</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L94" class="blob-num js-line-number js-blob-rnum" data-line-number="94"></td>
          <td id="file-traffic-ino-LC94" class="blob-code blob-code-inner js-file-line">      {</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L95" class="blob-num js-line-number js-blob-rnum" data-line-number="95"></td>
          <td id="file-traffic-ino-LC95" class="blob-code blob-code-inner js-file-line">        digitalWrite(eastYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L96" class="blob-num js-line-number js-blob-rnum" data-line-number="96"></td>
          <td id="file-traffic-ino-LC96" class="blob-code blob-code-inner js-file-line">        delay(yellowBlinkTime);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L97" class="blob-num js-line-number js-blob-rnum" data-line-number="97"></td>
          <td id="file-traffic-ino-LC97" class="blob-code blob-code-inner js-file-line">        digitalWrite(eastYellow, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L98" class="blob-num js-line-number js-blob-rnum" data-line-number="98"></td>
          <td id="file-traffic-ino-LC98" class="blob-code blob-code-inner js-file-line">        delay(yellowBlinkTime);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L99" class="blob-num js-line-number js-blob-rnum" data-line-number="99"></td>
          <td id="file-traffic-ino-LC99" class="blob-code blob-code-inner js-file-line">      }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L100" class="blob-num js-line-number js-blob-rnum" data-line-number="100"></td>
          <td id="file-traffic-ino-LC100" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastYellow, LOW);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L101" class="blob-num js-line-number js-blob-rnum" data-line-number="101"></td>
          <td id="file-traffic-ino-LC101" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastRed, LOW); // change east-facing lights from red to green</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L102" class="blob-num js-line-number js-blob-rnum" data-line-number="102"></td>
          <td id="file-traffic-ino-LC102" class="blob-code blob-code-inner js-file-line">      digitalWrite(eastGreen, HIGH);</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L103" class="blob-num js-line-number js-blob-rnum" data-line-number="103"></td>
          <td id="file-traffic-ino-LC103" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L104" class="blob-num js-line-number js-blob-rnum" data-line-number="104"></td>
          <td id="file-traffic-ino-LC104" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-traffic-ino-L105" class="blob-num js-line-number js-blob-rnum" data-line-number="105"></td>
          <td id="file-traffic-ino-LC105" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/aba486e9d0cfa15cc8f79283b656fad4/raw/13ec703f2a8e3fc749a0297379175d74d6d7638e/traffic.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/aba486e9d0cfa15cc8f79283b656fad4#file-traffic-ino" class="Link--inTextBlock">
          traffic.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>You can now operate your traffic lights! If you are facing the red light, press the matching button and wait until the lights change before you can cross the bridge.</p>



<p>You can adjust the delays, the speed of light-changing and the other aspects in the sketch. In some countries you may not have flashing yellow before green &#8211; so you could remove that feature.</p>



<p>You can see our example in operation from the <a href="https://www.youtube.com/watch?v=cNDKtVebaQU">video</a> below:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="embed-youtube"><iframe title="Project – Fun with Arduino-controlled Traffic Lights" width="500" height="281" src="https://www.youtube.com/embed/cNDKtVebaQU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<p><strong>Where to from here?&nbsp;</strong></p>



<p>You can now understand how the basic inputs and outputs of an Arduino development board can be harnessed for fun and useful projects. You could expand on this system by adding more traffic lights and buttons &#8211; use an <a href="https://amzn.to/42ASh0M" target="_blank" rel="noreferrer noopener">Arduino Mega-compatible</a> board as it has plenty more inputs and outputs.</p>



<p>Or you could experiment by using different types of sensors instead of buttons &#8211; such as&nbsp;motion detectors,&nbsp;beam-break&nbsp;switches or something home-made.</p>



<p>I hope you had fun with the traffic lights, or at least enjoyed reading about the blinking fun. To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x –&nbsp;<a href="https://twitter.com/tronixstuff" target="_blank" rel="noreferrer noopener">@tronixstuff</a>.</p>



<p>If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>:</p>



<figure class="wp-block-image"><a href="https://amzn.to/42pngN1" target="_blank" rel="noreferrer noopener"><img data-attachment-id="17129" data-permalink="https://tronixstuff.com/tutorials/screenshot-2025-04-13-113628/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" data-orig-size="885,392" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screenshot 2025-04-13 113628" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=885" src="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" alt="" class="wp-image-17129" /></a></figure>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">17166</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2025/04/arduino_lights_ai.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/arduino_lights_ai.jpg" medium="image">
			<media:title type="html">arduino_lights_AI</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-prototype-2_large.webp?w=479" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/final-traffic-lights.jpg?w=1024" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-pinouts.jpg?w=1024" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/traffic-light-button.jpg?w=1024" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" medium="image" />
	</item>
		<item>
		<title>Tutorial &#8211; TCA9548A 1-to-8 I2C Multiplexer Breakout with Arduino</title>
		<link>https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Mon, 14 Apr 2025 00:25:06 +0000</pubDate>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[TCA9548A]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=17135</guid>

					<description><![CDATA[Now and again you may find yourself needing to use more than one device with the same I2C bus address with your Arduino. Such as&#160;four OLEDs for a large display &#8211; or seven temperature sensors that are wired across a chicken hatchling coop.&#160; These types of problems can be solved with the TCA9548A 1-to-8 I2C Multiplexer [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Now and again you may find yourself needing to use more than one device with the same I2C bus address with your Arduino.</p>



<p>Such as&nbsp;four OLEDs for a large display &#8211; or seven temperature sensors that are wired across a chicken hatchling coop.&nbsp;</p>



<p>These types of problems can be solved with the <a href="https://amzn.to/4lvinLb" target="_blank" rel="noreferrer noopener">TCA9548A 1-to-8 I2C Multiplexer Breakout</a>, and in this guide we&#8217;ll run through the how to make it happen with some example devices. </p>



<p><strong>Getting Started</strong></p>



<p>First, consider the TCA9548A itself. It is the gateway between your Arduino and eight separate I2C buses. You have a single bus on one side, connected to your Arduino.</p>



<p>On the other side of the TCA9548A, you have eight I2C buses, and only one of these can be connected to the Arduino at a time. For example (from the <a href="https://www.ti.com/lit/ds/symlink/tca9548a.pdf" target="_blank" rel="noreferrer noopener">data sheet</a>):</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg"><img loading="lazy" width="591" height="315" data-attachment-id="17137" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_diagram/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg" data-orig-size="591,315" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_diagram" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=591" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=591" alt="" class="wp-image-17137" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg 591w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=300 300w" sizes="(max-width: 591px) 100vw, 591px" /></a></figure>



<p>The TCA9548 can operate on voltages between 1.8 and 5V DC&#8230; and operate with devices that have operating voltages between 1.8 and 5V DC. This is very convenient, as (for example) you can use devices made for 3.3V operation with 5V Arduinos, or vice versa. Awesome. So let&#8217;s get started.&nbsp;</p>



<p>The breakout board includes inline header pins, which are not soldered to the board. So you need to do that. An easy way to line up the pins properly is to drop them into a <a href="https://amzn.to/42J6slA">solderless breadboard</a>, as such:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp"><img loading="lazy" width="424" height="480" data-attachment-id="17139" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_breadboard_large-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp" data-orig-size="424,480" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_breadboard_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=265" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=424" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=424" alt="" class="wp-image-17139" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp 424w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=133 133w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=265 265w" sizes="(max-width: 424px) 100vw, 424px" /></a></figure>



<p>Then after a moment or two of soldering, you&#8217;re ready to use:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp"><img loading="lazy" width="480" height="401" data-attachment-id="17140" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_breadboard_ready_large-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp" data-orig-size="480,401" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_breadboard_ready_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=480" alt="" class="wp-image-17140" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<p>Next, insert your module into a solderless breadboard and wire it up as shown:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp"><img loading="lazy" width="407" height="480" data-attachment-id="17142" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_breadboard_ready_2_large-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp" data-orig-size="407,480" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_breadboard_ready_2_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=254" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=407" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=407" alt="" class="wp-image-17142" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp 407w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=127 127w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=254 254w" sizes="(max-width: 407px) 100vw, 407px" /></a></figure>



<p>We are using the red and blue vertical strips on the breadboard as 5V and GND respectively. Finally, we connect the 5V and GND from the Arduino to the solderless breadboard, and A4/A5 to SDA/SCL respectively on the breakout board:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp"><img loading="lazy" width="387" height="480" data-attachment-id="17143" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_breadboard_ready_3_large-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp" data-orig-size="387,480" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_breadboard_ready_3_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=242" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=387" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=387" alt="" class="wp-image-17143" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp 387w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=121 121w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=242 242w" sizes="(max-width: 387px) 100vw, 387px" /></a></figure>



<p>The electrical connections are as follows (Module&nbsp;&#8212; Arduino):</p>



<ul class="wp-block-list">
<li>Vin to 5V</li>



<li>GND to GND</li>



<li>A0 to GND</li>



<li>A1 to GND</li>



<li>A2 to GND</li>



<li>SDA to A4</li>



<li>SCL to A5</li>
</ul>



<p>Next, we consider the I2C bus address for the TCA9548A. Using the wiring setup shown above, the address is set to 0x70.&nbsp;<em>You only need to change this if one of your other devices also has an address of 0x70, as shown in the next step.</em></p>



<p><strong>Changing the I2C address of the TCA9548A</strong></p>



<p>The bus address of the TCA9548A is changed using the connections to the A0, A1 and A2 pins. By default in the tutorial we use 0x70, by wiring A0~A2 to GND (known as LOW). Using the table below, you can reconfigure to an address between 0x70 and 0x77 by matching the inputs to HIGH (5V) or LOW (GND):</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp"><img loading="lazy" width="480" height="244" data-attachment-id="17145" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_address_table_large-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp" data-orig-size="480,244" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_address_table_large" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=480" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=480" alt="" class="wp-image-17145" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp 480w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=300 300w" sizes="(max-width: 480px) 100vw, 480px" /></a></figure>



<p><strong>Testing&nbsp;</strong></p>



<p>Before we get too excited, now is a good time to test our wiring to ensure the Arduino can communicate with the TCA9548A. We&#8217;ll do this by running an I2C scanner sketch, which returns the bus address of a connected device.&nbsp;</p>



<p>Copy and paste this sketch into your Arduino IDE and upload it to your board. </p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist97858070" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-i2cscanner-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="i2cscanner.ino content, created by johnaboxall on 06:32AM on August 20, 2019."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="i2cscanner.ino">
        <tr>
          <td id="file-i2cscanner-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-i2cscanner-ino-LC1" class="blob-code blob-code-inner js-file-line">#include &lt;Wire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-i2cscanner-ino-LC2" class="blob-code blob-code-inner js-file-line"> </td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-i2cscanner-ino-LC3" class="blob-code blob-code-inner js-file-line">void setup() {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-i2cscanner-ino-LC4" class="blob-code blob-code-inner js-file-line">  Wire.begin();</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-i2cscanner-ino-LC5" class="blob-code blob-code-inner js-file-line">  Serial.begin(115200);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-i2cscanner-ino-LC6" class="blob-code blob-code-inner js-file-line">  Serial.println(&quot;\nI2C Scanner&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-i2cscanner-ino-LC7" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-i2cscanner-ino-LC8" class="blob-code blob-code-inner js-file-line"> </td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-i2cscanner-ino-LC9" class="blob-code blob-code-inner js-file-line">void loop() {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-i2cscanner-ino-LC10" class="blob-code blob-code-inner js-file-line">  byte error, address;</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-i2cscanner-ino-LC11" class="blob-code blob-code-inner js-file-line">  int nDevices;</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-i2cscanner-ino-LC12" class="blob-code blob-code-inner js-file-line">  Serial.println(&quot;Scanning&#8230;&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-i2cscanner-ino-LC13" class="blob-code blob-code-inner js-file-line">  nDevices = 0;</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-i2cscanner-ino-LC14" class="blob-code blob-code-inner js-file-line">  for(address = 1; address &lt; 127; address++ ) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-i2cscanner-ino-LC15" class="blob-code blob-code-inner js-file-line">    Wire.beginTransmission(address);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-i2cscanner-ino-LC16" class="blob-code blob-code-inner js-file-line">    error = Wire.endTransmission();</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-i2cscanner-ino-LC17" class="blob-code blob-code-inner js-file-line">    if (error == 0) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-i2cscanner-ino-LC18" class="blob-code blob-code-inner js-file-line">      Serial.print(&quot;I2C device found at address 0x&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-i2cscanner-ino-LC19" class="blob-code blob-code-inner js-file-line">      if (address&lt;16) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-i2cscanner-ino-LC20" class="blob-code blob-code-inner js-file-line">        Serial.print(&quot;0&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-i2cscanner-ino-LC21" class="blob-code blob-code-inner js-file-line">      }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-i2cscanner-ino-LC22" class="blob-code blob-code-inner js-file-line">      Serial.println(address,HEX);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-i2cscanner-ino-LC23" class="blob-code blob-code-inner js-file-line">      nDevices++;</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-i2cscanner-ino-LC24" class="blob-code blob-code-inner js-file-line">    }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-i2cscanner-ino-LC25" class="blob-code blob-code-inner js-file-line">    else if (error==4) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-i2cscanner-ino-LC26" class="blob-code blob-code-inner js-file-line">      Serial.print(&quot;Unknow error at address 0x&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-i2cscanner-ino-LC27" class="blob-code blob-code-inner js-file-line">      if (address&lt;16) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-i2cscanner-ino-LC28" class="blob-code blob-code-inner js-file-line">        Serial.print(&quot;0&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-i2cscanner-ino-LC29" class="blob-code blob-code-inner js-file-line">      }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-i2cscanner-ino-LC30" class="blob-code blob-code-inner js-file-line">      Serial.println(address,HEX);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-i2cscanner-ino-LC31" class="blob-code blob-code-inner js-file-line">    }    </td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-i2cscanner-ino-LC32" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-i2cscanner-ino-LC33" class="blob-code blob-code-inner js-file-line">  if (nDevices == 0) {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-i2cscanner-ino-LC34" class="blob-code blob-code-inner js-file-line">    Serial.println(&quot;No I2C devices found\n&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-i2cscanner-ino-LC35" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-i2cscanner-ino-LC36" class="blob-code blob-code-inner js-file-line">  else {</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-i2cscanner-ino-LC37" class="blob-code blob-code-inner js-file-line">    Serial.println(&quot;done\n&quot;);</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-i2cscanner-ino-LC38" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-i2cscanner-ino-LC39" class="blob-code blob-code-inner js-file-line">  delay(5000);          </td>
        </tr>
        <tr>
          <td id="file-i2cscanner-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-i2cscanner-ino-LC40" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/8385c212d28d9117513030f78d543a59/raw/8603339f44c1f6e7556a3a9e1d471e5d10c82f72/i2cscanner.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/8385c212d28d9117513030f78d543a59#file-i2cscanner-ino" class="Link--inTextBlock">
          i2cscanner.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>Then, open the serial monitor and set the data rate to 115200. You should be presented with something like the following:</p>



<figure class="wp-block-image size-large"><a href="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp"><img loading="lazy" width="600" height="542" data-attachment-id="17146" data-permalink="https://tronixstuff.com/2025/04/14/tutorial-tca9548a-i2c-multiplexer-arduino/tca9548a_i2c_scanner_grande-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp" data-orig-size="600,542" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tca9548a_i2c_scanner_grande" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=600" src="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=600" alt="" class="wp-image-17146" srcset="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp 600w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=150 150w, https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=300 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></figure>



<p>As you can see, our scanner returned an address of 0x70, which matches the wiring described in the bus address table mentioned earlier. If you did not find success, unplug the Arduino from the computer and double-check your wiring &#8211; then try again.</p>



<p><strong>Controlling the bus selector</strong></p>



<p>Using the TCA9548A is your sketch is not complex at all, it only requires one step before using your I2C device as normal. That extra step is to instruct the TCA9548A to use one of the eight buses that it controls.&nbsp;</p>



<p>To do this, we send a byte of data to the TCA9548A&#8217;s bus register which represents which of the eight buses we want to use. Each bit of the byte is used to turn the bus on or off, with the MSB (most significant bit) for bus 7, and the LSB (least significant bit) for bus 0.</p>



<p>For example, if you sent:</p>



<pre class="wp-block-preformatted">0b00000001 (in binary) or 0 in decimal</pre>



<p>&#8230; this would activate bus zero.&nbsp;</p>



<p>Or if you sent:</p>



<pre class="wp-block-preformatted">0b00010000 (in binary)</pre>



<p>&#8230; this would activate bus five.&nbsp;</p>



<p>Once you select a bus, the TCA9548A channels all data in and out of the bus to the Arduino on the selected bus. You only need to send the bus selection data when you want to change buses. We&#8217;ll demonstrate that later.&nbsp;</p>



<p>So to make life easier, we can use a little function to easily select the required bus:</p>



<pre class="wp-block-preformatted">void TCA9548A(uint8_t bus)
{
 &nbsp;Wire.beginTransmission(0x70); &nbsp;// TCA9548A address is 0x70
 &nbsp;Wire.write(1 &lt;&lt; bus); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// send byte to select bus
 &nbsp;Wire.endTransmission();
}</pre>



<p>This function accepts a bus number and places a &#8220;1&#8221; in the TCA9548A&#8217;s bus register matching our requirements. Then, you simply slip this function right before needing to access a device on a particular I2C bus. For example, a device on bus 0:&nbsp;</p>



<pre class="wp-block-preformatted">TCA9548A(0);</pre>



<p>&nbsp;&#8230; or a device on bus 6:</p>



<pre class="wp-block-preformatted">TCA9548A(6);</pre>



<p><strong>A quick note about pull-up resistors</strong></p>



<p><em>You still need to use pull-up resistors on the eight I2C buses eminating from the TCA9548A. If you&#8217;re using an assembled module, such as our example devices &#8211; they will have the resistors &#8211; so don&#8217;t panic.</em></p>



<p><em>I</em><em>f not, check the data sheets for your devices to determine the appropriate pull-up resistors value. If this information isn&#8217;t available, try 10k0 resistors.</em></p>



<p><em></em><strong>Controlling our first device</strong></p>



<p>Our first example device is the <a href="https://amzn.to/3G8StwI" target="_blank" rel="noreferrer noopener">tiny 0.49&#8243; OLED display</a>. If you haven&#8217;t seen this display before, <a href="https://tronixstuff.com/2019/10/15/a-tiny-tiny-0-49-64-x-32-graphic-i2c-oled-display-with-arduino/" target="_blank" rel="noreferrer noopener">click here for the tutorial</a>.</p>



<p>It is has four connections, which are wired as follows (OLED &#8212; TCA9548A/Arduino):</p>



<ul class="wp-block-list">
<li>GND to GND</li>



<li>Vcc to Arduino 3.3V</li>



<li>CL to TCA9548A SC0 (bus #0, clock pin)</li>



<li>DA to TCA9548A SD1 (bus #0, data pin)</li>
</ul>



<p>The OLED runs from 3.3V, so that&#8217;s why we&#8217;re powering it directly from the Arduino&#8217;s 3.3V pin.&nbsp;</p>



<p>Now, copy and upload this sketch to your Arduino:</p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist99088000" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-14201491-oled-tca9548a" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-text  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="14201491-oled-TCA9548A content, created by johnaboxall on 02:41AM on October 26, 2019."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="14201491-oled-TCA9548A">
        <tr>
          <td id="file-14201491-oled-tca9548a-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-14201491-oled-tca9548a-LC1" class="blob-code blob-code-inner js-file-line">#include &lt;Arduino.h&gt;</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-14201491-oled-tca9548a-LC2" class="blob-code blob-code-inner js-file-line">#include &lt;U8g2lib.h&gt;</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-14201491-oled-tca9548a-LC3" class="blob-code blob-code-inner js-file-line">#include &lt;Wire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-14201491-oled-tca9548a-LC4" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-14201491-oled-tca9548a-LC5" class="blob-code blob-code-inner js-file-line">void TCA9548A(uint8_t bus)</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-14201491-oled-tca9548a-LC6" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-14201491-oled-tca9548a-LC7" class="blob-code blob-code-inner js-file-line">  Wire.beginTransmission(0x70);  // TCA9548A address is 0x70</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-14201491-oled-tca9548a-LC8" class="blob-code blob-code-inner js-file-line">  Wire.write(1 &lt;&lt; bus);          // send byte to select bus</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-14201491-oled-tca9548a-LC9" class="blob-code blob-code-inner js-file-line">  Wire.endTransmission();</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-14201491-oled-tca9548a-LC10" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-14201491-oled-tca9548a-LC11" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-14201491-oled-tca9548a-LC12" class="blob-code blob-code-inner js-file-line">U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-14201491-oled-tca9548a-LC13" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-14201491-oled-tca9548a-LC14" class="blob-code blob-code-inner js-file-line">void setup() </td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-14201491-oled-tca9548a-LC15" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-14201491-oled-tca9548a-LC16" class="blob-code blob-code-inner js-file-line">  Wire.begin();</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-14201491-oled-tca9548a-LC17" class="blob-code blob-code-inner js-file-line">  u8g2.begin();</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-14201491-oled-tca9548a-LC18" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-14201491-oled-tca9548a-LC19" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-14201491-oled-tca9548a-LC20" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-14201491-oled-tca9548a-LC21" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-14201491-oled-tca9548a-LC22" class="blob-code blob-code-inner js-file-line">  TCA9548A(0); // tell the TCA9548A we want to use I2C bus number zero (to talk to the OLED)</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-14201491-oled-tca9548a-LC23" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-14201491-oled-tca9548a-LC24" class="blob-code blob-code-inner js-file-line">  // use the OLED as normal</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-14201491-oled-tca9548a-LC25" class="blob-code blob-code-inner js-file-line">  for (int a = 999; a &gt;= 0; &#8211;a)</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-14201491-oled-tca9548a-LC26" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-14201491-oled-tca9548a-LC27" class="blob-code blob-code-inner js-file-line">    u8g2.clearBuffer();          // clear the internal memory</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-14201491-oled-tca9548a-LC28" class="blob-code blob-code-inner js-file-line">    u8g2.setFont(u8g2_font_inb24_mr );  // choose a suitable font</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-14201491-oled-tca9548a-LC29" class="blob-code blob-code-inner js-file-line">    u8g2.setCursor(0, 24);</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-14201491-oled-tca9548a-LC30" class="blob-code blob-code-inner js-file-line">    u8g2.print(a);</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-14201491-oled-tca9548a-LC31" class="blob-code blob-code-inner js-file-line">    a = a &#8211; 47;</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-14201491-oled-tca9548a-LC32" class="blob-code blob-code-inner js-file-line">    u8g2.sendBuffer();          // transfer internal memory to the display</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-14201491-oled-tca9548a-LC33" class="blob-code blob-code-inner js-file-line">    delay(100);</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-14201491-oled-tca9548a-LC34" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-14201491-oled-tca9548a-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-14201491-oled-tca9548a-LC35" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/653cc12aa66571b6490610c20ac3b7c8/raw/c7b6b6ffc906d3475d12ff01c1d99c1cc8032201/14201491-oled-TCA9548A" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/653cc12aa66571b6490610c20ac3b7c8#file-14201491-oled-tca9548a" class="Link--inTextBlock">
          14201491-oled-TCA9548A
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>After a moment the OLED will display some numbers counting down in various amounts (<a href="https://www.youtube.com/watch?v=TarP-h92ShY" target="_blank" rel="noreferrer noopener">video</a>):</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="embed-youtube"><iframe title="Tutorial - TCA9548A 1-to-8 I2C Multiplexer Breakout with Arduino" width="500" height="281" src="https://www.youtube.com/embed/TarP-h92ShY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<p>So how did that work? We inserted our bus selection function at line 5 of the sketch, then called the function in at line 22 to tell the TCA9548A that we wanted to use I2C bus zero. Then the rest of the sketch used the OLED as normal. </p>



<p><strong>Controlling&nbsp;two devices</strong></p>



<p>Let&#8217;s add another device, a <a href="https://amzn.to/3RgubmD" target="_blank" rel="noreferrer noopener">BMP180 barometric pressure sensor module</a>. We&#8217;ll connect this to I2C bus number seven on the TCA5948A. There are four connections, which are wired as follows (BMP180 &#8212; TCA9548A/Arduino):</p>



<ul class="wp-block-list">
<li>GND to GND</li>



<li>Vcc to Arduino 3.3V</li>



<li>CL to TCA9548A SC0 (bus #7, clock pin)</li>



<li>DA to TCA9548A SD1 (bus #7, data pin)</li>
</ul>



<p>Now, copy and upload <a href="https://gist.githubusercontent.com/johnaboxall/04f5b93ce722627d260675d9d9e1c495/raw/8cfca2973fc7d32780eb59b04e6233f0dbd76ba7/TCA9548A3.ino" target="_blank" rel="noreferrer noopener">this sketch</a> to the Arduino, and after a moment the OLED will display the ambient temperature from the BMP180 in whole degrees Celsius. </p>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<style>.gist table { margin-bottom: 0; }</style><div style="tab-size: 8" id="gist137400701" class="gist">
    <div class="gist-file" translate="no" data-color-mode="light" data-light-theme="light">
      <div class="gist-data">
        <div class="js-gist-file-update-container js-task-list-container">
  <div id="file-tca9548a3-ino" class="file my-2">
    
    <div itemprop="text"
      class="Box-body p-0 blob-wrapper data type-c  "
      style="overflow: auto" tabindex="0" role="region"
      aria-label="TCA9548A3.ino content, created by johnaboxall on 11:11PM on April 13, 2025."
    >

        
<div class="js-check-hidden-unicode js-blob-code-container blob-code-content">

  <template class="js-file-alert-template">
  <div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
    <span>
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      <a class="Link--inTextBlock" href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a>
    </span>


  <div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters
</a>
</div>
</div></template>
<template class="js-line-alert-template">
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>
</svg>
</span></template>

  <table data-hpc class="highlight tab-size js-file-line-container" data-tab-size="4" data-paste-markdown-skip data-tagsearch-path="TCA9548A3.ino">
        <tr>
          <td id="file-tca9548a3-ino-L1" class="blob-num js-line-number js-blob-rnum" data-line-number="1"></td>
          <td id="file-tca9548a3-ino-LC1" class="blob-code blob-code-inner js-file-line">#include &lt;Arduino.h&gt;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L2" class="blob-num js-line-number js-blob-rnum" data-line-number="2"></td>
          <td id="file-tca9548a3-ino-LC2" class="blob-code blob-code-inner js-file-line">#include &lt;U8g2lib.h&gt;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L3" class="blob-num js-line-number js-blob-rnum" data-line-number="3"></td>
          <td id="file-tca9548a3-ino-LC3" class="blob-code blob-code-inner js-file-line">#include &lt;Adafruit_BMP085.h&gt;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L4" class="blob-num js-line-number js-blob-rnum" data-line-number="4"></td>
          <td id="file-tca9548a3-ino-LC4" class="blob-code blob-code-inner js-file-line">#include &lt;Wire.h&gt;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L5" class="blob-num js-line-number js-blob-rnum" data-line-number="5"></td>
          <td id="file-tca9548a3-ino-LC5" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L6" class="blob-num js-line-number js-blob-rnum" data-line-number="6"></td>
          <td id="file-tca9548a3-ino-LC6" class="blob-code blob-code-inner js-file-line">U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L7" class="blob-num js-line-number js-blob-rnum" data-line-number="7"></td>
          <td id="file-tca9548a3-ino-LC7" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L8" class="blob-num js-line-number js-blob-rnum" data-line-number="8"></td>
          <td id="file-tca9548a3-ino-LC8" class="blob-code blob-code-inner js-file-line">Adafruit_BMP085 bmp;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L9" class="blob-num js-line-number js-blob-rnum" data-line-number="9"></td>
          <td id="file-tca9548a3-ino-LC9" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L10" class="blob-num js-line-number js-blob-rnum" data-line-number="10"></td>
          <td id="file-tca9548a3-ino-LC10" class="blob-code blob-code-inner js-file-line">int temperature;</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L11" class="blob-num js-line-number js-blob-rnum" data-line-number="11"></td>
          <td id="file-tca9548a3-ino-LC11" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L12" class="blob-num js-line-number js-blob-rnum" data-line-number="12"></td>
          <td id="file-tca9548a3-ino-LC12" class="blob-code blob-code-inner js-file-line">void TCA9548A(uint8_t bus)</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L13" class="blob-num js-line-number js-blob-rnum" data-line-number="13"></td>
          <td id="file-tca9548a3-ino-LC13" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L14" class="blob-num js-line-number js-blob-rnum" data-line-number="14"></td>
          <td id="file-tca9548a3-ino-LC14" class="blob-code blob-code-inner js-file-line">  Wire.beginTransmission(0x70);  // TCA9548A address is 0x70</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L15" class="blob-num js-line-number js-blob-rnum" data-line-number="15"></td>
          <td id="file-tca9548a3-ino-LC15" class="blob-code blob-code-inner js-file-line">  Wire.write(1 &lt;&lt; bus);          // send byte to select bus</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L16" class="blob-num js-line-number js-blob-rnum" data-line-number="16"></td>
          <td id="file-tca9548a3-ino-LC16" class="blob-code blob-code-inner js-file-line">  Wire.endTransmission();</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L17" class="blob-num js-line-number js-blob-rnum" data-line-number="17"></td>
          <td id="file-tca9548a3-ino-LC17" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L18" class="blob-num js-line-number js-blob-rnum" data-line-number="18"></td>
          <td id="file-tca9548a3-ino-LC18" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L19" class="blob-num js-line-number js-blob-rnum" data-line-number="19"></td>
          <td id="file-tca9548a3-ino-LC19" class="blob-code blob-code-inner js-file-line">void setup()</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L20" class="blob-num js-line-number js-blob-rnum" data-line-number="20"></td>
          <td id="file-tca9548a3-ino-LC20" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L21" class="blob-num js-line-number js-blob-rnum" data-line-number="21"></td>
          <td id="file-tca9548a3-ino-LC21" class="blob-code blob-code-inner js-file-line">  Wire.begin();</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L22" class="blob-num js-line-number js-blob-rnum" data-line-number="22"></td>
          <td id="file-tca9548a3-ino-LC22" class="blob-code blob-code-inner js-file-line">  u8g2.begin();</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L23" class="blob-num js-line-number js-blob-rnum" data-line-number="23"></td>
          <td id="file-tca9548a3-ino-LC23" class="blob-code blob-code-inner js-file-line">  TCA9548A(7);    // select I2C bus 7 for the BMP180</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L24" class="blob-num js-line-number js-blob-rnum" data-line-number="24"></td>
          <td id="file-tca9548a3-ino-LC24" class="blob-code blob-code-inner js-file-line">  if (!bmp.begin())</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L25" class="blob-num js-line-number js-blob-rnum" data-line-number="25"></td>
          <td id="file-tca9548a3-ino-LC25" class="blob-code blob-code-inner js-file-line">  {</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L26" class="blob-num js-line-number js-blob-rnum" data-line-number="26"></td>
          <td id="file-tca9548a3-ino-LC26" class="blob-code blob-code-inner js-file-line">    Serial.println(&quot;Could not find a valid BMP085 sensor, check wiring!&quot;);</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L27" class="blob-num js-line-number js-blob-rnum" data-line-number="27"></td>
          <td id="file-tca9548a3-ino-LC27" class="blob-code blob-code-inner js-file-line">    while (1) {}</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L28" class="blob-num js-line-number js-blob-rnum" data-line-number="28"></td>
          <td id="file-tca9548a3-ino-LC28" class="blob-code blob-code-inner js-file-line">  }</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L29" class="blob-num js-line-number js-blob-rnum" data-line-number="29"></td>
          <td id="file-tca9548a3-ino-LC29" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L30" class="blob-num js-line-number js-blob-rnum" data-line-number="30"></td>
          <td id="file-tca9548a3-ino-LC30" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L31" class="blob-num js-line-number js-blob-rnum" data-line-number="31"></td>
          <td id="file-tca9548a3-ino-LC31" class="blob-code blob-code-inner js-file-line">void loop()</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L32" class="blob-num js-line-number js-blob-rnum" data-line-number="32"></td>
          <td id="file-tca9548a3-ino-LC32" class="blob-code blob-code-inner js-file-line">{</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L33" class="blob-num js-line-number js-blob-rnum" data-line-number="33"></td>
          <td id="file-tca9548a3-ino-LC33" class="blob-code blob-code-inner js-file-line">  // first, get the temperature from the BMP180</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L34" class="blob-num js-line-number js-blob-rnum" data-line-number="34"></td>
          <td id="file-tca9548a3-ino-LC34" class="blob-code blob-code-inner js-file-line">  TCA9548A(7);    // select I2C bus 7 for the BMP180</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L35" class="blob-num js-line-number js-blob-rnum" data-line-number="35"></td>
          <td id="file-tca9548a3-ino-LC35" class="blob-code blob-code-inner js-file-line">  temperature = int(bmp.readTemperature());</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L36" class="blob-num js-line-number js-blob-rnum" data-line-number="36"></td>
          <td id="file-tca9548a3-ino-LC36" class="blob-code blob-code-inner js-file-line">
</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L37" class="blob-num js-line-number js-blob-rnum" data-line-number="37"></td>
          <td id="file-tca9548a3-ino-LC37" class="blob-code blob-code-inner js-file-line">  // next, display the temperature on the OLED</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L38" class="blob-num js-line-number js-blob-rnum" data-line-number="38"></td>
          <td id="file-tca9548a3-ino-LC38" class="blob-code blob-code-inner js-file-line">  TCA9548A(0); // select I2C bus 0 for the OLED</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L39" class="blob-num js-line-number js-blob-rnum" data-line-number="39"></td>
          <td id="file-tca9548a3-ino-LC39" class="blob-code blob-code-inner js-file-line">  u8g2.clearBuffer();          // clear the internal memory</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L40" class="blob-num js-line-number js-blob-rnum" data-line-number="40"></td>
          <td id="file-tca9548a3-ino-LC40" class="blob-code blob-code-inner js-file-line">  u8g2.setFont(u8g2_font_inb24_mr );  // choose a suitable font</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L41" class="blob-num js-line-number js-blob-rnum" data-line-number="41"></td>
          <td id="file-tca9548a3-ino-LC41" class="blob-code blob-code-inner js-file-line">  u8g2.setCursor(0, 24);</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L42" class="blob-num js-line-number js-blob-rnum" data-line-number="42"></td>
          <td id="file-tca9548a3-ino-LC42" class="blob-code blob-code-inner js-file-line">  u8g2.print(temperature);</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L43" class="blob-num js-line-number js-blob-rnum" data-line-number="43"></td>
          <td id="file-tca9548a3-ino-LC43" class="blob-code blob-code-inner js-file-line">  u8g2.sendBuffer();</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L44" class="blob-num js-line-number js-blob-rnum" data-line-number="44"></td>
          <td id="file-tca9548a3-ino-LC44" class="blob-code blob-code-inner js-file-line">  delay(100);</td>
        </tr>
        <tr>
          <td id="file-tca9548a3-ino-L45" class="blob-num js-line-number js-blob-rnum" data-line-number="45"></td>
          <td id="file-tca9548a3-ino-LC45" class="blob-code blob-code-inner js-file-line">}</td>
        </tr>
  </table>
</div>


    </div>

  </div>
</div>

      </div>
      <div class="gist-meta">
        <a href="https://gist.github.com/johnaboxall/04f5b93ce722627d260675d9d9e1c495/raw/8cfca2973fc7d32780eb59b04e6233f0dbd76ba7/TCA9548A3.ino" style="float:right" class="Link--inTextBlock">view raw</a>
        <a href="https://gist.github.com/johnaboxall/04f5b93ce722627d260675d9d9e1c495#file-tca9548a3-ino" class="Link--inTextBlock">
          TCA9548A3.ino
        </a>
        hosted with &#10084; by <a class="Link--inTextBlock" href="https://github.com">GitHub</a>
      </div>
    </div>
</div>

</div></figure>



<p>This is demonstrated in the following video (finger is placed on the BMP180 for force a rise in temperature)(<a href="https://www.youtube.com/watch?v=3zsFPGvleIA" target="_blank" rel="noreferrer noopener">video</a>):</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="embed-youtube"><iframe title="Tutorial - TCA9548A 1-to-8 I2C Multiplexer Breakout with Arduino and two I2C devices" width="500" height="281" src="https://www.youtube.com/embed/3zsFPGvleIA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<p>So how did that work? We set up the libraries and required code for the OLED, BMP180 and TCA5948A as usual.&nbsp;</p>



<p>We need to intialise the BMP180, so this is done at line 24 &#8211; where we select the I2C bus 7 before initiating the BMP180.</p>



<p>The the sketch operates. On line 34 we again request I2C bus 7 from the TCA9548A, then get the temperature from the BMP180.</p>



<p>On line 38 we request I2C bus 0 from the TCA9548A, and then display the temperature on the OLED. Then repeat.</p>



<p><strong></strong><strong>A quick note about&nbsp;the reset pin</strong></p>



<p>More advanced users will be happy to know they can reset the TCA9548A status, to recover from a bus-fault condition. To do this, simply drop the RESET pin LOW (that is, connect it to GND).&nbsp;</p>



<p><strong>Where to from here?&nbsp;</strong></p>



<p>You can now understand through our worked example how easy it is to use the TCA9548A and access eight secondary I2C buses through the one bus from your Arduino. Don&#8217;t forget that the TCA9548A also does double-duty as a level converter, thereby increasing its value to you.&nbsp;</p>



<p>I hope you enjoyed reading about these useful TCA9548A boards. To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x – <a href="https://twitter.com/tronixstuff" target="_blank" rel="noreferrer noopener">@tronixstuff</a>.</p>



<p>If you find this sort of thing interesting, please consider <a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>:</p>



<figure class="wp-block-image size-full"><a href="https://amzn.to/42pngN1" target="_blank" rel=" noreferrer noopener"><img data-attachment-id="17129" data-permalink="https://tronixstuff.com/tutorials/screenshot-2025-04-13-113628/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" data-orig-size="885,392" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screenshot 2025-04-13 113628" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png?w=885" src="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" alt="" class="wp-image-17129" /></a></figure>



<p><strong>And, as always, have fun and make something</strong>.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">17135</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp" medium="image">
			<media:title type="html">tca9548a_breadboard_ready_large</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_diagram.jpg?w=591" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_large.webp?w=424" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_2_large.webp?w=407" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_breadboard_ready_3_large.webp?w=387" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_address_table_large.webp?w=480" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/tca9548a_i2c_scanner_grande.webp?w=600" medium="image" />

		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/screenshot-2025-04-13-113628.png" medium="image" />
	</item>
		<item>
		<title>Hewlett-Packard 5082-7415 LED Display from 1976</title>
		<link>https://tronixstuff.com/2025/04/11/hewlett-packard-5082-7415-led-display-from-1976/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Fri, 11 Apr 2025 07:20:52 +0000</pubDate>
				<category><![CDATA[5082-7415]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vintage]]></category>
		<category><![CDATA[5082]]></category>
		<category><![CDATA[calculator]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[hewlett]]></category>
		<category><![CDATA[hp]]></category>
		<category><![CDATA[packard]]></category>
		<category><![CDATA[QDSP6064]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=8746</guid>

					<description><![CDATA[In this article we examine a five digit, seven-segment LED display from Hewlett-Packard, the 5082-7415: We realise they&#8217;re most likely now pure unobtanium, but we like some old display p0rn so here you go. 2025 update &#8211; Tronixlabs in Australia has a limited quantity of new, old-stock four-digit QDSP6064 displays. Email john at tronixlabs dot com [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article we examine a five digit, seven-segment LED display from Hewlett-Packard, the 5082-7415:</p>
<p><img loading="lazy" data-attachment-id="16213" data-permalink="https://tronixstuff.com/2025/04/11/hewlett-packard-5082-7415-led-display-from-1976/5082-7415-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg" data-orig-size="300,183" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="5082-7415" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg?w=300" class="size-full wp-image-16213 alignleft" src="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg" alt="5082-7415" width="300" height="183" srcset="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg 300w, https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg?w=150&amp;h=92 150w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p><img loading="lazy" data-attachment-id="16212" data-permalink="https://tronixstuff.com/2025/04/11/hewlett-packard-5082-7415-led-display-from-1976/5082-7415rear-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg" data-orig-size="300,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="5082-7415rear" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg?w=300" class="alignnone size-full wp-image-16212" src="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg" alt="5082-7415rear" width="300" height="163" srcset="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg 300w, https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg?w=150&amp;h=82 150w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>We realise they&#8217;re most likely now pure unobtanium, but we like some old display p0rn so here you go.</p>
<p><strong>2025 update &#8211; </strong>Tronixlabs in Australia has a limited quantity of new, old-stock four-digit QDSP6064 displays. Email john at tronixlabs dot com for more information.</p>
<p>According to the data sheet (<a href="https://www.datasheets360.com/pdf/-8099882859277639708">HP 5082-series.pdf</a>) and other research this was available for a period of time around 1976 and used with other 5082-series modules in other HP products. Such as the Hewlett-Packard 3x series of calculators, for example:</p>
<p><img class="aligncenter" title="(C) David J Hicks, http://www.hpmuseum.org/" src="https://i0.wp.com/www.hpmuseum.org/31.jpg" alt="" width="199" height="379" /></p>
<p>Using the display is very easy &#8211; kudos to the engineers at HP for making a simple design that could be reusable in many applications. The 5082-7415 is a common-cathode unit and wiring is very simple &#8211; there are the usual eight anodes for segments a~f and the decimal point, and the five cathodes.</p>
<p>As this module isn&#8217;t too easily replaceable, I was very conservative with the power supply &#8211; feeding just under 1.6V at 10mA to each of the anode pins. A quick test proved very promising:</p>
<p style="text-align: center"><img loading="lazy" data-attachment-id="16210" data-permalink="https://tronixstuff.com/2025/04/11/hewlett-packard-5082-7415-led-display-from-1976/firsttest-3/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg" data-orig-size="300,172" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="firsttest" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg?w=300" class="alignnone size-full wp-image-16210" src="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg" alt="firsttest" width="300" height="172" srcset="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg 300w, https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg?w=150&amp;h=86 150w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>Excellent &#8211; it worked! But now to get it displaying some sort of interesting way. Using the following hardware&#8230;</p>
<ul>
<li>an <a href="https://amzn.to/3G64Zgi" target="_blank" rel="noopener">Arduino-compatible board</a></li>
<li>Two <a href="https://amzn.to/4j5FNVK" target="_blank" rel="noopener">74HC595 shift registers</a></li>
<li>Eight 560 ohm <a href="https://amzn.to/3G5w8A8" target="_blank" rel="noopener">resistors</a></li>
<li>Five 1k ohm <a href="https://amzn.to/3G5w8A8" target="_blank" rel="noopener">resistors</a></li>
<li>Five BC548 <a href="https://amzn.to/4jNjmVB" target="_blank" rel="noopener">transistors</a></li>
<li>A large <a href="https://amzn.to/42E99om" target="_blank" rel="noopener">solderless breadboard</a> and plenty of wires</li>
</ul>
<p>Don&#8217;t forget to use the data sheet (<a href="https://www.datasheets360.com/pdf/-8099882859277639708">HP 5082-series.pdf</a>). You don&#8217;t have to use Arduino &#8211; any microcontroller with the appropriate I/O can take care of this.</p>
<p>Here is a simple Arduino sketch that scrolls through the digits with and then without the decimal point:</p>
<pre class="lang:arduino decode:true ">// Arduino sketch to demonstrate HP 5082-7415 LED Display unit
// John Boxall, April 2012
int clockPin=6;
int latchPin=7;
int dataPin=8;
// array for cathodes - sent to second shift register
byte digits[]={
  B10000000,
  B01000000,
  B00100000,
  B00010000,
  B00001000,
  B11111000}; // use digits[6] to turn all on
// array for anodes (to display 0~0) - sent to first shift register
byte numbers[]={
  B11111100,
  B01100000,
  B11011010,
  B11110010,
  B01100110,
  B10110110,
  B10111110,
  B11100000,
  B11111110,
  B11110110};
void setup()
{
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
void loop()
{
  int i;
  for ( i=0 ; i&lt;10; i++ )
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, digits[6]);
    shiftOut(dataPin, clockPin, LSBFIRST, numbers[i]);
    digitalWrite(latchPin, HIGH);
    delay(250);
  }
  // now repeat with decimal point
  for ( i=0 ; i&lt;10; i++ )
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, digits[6]);
    shiftOut(dataPin, clockPin, LSBFIRST, numbers[i]+1);
    digitalWrite(latchPin, HIGH);
    delay(250);
  }
}</pre>
<p>And the results:</p>
<div class="embed-youtube"><iframe title="Hewlett-Packard 5082-7415 LED display demonstration" width="500" height="281" src="https://www.youtube.com/embed/izDoIpxYRVc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>Now for something more useful. Here is a function that sends a single digit to a position on the display with the option of turning the decimal point on or off:</p>
<pre class="lang:arduino decode:true ">void displayDigit(int value, int posit, boolean decPoint)
// displays integer value at digit position posit with decimal point on/off
{
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, LSBFIRST, digits[posit]);
 if (decPoint==true)
 {
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]+1); 
 } 
 else 
 {
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]); 
 }
 digitalWrite(latchPin, HIGH);
}</pre>
<p>So if you wanted to display the number three in the fourth digit, with the decimal point &#8211; use</p>
<pre class="lang:arduino decode:true ">displayDigit(3,3,true);</pre>
<p>with the following result:</p>
<p style="text-align: center"><img loading="lazy" data-attachment-id="16209" data-permalink="https://tronixstuff.com/2025/04/11/hewlett-packard-5082-7415-led-display-from-1976/three-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg" data-orig-size="300,146" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="three" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg?w=300" class="alignnone size-full wp-image-16209" src="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg" alt="three" width="300" height="146" srcset="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg 300w, https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg?w=150&amp;h=73 150w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>We make use of the <em>displayDigit() </em>function in our next sketch. We introduce a new function:</p>
<pre class="lang:arduino decode:true ">displayInteger(number,cycles);</pre>
<p>It accepts a long integer between zero and 99999 (number) and displays it on the module for <em>cycles</em> times:</p>
<pre class="lang:arduino decode:true ">// Arduino sketch to demonstrate HP 5082-7415 LED Display unit
// Displays numbers on request
// John Boxall, April 2012
int clockPin=6;
int latchPin=7;
int dataPin=8;
// array for cathodes - sent to second shift register
byte digits[]={
 B10000000,
 B01000000,
 B00100000,
 B00010000,
 B00001000,
 B11111000}; // use digits[6] to turn all on
// array for anodes (to display 0~0) - sent to first shift register
byte numbers[]={
 B11111100,
 B01100000,
 B11011010,
 B11110010,
 B01100110,
 B10110110,
 B10111110,
 B11100000,
 B11111110,
 B11110110};
void setup()
{
 pinMode(clockPin, OUTPUT);
 pinMode(latchPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
 randomSeed(analogRead(0));
}
void clearDisplay()
// turns off all digits
{
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, LSBFIRST, 0);
 shiftOut(dataPin, clockPin, LSBFIRST, 0); 
 digitalWrite(latchPin, HIGH);
}
void displayDigit(int value, int posit, boolean decPoint)
// displays integer value at digit position posit with decimal point on/off
{
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, LSBFIRST, digits[posit]);
 if (decPoint==true)
 {
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]+1); 
 } 
 else 
 {
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]); 
 }
 digitalWrite(latchPin, HIGH);
}
void displayInteger(long number,int cycles)
// displays a number 'number' on the HP display. 
{
 long i,j,k,l,z;
 float f;
 clearDisplay();
 for (z=0; z
void loop()
{
 long l2;
 l2=random(0,100001);
 displayInteger(l2,400);
}</pre>
<p>For demonstration purposes the sketch displays random numbers, as shown in the video below:</p>
<div class="embed-youtube"><iframe title="Hewlett-Packard 5082-7415 LED Display demonstration" width="500" height="281" src="https://www.youtube.com/embed/_6PICPN_vWE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p><em><strong>Update &#8211; four-digit versions&#8230;</strong></em></p>
<p>They worked very nicely and can be driven in the same method as the 5082-7415s described earlier. In the following video we have run the same sketches with the new displays:</p>
<div class="embed-youtube"><iframe title="Hewlett-Packard QDSP-6064 LED Display Modules" width="500" height="281" src="https://www.youtube.com/embed/8qcVixOZoT4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>In the meanwhile, I hope you found this article of interest. Thanks to the <a href="http://www.decadecounter.com/vta/articleview.php?item=596" target="_blank" rel="noopener">Vintage Technology Association</a> website and the <a href="http://www.hpmuseum.org/" target="_blank" rel="noopener">Museum of HP Calculators</a> for background information.</p>
<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x – <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>
<p>I hope you enjoyed reading about the displays. If you find this sort of thing interesting, please consider <a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>
<p>And as always, have fun and make something.</p>
<div id="jp-post-flair" class="sharedaddy sd-like-enabled sd-sharing-enabled">
<div class="sharedaddy sd-sharing-enabled"></div>
</div>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">15897</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415.jpg" medium="image">
			<media:title type="html">5082-7415</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415-1.jpg" medium="image">
			<media:title type="html">5082-7415</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2012/04/5082-7415rear-1.jpg" medium="image">
			<media:title type="html">5082-7415rear</media:title>
		</media:content>

		<media:content url="http://www.hpmuseum.org/31.jpg" medium="image">
			<media:title type="html">(C) David J Hicks, http://www.hpmuseum.org/</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2012/04/firsttest-1.jpg" medium="image">
			<media:title type="html">firsttest</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2012/04/three-1.jpg" medium="image">
			<media:title type="html">three</media:title>
		</media:content>
	</item>
		<item>
		<title>Australian Electronics &#8211; David Jones interviews Colin Mitchell</title>
		<link>https://tronixstuff.com/2025/04/11/australian-electronics-david-jones-interviews-colin-mitchell/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Fri, 11 Apr 2025 07:05:58 +0000</pubDate>
				<category><![CDATA[australia]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[talking electronics]]></category>
		<category><![CDATA[australian]]></category>
		<category><![CDATA[colin]]></category>
		<category><![CDATA[dave]]></category>
		<category><![CDATA[eevblog]]></category>
		<category><![CDATA[industry]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[jones]]></category>
		<category><![CDATA[kits]]></category>
		<category><![CDATA[mitchell]]></category>
		<category><![CDATA[talking]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=8938</guid>

					<description><![CDATA[In this post I would like to share a series of interviews conducted by Dave Jones from eevblog.com. Dave interviews Colin Mitchell from Talking Electronics. Throughout the 1980s and onwards, Colin published a range of electronics magazines, tutorials and a plethora of electronics kits &#8211; of which many are still available today. Tens of thousands of Australians [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: left">In this post I would like to share a series of interviews conducted by Dave Jones from <a href="http://www.eevblog.com" target="_blank" rel="noopener">eevblog.com</a>.</p>
<p style="text-align: left">Dave interviews Colin Mitchell from <a href="http://www.talkingelectronics.com/te_interactive_index.html" target="_blank" rel="noopener">Talking Electronics</a>. Throughout the 1980s and onwards, Colin published a range of electronics magazines, tutorials and a plethora of electronics kits &#8211; of which many are still <a href="http://www.talkingelectronics.com/kits/KitsFrontice.html" target="_blank" rel="noopener">available today</a>.</p>
<p style="text-align: left">Tens of thousands of Australians were great fans of the TE products, and longed for their range of kits and products.  We hope you enjoy these interviews, and if not &#8211; stay tuned for upcoming articles.</p>
<p style="text-align: left">
<div class="embed-youtube"><iframe title="EEVblog #280-1 - Talking Electronics - History - Part 1 of 5" width="500" height="281" src="https://www.youtube.com/embed/kXWRLNq8OCU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<div class="embed-youtube"><iframe title="EEVblog #280-2 - Talking Electronics - America - Part 2 of 5" width="500" height="281" src="https://www.youtube.com/embed/oyryds71p44?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<div class="embed-youtube"><iframe title="EEVblog #280-3 - Talking Electronics - FM Bug Kits - Part 3 of 5" width="500" height="281" src="https://www.youtube.com/embed/52tafTy2q_Q?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<div class="embed-youtube"><iframe title="EEVblog #280-4 - Talking Electronics - The Internet And Learning - Part 4 of 5" width="500" height="281" src="https://www.youtube.com/embed/o0bkyAntDHo?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<div class="embed-youtube"><iframe title="EEVblog #280-5 - Talking Electronics - Old Hardware - Part 5 of 5" width="500" height="281" src="https://www.youtube.com/embed/WzCVyOnota8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p style="text-align: left">Once again, thanks to <a href="http://www.eevblog.com" target="_blank" rel="noopener">Dave Jones</a> and of course Colin Mitchell from <a href="http://talkingelectronics.com/" target="_blank" rel="noopener">Talking Electronics</a> for their interview and various insights.</p>
<p><strong>2020 Update</strong></p>
<p>Colin is still firing on all cylinders, and gives another interview about his Talking Electronics empire.</p>
<div class="embed-youtube"><iframe title="Talking Electronics - A conversation with Colin Mitchell" width="500" height="281" src="https://www.youtube.com/embed/u5c8FRoYDQw?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x – <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>
<p>If you find this sort of thing interesting, please consider <a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>
<p>And as always, have fun and make something.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">15901</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2025/04/colin.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2025/04/colin.jpg" medium="image">
			<media:title type="html">colin</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial &#8211; LM3914 Dot/Bar Display Driver IC</title>
		<link>https://tronixstuff.com/2025/04/10/tutorial-lm3914-dotbar-display-driver-ic/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Thu, 10 Apr 2025 01:59:15 +0000</pubDate>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[LM3914]]></category>
		<category><![CDATA[TI]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[voltmeter]]></category>
		<category><![CDATA[bar]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[dot]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[IC]]></category>
		<category><![CDATA[level]]></category>
		<category><![CDATA[LM3915]]></category>
		<category><![CDATA[LM3916]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=12062</guid>

					<description><![CDATA[This is the first of two tutorials that will examine the LM391x series of LED driver ICs. In this first tutorial we cover the LM3914, and the second covers the LM3915. The goal of these tutorials is to have you using the parts in a small amount of time and experiment with your driver ICs, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>This is the first of two tutorials that will examine the LM391x series of LED driver ICs. In this first tutorial we cover the <a href="https://amzn.to/42aXRbi" target="_blank" rel="noreferrer noopener">LM3914</a>, and the second covers the <a href="https://tronixstuff.com/2013/12/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/">LM3915</a>. The goal of these tutorials is to have you using the parts in a small amount of time and experiment with your driver ICs, from which point you can research further into their theory and application.</p>



<p>Although these parts have been around for many years, the LM3914 in particular is still quite popular. It offers a simple way to display a linear voltage level using one or more groups of ten LEDs with a minimum of fuss.</p>



<p>With a variety of external parts or circuitry these LEDs can then represent all sorts of data, or just blink for your amusement. We&#8217;ll run through a few example circuits that you can use in your own projects and hopefully give you some ideas for the future. Originally by National Semiconductor, the LM391X series is now handled by Texas Instruments, and the usual off-brand versions are also prevalent.</p>



<figure class="wp-block-image"><a href="https://amzn.to/42aXRbi" target="_blank" rel=" noreferrer noopener"><img data-attachment-id="16091" data-permalink="https://tronixstuff.com/2025/04/10/tutorial-lm3914-dotbar-display-driver-ic/lm3914-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914.jpg" data-orig-size="500,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1379081567&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;80&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="LM3914" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914.jpg" alt="LM3914 from PMD Way" class="wp-image-16091" /></a></figure>



<p><em><strong>Getting Started</strong></em></p>



<p>You will need the <a href="https://tronixstuff.com/wp-content/uploads/2013/08/LM3914-data-sheet.pdf">LM3914 data sheet</a>, so please download that and keep it as a reference. So &#8211; back to basics. The LM3914 controls ten LEDs. It controls the current through the LEDs with the use of only one resistor, and the LEDs can appear in a bar graph or single &#8216;dot&#8217; when in use. The LM3914 contains a ten-stage voltage divider, each stage when reached will illuminate the matching LED (and those below it in level meter mode).</p>



<p>Let&#8217;s consider the most basic of examples (from page two of the data sheet) &#8211; a voltmeter with a range of 0~5V.</p>



<p>The Vled rail is also connected to the supply voltage in our example. Pin 9 controls the bar/dot display mode &#8211; with it connected to pin 3 the LEDs will operate in bar graph mode, leave it open for dot mode.</p>



<p>The 2.2uF capacitor is required only when &#8220;leads to the LED supply are 6″ or longer&#8221;. We&#8217;ve hooked up the circuit above, and created a 0~5V DC source via a 10kΩ potentiometer with a multimeter to show the voltage &#8211; in the following video you can see the results of this circuit in action, in both dot and bar graph mode:</p>


<div class="embed-youtube"><iframe title="LM3914 5V voltmeter demonstration" width="500" height="375" src="https://www.youtube.com/embed/Os_I5fNE6I4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p><em><strong>Customising the upper range and LED current</strong></em></p>



<p>Well that was exciting, however what if you want a different reference voltage? That is you want your display to have a range of 0~3 V DC? And how do you control the current flow through each LED? With maths and resistors. Consider the following formulae:</p>



<figure class="wp-block-image"><img data-attachment-id="16093" data-permalink="https://tronixstuff.com/2025/04/10/tutorial-lm3914-dotbar-display-driver-ic/lm3914_formulae-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914_formulae.jpg" data-orig-size="500,208" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="LM3914_formulae" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914_formulae.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914_formulae.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914_formulae.jpg" alt="LM3914 from PMD Way" class="wp-image-16093" /></figure>



<p>As you can see the LED current (Iled) is simple, our example is 12.5/1210 which returned 10.3 mA &#8211; and in real life 12.7 mA (resistor tolerance is going to affect the value of the calculations).</p>



<p>Now to calculate a new Ref Out voltage &#8211; for example &nbsp;we&#8217;ll shoot for a 3 V meter, and keep the same current for the LEDs. This requires solving for R2 in the equation above, which results with&nbsp;R2 = -R1 + 0.8R1V. Substituting the values &#8211; R2 = -1210 + 0.8 x 1210 x 3 gives a value of 1694Ω for R2. Not everyone will have the E48 resistor range, so try and get something as close as possible. We found a 1.8 kΩ for R2 and show the results in the following video:</p>


<div class="embed-youtube"><iframe title="LM3914 3V voltmeter demonstration" width="500" height="375" src="https://www.youtube.com/embed/DXORgX49Aog?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>You can of course have larger display range values, but a supply voltage of no more than 25 V will need to be equal to or greater than that value. E.g. if you want a 0~10 V display, the supply voltage must be &gt;= 10V DC.</p>



<p><em><strong>Creating custom ranges</strong></em></p>



<p>Now we&#8217;ll look at how to create &nbsp;a lower range limit, so you can have displays that (for example) can range from a non-zero positive value. For example, you want to display levels between 3 and 5V DC. From the previous section, you know how to set the upper limit, and setting the lower limit is simple &#8211; just apply the lower voltage to pin 4 (Rlo).</p>



<p>You can derive this using a resistor divider or other form of supply with a common GND. When creating such circuits, remember that the tolerance of the resistors used in the voltage dividers will have an affect on the accuracy. Some may wish to fit trimpots, which after alignment can be set permanently with a blob of glue.</p>



<p>Finally, for more reading on this topic &#8211; download and review the&nbsp;<a href="https://tronixstuff.com/wp-content/uploads/2013/08/snva584-LM3914-5V-monitor-circuit.pdf">TI application note</a>.</p>



<p><em><strong>Chaining multiple LM3914s</strong></em></p>



<p>Two or more LM3914s can be chained together to increase the number of LEDs used to display the levels over an expanded range. The circuitry is similar to using two independent units, except the REFout (pin 7) from the first LM3914 is fed to the REFlo (pin 4) of the second LM3914 &#8211; whose REFout is set as required for the upper range limit. Consider the following example schematic which gave a real-world range of 0~3.8V DC:</p>



<figure class="wp-block-image"><img data-attachment-id="16094" data-permalink="https://tronixstuff.com/2025/04/10/tutorial-lm3914-dotbar-display-driver-ic/9736776126_e17d056443_b/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/09/9736776126_e17d056443_b.jpg" data-orig-size="590,825" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="9736776126_e17d056443_b" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/09/9736776126_e17d056443_b.jpg?w=215" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/09/9736776126_e17d056443_b.jpg?w=590" src="https://tronixstuff.com/wp-content/uploads/2013/09/9736776126_e17d056443_b.jpg" alt="LM3914 from PMD Way" class="wp-image-16094" /></figure>



<p>The 20~22kΩ resistor is required if you&#8217;re using dot mode (see &#8220;Dot mode carry&#8221; in page ten of the data sheet). Moving on, the circuit above results with the following:</p>


<div class="embed-youtube"><iframe title="Using two LM3914s" width="500" height="375" src="https://www.youtube.com/embed/EtWdHdJBv8w?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p><em><strong>Where to from here?</strong></em></p>



<p>Now you can visually represent all sorts of low voltages for many purposes. There&#8217;s more example circuits and notes in the&nbsp;<a href="https://tronixstuff.com/wp-content/uploads/2013/08/LM3914-data-sheet.pdf">LM3914 data sheet</a>, so have a read through and delve deeper into the operation of the LM3914.</p>



<p>Furthermore Dave Jones from eevblog.com has made a great video whcih describes a practical application of the LM3914:</p>


<div class="embed-youtube"><iframe title="Designing a Li-Ion Battery Gauge with the LM3914 - EEVblog #204" width="500" height="281" src="https://www.youtube.com/embed/iIKGvHjDQHs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p><em><strong>Conclusion</strong></em></p>



<p>As always we hope you found this useful. Don&#8217;t forget to read the <a href="https://tronixstuff.com/2013/12/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/" target="_blank" rel="noopener">LM3915</a> tutorial as well.</p>



<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x &#8211; <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>



<p>I hope you enjoyed making this or at least reading about it. If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>



<p>And as always, have fun and make something.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">12062</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2013/09/98638-max7219_as1107.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/09/98638-max7219_as1107.jpg" medium="image">
			<media:title type="html">MAX7219_AS1107</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914.jpg" medium="image">
			<media:title type="html">LM3914 from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/09/lm3914_formulae.jpg" medium="image">
			<media:title type="html">LM3914 from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/09/9736776126_e17d056443_b.jpg" medium="image">
			<media:title type="html">LM3914 from PMD Way</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial &#8211; Ethernet Shields and Arduino</title>
		<link>https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 07:09:26 +0000</pubDate>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[DHT22]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[iot]]></category>
		<category><![CDATA[shield]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[weather]]></category>
		<category><![CDATA[website]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=14344</guid>

					<description><![CDATA[In this chapter we will introduce and examine the use of&#160;Ethernet&#160;networking with Arduino over local networks and the greater Internet. It will be assumed that you have a basic understanding of computer networking, such as the knowledge of how to connect computers to a hub/router with RJ45 cables, what an IP and MAC address is, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>In this chapter we will introduce and examine the use of&nbsp;Ethernet&nbsp;networking with Arduino over local networks and the greater Internet.</p>



<p>It will be assumed that you have a basic understanding of computer networking, such as the knowledge of how to connect computers to a hub/router with RJ45 cables, what an IP and MAC address is, and so on. Furthermore,&nbsp;<a href="http://en.wikipedia.org/wiki/Ethernet" target="_blank" rel="noopener">here is a good quick rundown</a>&nbsp;about&nbsp;Ethernet.</p>



<p><em><strong>Getting Started</strong></em></p>



<p>You will need an <a href="https://amzn.to/4lp0Wf4" target="_blank" rel="noreferrer noopener">Arduino Uno or compatible board</a> with an <a href="https://amzn.to/3YfE207" target="_blank" rel="noreferrer noopener">Ethernet shield</a> that uses the W5100 Ethernet controller IC (pretty much all of them):</p>



<figure class="wp-block-image"><a href="https://amzn.to/3YfE207" target="_blank" rel=" noreferrer noopener"><img data-attachment-id="16062" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/w5100-ethernet-shield-arduino-pmdway-1_1024x1024/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg" data-orig-size="903,680" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="w5100-ethernet-shield-arduino-pmdway-1_1024x1024" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg?w=903" src="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg" alt="W5100 Ethernet shield for Arduino from PMD Way" class="wp-image-16062" /></a></figure>



<p>Furthermore you will need to power the board via the external DC socket – the W5100 IC uses more current than the USB power can supply. A <a href="https://amzn.to/42pi7Vl" target="_blank" rel="noreferrer noopener">9V 1.5A plug pack/wall wart will suffice</a>.</p>



<p>Finally it does get hot – so be careful not to touch the W5100 after extended use. In case you’re not sure – this is the W5100 IC:</p>



<figure class="wp-block-image"><img data-attachment-id="16064" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/wiznet_w5100-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/wiznet_w5100.jpg" data-orig-size="240,240" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Wiznet_W5100" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/wiznet_w5100.jpg?w=240" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/wiznet_w5100.jpg?w=240" src="https://tronixstuff.com/wp-content/uploads/2013/12/wiznet_w5100.jpg" alt="W5100 Ethernet shield for Arduino from PMD Way" class="wp-image-16064" /></figure>



<p>Once you have your Ethernet-enabled Arduino, and have the external power connected &#8211; it&#8217;s a good idea to check it all works. Open the Arduino IDE and select&nbsp;<em>File &gt; Examples &gt; Ethernet &gt; Webserver</em>. This loads a simple sketch which will display data gathered from the analogue inputs on a web browser. However don’t upload it yet, it needs a slight modification.</p>



<p>You need to specify the&nbsp;<a href="http://en.wikipedia.org/wiki/IP_address" target="_blank" rel="noopener">IP address</a>&nbsp;of the Ethernet shield – which is done inside the sketch. This is simple, go to the line:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">IPAddress ip(192,168,1, 177);</pre>



<p>And alter it to match your own setup. For example, in my home the router’s IP address is 10.1.1.1, the printer is 10.1.1.50 and all PCs are below …50. So I will set my shield IP to 10.1.1.77 by altering the line to:</p>



<div id="crayon-529ee078398f9288475273">
<pre class="lang:arduino decode:true ">IPAddress ip(10,1,1,77);</pre>
<p>You also have the opportunity to change your&nbsp;<a href="http://en.wikipedia.org/wiki/MAC_address" target="_blank" rel="noopener">MAC address</a>. Each piece of networking equipment has a unique serial number to identify itself over a network, and this is normall hard-programmed into the equipments’ firmware. However with Arduino we can define the MAC address ourselves.</p>
<p>If you are running more than one Ethernet shield on your network, ensure they have different MAC addresses by altering the hexadecimal values in the line:</p>
</div>



<div id="crayon-529ee078398ea719877420">
<pre class="lang:arduino decode:true ">byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };</pre>
<p>However if you only have one shield just leave it be. There may be the very, very, statistically rare chance of having a MAC address the same as your existing hardware, so that would be another time to change it.</p>
<p>Once you have made your alterations, save and upload the sketch. Now open a web browser and navigate to the IP address you entered in the sketch, and you should be presented with something similar to the following:</p>
<figure><img loading="lazy" data-attachment-id="16065" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/arduino-webserver-example-sketch-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg" data-orig-size="408,228" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Arduino-webserver-example-sketch" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg?w=408" class="alignnone size-full wp-image-16065" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg" alt="Arduino-webserver-example-sketch" width="408" height="228" srcset="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg 408w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg?w=150&amp;h=84 150w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg?w=300&amp;h=168 300w" sizes="(max-width: 408px) 100vw, 408px"></figure><p style="text-align:center"></p>
<p>What&#8217;s happening? The Arduino has been programmed to offer a simple web page with the values measured by the analogue inputs. You can refresh the browser to get updated values.</p>
<p>At this point – please note that the Ethernet shields use digital pins 10~13, so you can’t use those for anything else. Some Arduino Ethernet shields may also have a microSD card socket, which also uses another digital pin – so check with the documentation to find out which one.</p>
<p>Nevertheless, now&nbsp;that we can see the&nbsp;Ethernet&nbsp;shield is working we can move on to something more useful. Let’s dissect the previous example in a simple way, and see how we can distribute and display more interesting data over the network. For reference, all of the&nbsp;Ethernet-related functions are handled by the&nbsp;<i>Ethernet</i>&nbsp;Arduino&nbsp;library. If you examine the previous sketch we just used, the section that will be of interest is:</p>
<pre class="lang:arduino decode:true "> for (int analogChannel = 0; analogChannel &lt; 6; analogChannel++) 
          {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("&lt;br /&gt;");       
          }
          client.println("&lt;/html&gt;");</pre>
<p>Hopefully this section of the sketch should be familiar – remember how we have used&nbsp;<em>serial.print();</em>&nbsp;in the past when sending data to the serial monitor box? Well now we can do the same thing, but sending data from our&nbsp;Ethernet&nbsp;shield back to a web browser – on other words, a very basic type of web page.</p>
<p>However there is something you may or may not want to &nbsp;learn in order to format the output in a readable format – HTML code. I am not a website developer (!) so will not delve into HTML too much.</p>
<p>However if you wish to serve up nicely formatted&nbsp;web pages&nbsp;with your Arduino and so on,&nbsp;<a href="http://en.wikipedia.org/wiki/HTML" target="_blank" rel="noopener">here</a>&nbsp;would be a good start. In the interests of simplicity, the following two functions will be the most useful:</p>
<div id="crayon-529ee07839911074988149">
<pre class="lang:arduino decode:true ">client.print(" is ");</pre>
<p><em>Client.print ();&nbsp;</em>allows us to send text or data back to the web page. It works in the same way as&nbsp;<em>serial.print()</em>, so nothing new there. You can also specify the&nbsp;<a href="http://arduino.cc/en/Reference/ClientPrintln" target="_blank" rel="noopener">data type</a>&nbsp;in the same way as with serial.print(). Naturally you can also use it to send data back as well. The other useful line is:</p>
<div id="crayon-529ee07839918534976548">
<pre class="lang:arduino decode:true ">client.println("&lt;br /&gt;");</pre>
<p>which sends the HTML code back to the web browser telling it to start a new line. The part that actually causes the carriage return/new line is the &lt;br /&gt; which is an HTML code (or “tag”) for a new line. So if you are creating more elaborate web page displays, you can just insert other HTML tags in the&nbsp;<em>client.print();&nbsp;</em>statement.</p>
<p>If you want to learn more about HTML commands, <a href="http://www.w3schools.com/html/" target="_blank" rel="noopener">here&#8217;s a good tutorial site</a>. Finally &#8211; note that the sketch will only send the data when it has been requested, that is when it has received a request from the web browser.</p>
<p><b><i>Accessing your Arduino over the Internet</i></b></p>
<p>So far &#8211; so good. But what if you want to access your Arduino from outside the local network?</p>
<p>You will need a&nbsp;<a href="http://en.wikipedia.org/wiki/Static_IP_address#Static_IP" target="_blank" rel="noopener">static</a>&nbsp;IP address – that is, the IP address your internet service provider assigns to your connection needs to stay the same. If you don’t have a static IP, as long as you leave your modem/router permanently swiched on your IP&nbsp;<em>shouldn’t</em>&nbsp;change. However that isn&#8217;t an optimal solution.</p>
<blockquote><p>If your ISP cannot offer you a static IP at all, you can still move forward with the project by using an organisation that offers a Dynamic DNS. These organisations offer you your own static IP host name (e.g. mojo.monkeynuts.com) instead of a number, keep track of your changing IP address and linking it to the new host name. From what I can gather, your modem needs to support (have an in-built client for…) these DDNS services. As an example, two companies are&nbsp;<a href="http://www.no-ip.com/" target="_blank" rel="noopener">No-IP</a>&nbsp;and<a href="http://www.dyndns.com/" target="_blank" rel="noopener">DynDNS.com</a>. Please note that I haven’t used those two, they are just offered as examples.</p></blockquote>
<p>Now, to find your IP address&#8230; usually this can be found by logging into your router’s administration page &#8211; it is usually 192.168.0.1 but could be different. <em>Check with your supplier or ISP</em> if they supplied the hardware.&nbsp;For this example, if I enter 10.1.1.1 in a web browser, and after entering my modem administration password, the following screen is presented:</p>
<figure><img loading="lazy" data-attachment-id="16066" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/wan-ip-address-router-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg" data-orig-size="500,269" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="WAN-IP-address-router" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg?w=500" class="alignnone size-full wp-image-16066" src="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg" alt="WAN-IP-address-router" width="500" height="269" srcset="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg 500w, https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg?w=150&amp;h=81 150w, https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg?w=300&amp;h=161 300w" sizes="(max-width: 500px) 100vw, 500px"></figure><p style="text-align:center"></p>
<p style="text-align:left">What you are looking for is your WAN IP address, as you can see in the image above. To keep the pranksters away, I have blacked out some of my address.</p>
<p style="text-align:left">The next thing to do is turn on&nbsp;<em>port-forwarding</em>. This tells the router where to redirect incoming requests from the outside world. When the modem receives such a request, we want to send that request to the port number of our&nbsp;Ethernet&nbsp;shield. Using the:</p>
<pre class="lang:arduino decode:true">EthernetServer server(125);</pre>
<p>function in our sketch has set the port number to 125. Each modem’s configuration screen will look different, but as an example here is one:</p>
<figure><img loading="lazy" data-attachment-id="16067" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/arduino-router-port-forwarding-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg" data-orig-size="500,256" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Arduino-router-port-forwarding" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg?w=500" class="alignnone size-full wp-image-16067" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg" alt="Arduino-router-port-forwarding" width="500" height="256" srcset="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg 500w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg?w=150&amp;h=77 150w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg?w=300&amp;h=154 300w" sizes="(max-width: 500px) 100vw, 500px"></figure><p style="text-align:center"></p>
<p style="text-align:left">So you can see from the line number one in the image above, the inbound port numbers have been set to 125, and the IP address of the&nbsp;Ethernet&nbsp;shield has been set to 10.1.1.77 – the same as in the sketch.</p>
<p style="text-align:left">After saving the settings, we’re all set. The external address of my&nbsp;Ethernet&nbsp;shield will be the WAN:125, so to access the Arduino I will type my WAN address with :125 at the end into the browser of the remote web device, which will contact the lonely&nbsp;Ethernet&nbsp;hardware back home.</p>
<p style="text-align:left">Furthermore, you may need to alter your modem’s&nbsp;<em>firewall&nbsp;</em>settings, to allow the port 125 to be “open” to incoming requests. Please check your modem documentation for more information on how to do this.</p>
<p>Now from basically any&nbsp;Internet&nbsp;connected device in the free world, I can enter my WAN and port number into the URL field and receive the results. For example, from a phone when it is connected to the&nbsp;Internet&nbsp;via LTE mobile data:</p>
<figure><img loading="lazy" data-attachment-id="16068" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/arduino-webserver-example-cellular-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg" data-orig-size="500,261" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Arduino-webserver-example-cellular" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg?w=500" class="alignnone size-full wp-image-16068" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg" alt="Arduino-webserver-example-cellular" width="500" height="261" srcset="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg 500w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg?w=150&amp;h=78 150w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg?w=300&amp;h=157 300w" sizes="(max-width: 500px) 100vw, 500px"></figure><p style="text-align:center"></p>
<p style="text-align:left"><span style="text-align:left">So at this stage you can now display data on a simple web page created by your Arduino and access it from anywhere with unrestricted Internet access. With your previous Arduino knowledge you can now use data from sensors or other parts of a sketch and display it for retrieval.</span></p>
<p><em><strong>Displaying sensor data on a web page</strong></em></p>
<p>As an example of displaying sensor data on a web page, let&#8217;s use an inexpensive and popular temperature and humidity sensor &#8211; <a href="https://pmdway.com/search?q=dht22" target="_blank" rel="noopener">the DHT22</a>. You will need to install the DHT22 Arduino library which can be <a href="http://www.freetronics.com/pages/humid-humidity-temperature-sensor-module-quickstart-guide" target="_blank" rel="noopener">found on this page</a>. If this is your first time with the DHT22, experiment with the example sketch that&#8217;s included with the library so you understand how it works.</p>
<p>Connect the DHT22 with the data pin to Arduino D2, Vin to the 5V pin and GND to &#8230; GND.</p>
<p style="text-align:left">Now for our sketch &#8211; to display the temperature and humidity on a web page.&nbsp;If you&#8217;re not up on HTML you can use online services <a href="http://www.quackit.com/html/online-html-editor/" target="_blank" rel="noopener">such as this</a> to generate the code, which you can then modify to use in the sketch.</p>
<p style="text-align:left">In the example below, the temperature and humidity data from the DHT22 is served in a simple web page:</p>
<pre class="lang:arduino decode:true  crayon-selected">#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;

// for DHT22 sensor
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,1,1,77);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(125);
DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
  dht.begin();
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() 
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == 'n' &amp;&amp; currentLineIsBlank) 
        {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
	  client.println("Refresh: 30");  // refresh the page automatically every 30 sec
          client.println();
          client.println("&lt;!DOCTYPE HTML&gt;");
          client.println("&lt;html&gt;");

          // get data from DHT22 sensor
          float h = dht.readHumidity();
          float t = dht.readTemperature();
          Serial.println(t);
          Serial.println(h);

          // from here we can enter our own HTML code to create the web page
          client.print("&lt;head&gt;&lt;title&gt;Office Weather&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Office Temperature&lt;/h1&gt;&lt;p&gt;Temperature - ");
          client.print(t);
          client.print(" degrees Celsius&lt;/p&gt;");
          client.print("&lt;p&gt;Humidity - ");
          client.print(h);
          client.print(" percent&lt;/p&gt;");
          client.print("&lt;p&gt;&lt;em&gt;Page refreshes every 30 seconds.&lt;/em&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;");
          break;
        }
        if (c == 'n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != 'r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}</pre>
<p>It is a modification of the IDE&#8217;s&nbsp;<em>webserver&nbsp;</em>example sketch that we used previously &#8211; with a few modifications. First, the webpage will automatically refresh every 30 seconds &#8211; this parameter is set in the line:</p>
<pre class="lang:arduino decode:true ">client.println("Refresh: 30");  // refresh the page automatically every 30 sec</pre>
<p>&#8230; and the custom HTML for our web page starts below the line:</p>
<pre class="lang:arduino decode:true ">// from here we can enter our own HTML code to create the web page</pre>
<p>You can then simply insert the required HTML inside&nbsp;<em>client.print()</em> functions to create the layout you need.</p>
<p>Finally &#8211; here&#8217;s an example screen shot of the example sketch at work:</p>
<figure><img loading="lazy" data-attachment-id="16070" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-16-ethernet/arduino-ethernet-pmdway-dht22-humid-cellular/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg" data-orig-size="500,345" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1386322904&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;125&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="arduino-ethernet-pmdway-dht22-humid-cellular" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg?w=500" class="alignnone size-full wp-image-16070" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg" alt="arduino-ethernet-pmdway-dht22-humid-cellular" width="500" height="345" srcset="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg 500w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg?w=150&amp;h=104 150w, https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg?w=300&amp;h=207 300w" sizes="(max-width: 500px) 100vw, 500px"></figure><p style="text-align:center"></p>
<p>You now have the framework to create your own web pages that can display various data processed with your Arduino.</p>




<p><strong><em>Conclusion</em></strong></p>



<p>I hope you enjoyed making this or at least reading about it. If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>



<p>And as always, have fun and make something.</p>



<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on twitter&nbsp;<a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">14344</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/w5100-ethernet-shield-arduino-pmdway-1_1024x1024.jpg" medium="image">
			<media:title type="html">w5100-ethernet-shield-arduino-pmdway-1_1024x1024</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/wiznet_w5100.jpg" medium="image">
			<media:title type="html">W5100 Ethernet shield for Arduino from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-sketch.jpg" medium="image">
			<media:title type="html">Arduino-webserver-example-sketch</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/wan-ip-address-router.jpg" medium="image">
			<media:title type="html">WAN-IP-address-router</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-router-port-forwarding.jpg" medium="image">
			<media:title type="html">Arduino-router-port-forwarding</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-webserver-example-cellular.jpg" medium="image">
			<media:title type="html">Arduino-webserver-example-cellular</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-ethernet-pmdway-dht22-humid-cellular.jpg" medium="image">
			<media:title type="html">arduino-ethernet-pmdway-dht22-humid-cellular</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial – LM3915 Logarithmic Dot/Bar Display Driver IC</title>
		<link>https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 07:03:35 +0000</pubDate>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[LM3915]]></category>
		<category><![CDATA[TI]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[bar]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[dot]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[IC]]></category>
		<category><![CDATA[level]]></category>
		<category><![CDATA[LM3914]]></category>
		<category><![CDATA[LM3916]]></category>
		<category><![CDATA[logarithmic]]></category>
		<category><![CDATA[voltmeter]]></category>
		<category><![CDATA[vu]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=13513</guid>

					<description><![CDATA[Introduction This is the second of two articles that will examine the LM391x series of LED driver ICs. The first covered the LM3914, and this covers the LM3915. The goal of these is to have you using the parts in a small amount of time and experiment with your driver ICs, from which point you [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><em><strong>Introduction</strong></em></p>



<p>This is the second of two articles that will examine the LM391x series of LED driver ICs. The first covered the <a href="https://tronixstuff.com/2013/09/14/tutorial-lm3914-dotbar-display-driver-ic/" target="_blank" rel="noopener">LM3914</a>, and this covers the <a href="https://amzn.to/3FWSZOj" target="_blank" rel="noreferrer noopener">LM3915</a>. The goal of these is to have you using the parts in a small amount of time and experiment with your driver ICs, from which point you can research further into their theory and application.</p>



<p>Although these parts have been around for many years, the <a href="https://amzn.to/3FWSZOj" target="_blank" rel="noreferrer noopener">LM3915</a> isn&#8217;t used that much however for the sake of completeness we&#8217;re writing the tutorial. The LM3915 offers a simple way to display a <em>logarithmic</em> voltage level using one or more groups of ten LEDs with a minimum of fuss.&nbsp;<em>If you&#8217;re wanting to make a VU meter</em>, you should use the LM3916 which we will cover in the final instalment of this trilogy.</p>



<p>Instead of having each LED represent a voltage level as with the LM3914, each LED connected to the LM3915 represents a 3 dB (decibel) change in the power level of the signal. For more on decibels, <a href="http://en.wikipedia.org/wiki/Decibel" target="_blank" rel="noopener">check out Wikipedia</a>.</p>



<p>To display these power level changes we’ll run through a couple of examples that you can use in your own projects and hopefully give you some ideas for the future. Originally by National Semiconductor, the LM391X series was then handled by Texas Instruments. Now, they&#8217;re obsolete &#8211; but many other places are making functional equivalents. </p>



<figure class="wp-block-image"><a href="https://amzn.to/3FWSZOj" target="_blank" rel=" noreferrer noopener"><img data-attachment-id="16055" data-permalink="https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/two-lm3915-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg" data-orig-size="500,180" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1386259602&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;80&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="two-LM3915" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg" alt="LM3915 from PMD Way" class="wp-image-16055" /></a></figure>



<p><em><strong>Getting Started</strong></em></p>



<p>You will need the&nbsp;<a href="https://tronixstuff.com/wp-content/uploads/2013/12/LM3915-data-sheet.pdf">LM3915 data sheet</a>, so please download that and keep it as a reference.&nbsp;First – back to basics. The LM3915 controls ten LEDs. It controls the current through the LEDs with the use of only one resistor, and the LEDs can appear in a bar graph or single ‘dot’ when in use. The LM3915 contains a ten-stage voltage divider, each stage when reached will illuminate the matching LED (and those below it in level meter mode).</p>



<p>Let’s consider the most basic of examples (from page two of the data sheet) – a simple logarithmic display of voltage between 0 and 10V:</p>



<figure class="wp-block-image"><img data-attachment-id="16056" data-permalink="https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/lm3915-demo-board-circuit-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board-circuit.jpg" data-orig-size="500,954" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="LM3915-demo-board-circuit" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board-circuit.jpg?w=157" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board-circuit.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board-circuit.jpg" alt="LM3915 from PMD Way" class="wp-image-16056" /></figure>



<p>After building the circuit you can connect a signal to measure via pin 5, and the GND to pin 2. We&#8217;ve built the circuit exactly as above on some stripboard for demonstration purposes, with the only difference being the use of an 8.2kΩ resistor for R2:</p>



<figure class="wp-block-image"><img data-attachment-id="16057" data-permalink="https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/lm3915-demo-board-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board.jpg" data-orig-size="500,291" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1386276484&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;80&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="LM3915-demo-board" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board.jpg" alt="LM3915 from PMD Way" class="wp-image-16057" /></figure>



<p>To show this in action we use a signal of varying AC voltage &#8211; a sine wave at around 2 kHz. In the following video,&nbsp;you can see the comparison of the signal&#8217;s voltage against the LEDs being illuminated, and you will see the logarithmic voltage increase represented by the LEDs:</p>


<div class="embed-youtube"><iframe title="Demonstrating the LM3915 with varying AC voltage" width="500" height="281" src="https://www.youtube.com/embed/JjILRLZTvgk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>We used the bar display mode for the voltage increase, and the dot display mode for the voltage decrease. Did you notice that during the voltage decrease, the LEDs below the maximum level being displayed were dim?</p>



<p>As the signal&#8217;s voltage was varying very quickly, the change in the LED&#8217;s location is a blur due to the speed of change. In the video below,&nbsp;we&#8217;ve slowed the frequency right down but kept the same maximum voltage.</p>


<div class="embed-youtube"><iframe title="Demonstrating the LM3915 with slowly varying AC voltage" width="500" height="281" src="https://www.youtube.com/embed/surH4pOGDKA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>Well that was a lot of fun, and gives you an idea of what is possible with the LM3915.</p>



<p><em><strong>Displaying weaker signals</strong></em></p>



<p>In non-theoretical situations your input signal won&#8217;t conveniently be between 0 and 10 V. For example the line level on audio equipment <a href="http://en.wikipedia.org/wiki/Line_level" target="_blank" rel="noopener">can vary</a> between 1 and 3V peak to peak. For example, here&#8217;s a random DSO image from measuring the headphone output on my computer whilst playing some typical music:</p>



<figure class="wp-block-image"><img data-attachment-id="16058" data-permalink="https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/audio-signal-lm3915-pc-sound-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/audio-signal-lm3915-pc-sound.jpg" data-orig-size="480,800" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="audio-signal-LM3915-PC-sound" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/audio-signal-lm3915-pc-sound.jpg?w=180" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/audio-signal-lm3915-pc-sound.jpg?w=480" src="https://tronixstuff.com/wp-content/uploads/2013/12/audio-signal-lm3915-pc-sound.jpg" alt="LM3915 from PMD Way" class="wp-image-16058" /></figure>



<p>Although it&#8217;s an AC signal we&#8217;ll treat it as DC for simplicity. So to display this random low DC voltage signal we&#8217;ll reduce the range of the display to 0~3V DC. This is done using &nbsp;the same method as with the LM3914 &#8211; with maths and different resistors.</p>



<p>Consider the following formulae:</p>



<figure class="wp-block-image"><img data-attachment-id="16059" data-permalink="https://tronixstuff.com/2025/04/09/tutorial-lm3915-logarithmic-dotbar-display-driver-ic/lm3915-reference-voltage-formula-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-reference-voltage-formula.jpg" data-orig-size="500,164" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="LM3915-reference-voltage-formula" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-reference-voltage-formula.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-reference-voltage-formula.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-reference-voltage-formula.jpg" alt="LM3915 from PMD Way" class="wp-image-16059" /></figure>



<p>As you can see the LED current (Iled) is simple, however we&#8217;ll need to solve for R1 and R2 with the first formula to get our required Vref of 3V. For our example circuit I use 2.2kΩ for R2 which gives a value of&nbsp;1.8kΩ for R1. However putting those values in the ILED formula gives a pretty low current for the LEDs, about 8.3 mA.</p>



<p>Live and learn &#8211; so spend time experimenting with values so you can match the required Vref and ILED.</p>



<p>Nevertheless in this video&nbsp;below we have the Vref of 3V and some music in from the computer as a sample source of low-voltage DC. <em><strong>This is not a VU meter!</strong>&nbsp;</em></p>


<div class="embed-youtube"><iframe title="Demonstrating the LM3915 with low Vref" width="500" height="281" src="https://www.youtube.com/embed/gWEYIWWvwVo?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>Again due to the rapid rate of change of the voltage, there is the blur between the maximum level at the time and 0V.</p>



<p><em><strong><em><strong>Chaining multiple LM3915s</strong></em></strong></em></p>



<p>This is covered well in the data sheet, so read it for more on using two LM3915s.&nbsp;Plus there are some great example circuits in the data sheet, for example the 100W audio power meter on page 26 and the vibration meter (using a piezo) on page 18.</p>



<p><em><strong>Conclusion</strong></em></p>



<p>I hope you enjoyed making this or at least reading about it. If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>



<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x &#8211; <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>



<p>And as always, have fun and make something.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">13513</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/two-lm3915.jpg" medium="image">
			<media:title type="html">two-LM3915</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board-circuit.jpg" medium="image">
			<media:title type="html">LM3915 from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-demo-board.jpg" medium="image">
			<media:title type="html">LM3915 from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/audio-signal-lm3915-pc-sound.jpg" medium="image">
			<media:title type="html">LM3915 from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/lm3915-reference-voltage-formula.jpg" medium="image">
			<media:title type="html">LM3915 from PMD Way</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial &#8211; the Arduino AREF Pin</title>
		<link>https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-22-aref-pin/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 06:55:17 +0000</pubDate>
				<category><![CDATA[ADC]]></category>
		<category><![CDATA[analogRead]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[aref]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[accuracy]]></category>
		<category><![CDATA[analog]]></category>
		<category><![CDATA[AREF]]></category>
		<category><![CDATA[converter]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[internal]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[resolution]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=14455</guid>

					<description><![CDATA[Learn how to measure smaller voltages with greater accuracy using your Arduino. In this tutorial we&#8217;ll look at how you can measure smaller voltages with greater accuracy using the analogue input pins on your Arduino Uno R1 to R3 (not R4!) or compatible board in conjunction with the AREF pin. However first we&#8217;ll do some [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Learn how to measure smaller voltages with greater accuracy using your Arduino.</p>



<p>In this tutorial we&#8217;ll look at how you can measure smaller voltages with greater accuracy using the analogue input pins on your <a href="https://amzn.to/4jtzETl" target="_blank" rel="noreferrer noopener">Arduino Uno</a> R1 to R3 (<strong>not R4!</strong>) or compatible board in conjunction with the AREF pin. However first we&#8217;ll do some revision to get you up to speed. Please read this post entirely before working with AREF the first time.</p>



<figure class="wp-block-image"><a href="https://amzn.to/4jtzETl" target="_blank" rel=" noreferrer noopener"><img data-attachment-id="16035" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-22-aref-pin/arduino-uno-aref-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-uno-aref.jpg" data-orig-size="500,330" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1386853636&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.05&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="Arduino-Uno-AREF" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-uno-aref.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-uno-aref.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-uno-aref.jpg" alt="Arduino Uno from PMD Way" class="wp-image-16035" /></a></figure>



<p><em><strong>Revision</strong></em></p>



<p>You may recall from previous Arduino tutorials that we used the <em>analogRead()</em> function to measure the voltage of an electrical current from sensors and so on using one of the analogue input pins. The value returned from <em>analogRead()</em> would be between zero an 1023, with zero representing zero volts and 1023 representing the operating voltage of the Arduino board in use.</p>



<p>And when we say the operating voltage &#8211; this is the voltage available to the Arduino <em><strong>after</strong> </em>the power supply circuitry. For example, if you have a typical Arduino Uno board and run it from the USB socket &#8211; sure, there is 5V available to the board from the USB socket on your computer or hub &#8211; but the voltage is reduced slightly as the current winds around the circuit to the microcontroller &#8211; or the USB source just isn&#8217;t up to scratch.</p>



<p>This can easily be demonstrated by connecting an Arduino Uno to USB and putting a multimeter set to measure voltage across the 5V and GND pins. Some boards will return as low as 4.8 V, some higher but still below 5V. So if you&#8217;re gunning for accuracy, power your board from an external power supply via the DC socket or Vin pin &#8211; such as 9V DC. Then after that goes through the power regulator circuit you&#8217;ll have a nice 5V, for example:</p>



<figure class="wp-block-image"><img data-attachment-id="16036" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-22-aref-pin/arduino-5v-jpg-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-5v.jpg.jpg" data-orig-size="500,301" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;2.8&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-LZ3&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1386771289&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;6.1&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.05&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="Arduino-5V.jpg" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-5v.jpg.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-5v.jpg.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-5v.jpg.jpg" alt="Arduino Uno from PMD Way" class="wp-image-16036" /></figure>



<p>This is important as the accuracy of any&nbsp;<em>analogRead()</em> values will be affected by not having a true 5 V. If you don&#8217;t have any option, you can use some maths in your sketch to compensate for the drop in voltage. For example, if your voltage is 4.8V &#8211; the analogRead() range of 0~1023 will relate to 0~4.8V and not 0~5V. This may sound trivial, however if you&#8217;re using a sensor that returns a value as a voltage (e.g. the TMP36 temperature sensor) &#8211; the calculated value will be wrong. So in the interests of accuracy, use an external power supply.</p>



<p><em><strong>Why does analogRead() return a value between 0 and 1023?<br><br></strong></em>This is due to the <em>resolution </em>of the ADC. The resolution (for this article) is the degree to which something can be represented numerically. The <em>higher </em>the resolution, the greater accuracy with which something can be represented. We measure resolution in the terms of the number of <em>bits </em>of resolution.</p>



<p>For example, a 1-bit resolution would only allow two (two to the power of one) values – zero and one. A 2-bit resolution would allow four (two to the power of two) values – zero, one, two and three. If we tried to measure &nbsp;a five volt range with a two-bit resolution, and the measured voltage was four volts, our ADC would return a numerical value of 3 – as four volts falls between 3.75 and 5V. It is easier to imagine this with the following image:</p>



<figure class="wp-block-image"><img data-attachment-id="16037" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-22-aref-pin/arduino-adc-aref-2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-adc-aref.jpg" data-orig-size="500,340" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Arduino-ADC-aref" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-adc-aref.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-adc-aref.jpg?w=500" src="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-adc-aref.jpg" alt="Arduino AREF" class="wp-image-16037" /></figure>



<p>&nbsp;So with our example ADC with 2-bit resolution, it can only represent the voltage with four possible resulting values. If the input voltage falls between 0 and 1.25, the ADC returns numerical 0; if the voltage falls between 1.25 and 2.5, the ADC returns a numerical value of 1. And so on. With our Arduino’s ADC range of 0~1023 – we have 1024 possible values – or 2 to the power of 10. So our Arduinos have an ADC with a 10-bit resolution.</p>



<p><em><strong>So what is AREF?&nbsp;</strong></em></p>



<p>To cut a long story short, when your Arduino takes an analogue reading, it compares the voltage measured at the analogue pin being used against what is known as the <em>reference voltage</em>. In normal <em>analogRead</em> use, the reference voltage is the operating voltage of the board. For the more popular Arduino boards such as the Uno, Mega, Duemilanove and Leonardo/Yún boards, the operating voltage of 5V. If you have an Arduino Due board, the operating voltage is 3.3V. If you have something else &#8211; check the Arduino <a href="http://arduino.cc/en/Main/Products" target="_blank" rel="noopener">product page</a> or ask your board supplier.</p>



<p>So if you have a reference voltage of 5V, each unit returned by <em>analogRead()</em> is valued at 0.00488 V. (This is calculated by dividing 1024 into 5V).&nbsp;What if we want to measure voltages between 0 and 2, or 0 and 4.6? How would the ADC know what is 100% of our voltage range?</p>



<p>And therein lies the reason for the AREF pin. AREF means<strong>&nbsp;A</strong>nalogue&nbsp;<strong>REF</strong>erence. It allows us to feed the Arduino a reference voltage from an external power supply. For example, if we want to measure voltages with a maximum range of 3.3V, we would feed a nice smooth 3.3V into the AREF pin – perhaps from a voltage regulator IC.&nbsp;Then the each step of the ADC would represent around 3.22 millivolts (divide 1024 into 3.3).</p>



<p>Note that the lowest reference voltage you can have is 1.1V. There are two forms of AREF &#8211; internal and external, so let&#8217;s check them out.</p>



<p><em><strong>External AREF</strong></em></p>



<p>An external AREF is where you supply an external reference voltage to the Arduino board. This can come from a regulated power supply, or if you need 3.3V you can get it from the Arduino&#8217;s 3.3V pin. If you are using an external power supply, be sure to connect the GND to the Arduino&#8217;s GND pin. Or if you&#8217;re using the Arduno&#8217;s 3.3V source &#8211; just run a jumper from the 3.3V pin to the AREF pin.</p>



<p>To activate the external AREF, use the following in&nbsp;<em>void setup():</em></p>



<pre class="wp-block-preformatted lang:arduino decode:true">analogReference(EXTERNAL); // use AREF for reference voltage</pre>



<p>This sets the reference voltage to whatever you have connected to the AREF pin &#8211; which of course will have a voltage between 1.1V and the board&#8217;s operation voltage.</p>



<p>Very important note &#8211; when using an external voltage reference, you&nbsp;<em>must</em>&nbsp;set the analogue reference to EXTERNAL before using&nbsp;<em>analogRead()</em>. This will prevent you from shorting the active internal reference voltage and the AREF pin, which can damage the microcontroller on the board.</p>



<p>If necessary for your application, you can revert back to the board&#8217;s operating voltage for AREF (that is &#8211; back to normal) with the following:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">analogReference(DEFAULT);</pre>



<p>Now to demonstrate external AREF at work. Using a 3.3V AREF, the following sketch measures the voltage from A0 and displays the percentage of total AREF and the calculated voltage:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(8,9,4,5,6,7);

int analoginput = 0; // our analog pin
int analogamount = 0; // stores incoming value
float percentage = 0; // used to store our percentage value
float voltage =0; // used to store voltage value

void setup()
{
  lcd.begin(16, 2);
  analogReference(EXTERNAL); // use AREF for reference voltage
}

void loop()
{
  lcd.clear();
  analogamount=analogRead(analoginput);
  percentage=(analogamount/1024.00)*100;
  voltage=analogamount*3.222; // in millivolts
  lcd.setCursor(0,0);
  lcd.print("% of AREF: ");
  lcd.print(percentage,2);
  lcd.setCursor(0,1);  
  lcd.print("A0 (mV): ");
  lcd.println(voltage,2);
  delay(250);
}</pre>



<p>The results of the sketch above are shown in the following video:</p>


<div class="embed-youtube"><iframe title="Demonstrating the Arduino&#039;s external AREF pin" width="500" height="281" src="https://www.youtube.com/embed/Vrw-MOzsSIc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p><em><strong>Internal AREF</strong></em></p>



<p>The microcontrollers on our Arduino boards can also generate an internal reference voltage of 1.1V and we can use this for AREF work. Simply use the line:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">analogReference(INTERNAL);</pre>



<p>For Arduino Mega boards, use:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">analogReference(INTERNAL1V1);</pre>



<p>in&nbsp;<em>void setup()</em> and you&#8217;re off.&nbsp;If you have an Arduino Mega there is also a 2.56V reference voltage available which is activated with:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">analogReference(INTERNAL2V56);</pre>



<p>Finally &#8211; before settling on the results from your AREF pin, always calibrate the readings against a known good multimeter.</p>



<p><strong><em>Conclusion</em></strong></p>



<p>The AREF function gives you more flexibility with measuring analogue signals. If you are interested in using specific ADC components, we have tutorials on the&nbsp;<a href="https://tronixstuff.com/2013/07/02/tutorial-arduino-and-the-ti-ads1110-16-bit-adc/" target="_blank" rel="noopener">ADS1110 16-bit ADC</a> and the&nbsp;<a href="https://tronixstuff.com/2013/06/17/tutorial-arduino-and-pcf8591-adc-dac-ic/" target="_blank" rel="noopener">NXP PCF 8591</a> 8-bit A/D and D/A IC.</p>



<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on X &#8211; <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>



<p>I hope you enjoyed making this or at least reading about it. If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>



<p>And as always, have fun and make something.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">14455</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2013/12/9462a-arduino-uno-aref.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/9462a-arduino-uno-aref.jpg" medium="image">
			<media:title type="html">Arduino Uno AREF</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-uno-aref.jpg" medium="image">
			<media:title type="html">Arduino Uno from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-5v.jpg.jpg" medium="image">
			<media:title type="html">Arduino Uno from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/arduino-adc-aref.jpg" medium="image">
			<media:title type="html">Arduino AREF</media:title>
		</media:content>
	</item>
		<item>
		<title>Tutorial – Numeric Keypads and Arduino</title>
		<link>https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-42-numeric-keypads/</link>
		
		<dc:creator><![CDATA[John Boxall]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 06:23:21 +0000</pubDate>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[COM-08653]]></category>
		<category><![CDATA[numeric keypad]]></category>
		<category><![CDATA[PIN]]></category>
		<category><![CDATA[tronixstuff]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[12-digit]]></category>
		<category><![CDATA[electronic]]></category>
		<category><![CDATA[kepad]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[numeric]]></category>
		<guid isPermaLink="false">http://tronixstuff.com/?p=14523</guid>

					<description><![CDATA[Numeric keypads can provide a simple end-user alternative for various interfaces for your projects. Or if you need a lot of buttons, they can save you a lot of time with regards to construction. We&#8217;ll run through connecting them, using the Arduino library and then finish with a useful example sketch. Getting Started No matter [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Numeric keypads can provide a simple end-user alternative for various interfaces for your projects. Or if you need a lot of buttons, they can save you a lot of time with regards to construction. We&#8217;ll run through connecting them, using the Arduino library and then finish with a useful example sketch.</p>



<figure class="wp-block-image"><a href="https://amzn.to/3XT98ua"><img data-attachment-id="16051" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-42-numeric-keypads/keypad2/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad2.jpg" data-orig-size="624,312" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="keypad2" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad2.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad2.jpg?w=624" src="https://tronixstuff.com/wp-content/uploads/2013/12/keypad2.jpg" alt="Numeric keypads from PMD Way" class="wp-image-16051" /></a></figure>



<p><em><strong>Getting Started</strong></em></p>



<p>No matter where you get your keypads from, make sure you can get the data sheet &#8211; as this will make life easier when wiring them up. For example:</p>



<figure class="wp-block-image"><a href="https://amzn.to/3XT98ua"><img data-attachment-id="16049" data-permalink="https://tronixstuff.com/2025/04/09/arduino-tutorials-chapter-42-numeric-keypads/keypad/" data-orig-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad.jpg" data-orig-size="1059,597" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="keypad" data-image-description="" data-image-caption="" data-medium-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad.jpg?w=300" data-large-file="https://tronixstuff.com/wp-content/uploads/2013/12/keypad.jpg?w=1024" src="https://tronixstuff.com/wp-content/uploads/2013/12/keypad.jpg" alt="Numeric keypads from PMD Way" class="wp-image-16049" /></a></figure>



<p>The data sheet is important as it will tell you which pins or connectors on the keypad are for the rows and columns.&nbsp;If you don&#8217;t have the data sheet &#8211; you will need to manually determine which contacts are for the rows and columns.</p>



<p>This can be done using the continuity function of a multimeter (the buzzer). Start by placing one probe on pin 1, the other probe on pin 2, and press the keys one by one. Make a note of when a button completes the circuit, then move onto the next pin. Soon you will know which is which. For example, on the example keypad pins 1 and 5 are for button “1″, 2 and 5 for “4″,&nbsp;etc…</p>



<p><span style="line-height:1.5em">At this point please </span><a href="https://github.com/Chris--A/Keypad" target="_blank" rel="noreferrer noopener">download</a><span style="line-height:1.5em"> and install the keypad Arduino library. Now we&#8217;ll demonstrate how to use both keypads in simple examples. </span></p>



<p><em style="line-height:1.5em"><strong>Using a 12 digit keypad</strong></em></p>



<p>We&#8217;ll use the <a href="https://amzn.to/3XT98ua" target="_blank" rel="noreferrer noopener">small black keypad</a>, an <a href="https://amzn.to/3XT98ua" target="_blank" rel="noreferrer noopener">Arduino Uno-compatible</a> and an LCD with an I2C interface for display purposes. If you don&#8217;t have an LCD you could always send the text to the serial monitor instead.</p>



<div>Wire up your LCD then connect the keypad to the Arduino in the following manner:</div>



<div>
<ul>
<li>Keypad row 1 to Arduino digital 5</li>
<li>Keypad row 2 to Arduino digital 4</li>
<li>Keypad row 3 to Arduino digital 3</li>
<li>Keypad row 4 to Arduino digital 2</li>
<li>Keypad column 1 to Arduino digital 8</li>
<li>Keypad column 2 to Arduino digital 7</li>
<li>Keypad column 3 to Arduino digital 6</li>
</ul>
</div>



<p>If your keypad is different to ours, take note of the lines in the sketch from:</p>



<pre class="wp-block-preformatted lang:arduino decode:true">// keypad type definition</pre>



<p>As you need to change the numbers in the arrays <em>rowPins[ROWS]</em> and <em>colPins[COLS]</em>. You enter the digital pin numbers connected to the rows and columns of the keypad respectively.</p>



<p>Furthermore, the array&nbsp;<em>keys</em>&nbsp;stores the values displayed in the LCD when a particular button is pressed. You can see we&#8217;ve matched it with the physical keypad used, however you can change it to whatever you need. But for now,&nbsp;<span style="line-height:1.5em">enter and upload the following sketch once you&#8217;re satisfied with the row/pin number allocations:</span></p>



<pre class="wp-block-preformatted lang:arduino decode:true">/* Numeric keypad and I2C LCD
   http://tronixstuff.com
   Uses Keypad library for Arduino
   http://www.arduino.cc/playground/Code/Keypad
   by Mark Stanley, Alexander Brevig */

#include "Keypad.h"
#include "Wire.h" // for I2C LCD
#include "LiquidCrystal_I2C.h" // for I2C bus LCD module 
// http://www.dfrobot.com/wiki/index.php/I2C/TWI_LCD1602_Module_(SKU:_DFR0063)
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

// keypad type definition
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] =
 {{'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}};

byte rowPins[ROWS] = {
  5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  8, 7, 6}; // connect to the column pinouts of the keypad

int count=0;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  lcd.init();          // initialize the lcd
  lcd.backlight(); // turn on LCD backlight
}

void loop()
{
  char key = keypad.getKey();
  if (key != NO_KEY)
  {
    lcd.print(key);
    count++;
    if (count==17)
    {
      lcd.clear();
      count=0;
    }
  }
}</pre>



<p>And the results of the sketch are <a href="http://www.youtube.com/watch?v=Z5ufcU2NlEc&amp;" target="_blank" rel="noopener">shown in this video</a>.</p>


<div class="embed-youtube"><iframe title="Arduino and 12-digit numeric keypad" width="500" height="375" src="https://www.youtube.com/embed/Z5ufcU2NlEc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>So now you can see how the button presses can be translated into data for use in a sketch. We&#8217;ll now repeat this demonstration with the larger keypad.</p>



<p><em><strong>Using a 16 digit keypad</strong></em></p>



<p>We&#8217;ll use the <a href="https://amzn.to/43KKr71">larger 4&#215;4 keypad</a>, an <a href="https://amzn.to/42BZU8c" target="_blank" rel="noreferrer noopener">Arduino Uno-compatible</a> and for a change the I2C LCD from Akafugu for display purposes. Again, if you don&#8217;t have an LCD you could always send the text to the serial monitor instead. Wire up the LCD and then connect the keypad to the Arduino in the following manner:</p>



<div>
<ul>
<li>Keypad row 1 (pin eight) to Arduino digital 5</li>
<li>Keypad row 2 (pin 1) to Arduino digital 4</li>
<li>Keypad row 3 (pin 2) to Arduino digital 3</li>
<li>Keypad row 4 (pin 4) to Arduino digital 2</li>
<li>Keypad column 1 (pin 3) to Arduino digital 9</li>
<li>Keypad column 2 (pin 5) to Arduino digital 8</li>
<li>Keypad column 3 (pin 6) to Arduino digital 7</li>
<li>Keypad column 4 (pin 7) to Arduino digital 6</li>
</ul>
<div>Now for the sketch – take note how we have accommodated for the larger numeric keypad:</div>
<ul>
<li>the extra column in the array char keys[]</li>
<li>the extra pin in the array colPins[]</li>
<li>and the byte COLS = 4.</li>
</ul>
<pre class="lang:arduino decode:true ">/* Numeric keypad and I2C LCD
   http://tronixstuff.com
   Uses Keypad library for Arduino
   http://www.arduino.cc/playground/Code/Keypad
   by Mark Stanley, Alexander Brevig */

#include "Keypad.h"
#include "Wire.h" // for I2C LCD
#include "TWILiquidCrystal.h"
// http://store.akafugu.jp/products/26
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] =
 {{'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}};
byte rowPins[ROWS] = {
  5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  9, 8, 7, 6}; //connect to the column pinouts of the keypad
int count=0;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.print("Keypad test!");  
  delay(1000);
  lcd.clear();
}

void loop()
{
  char key = keypad.getKey();
  if (key != NO_KEY)
  {
    lcd.print(key);
    Serial.print(key);
    count++;
    if (count==17)
    {
      lcd.clear();
      count=0;
    }
  }
}</pre>
<p>And again you can see the results of the sketch above <a href="http://www.youtube.com/watch?v=bJnOS-BDq90" target="_blank" rel="noopener">in this video</a>.</p>
<p></p></div>


<div class="embed-youtube"><iframe title="Arduino and 16-digit numeric keypad" width="500" height="281" src="https://www.youtube.com/embed/bJnOS-BDq90?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p>And now for an example project, one which is probably the most requested use of the numeric keypad&#8230;</p>



<p><em style="line-height:1.5em"><strong>Example Project &#8211; PIN access system</strong></em></p>



<p><span style="line-height:1.5em">The most-requested use for a numeric keypad seems to be a &#8220;PIN&#8221; style application, where the Arduino is instructed to do something based on a correct number being entered into the keypad. The following sketch uses the hardware described for the previous sketch and implements a six-digit PIN entry system. The actions to take place can be inserted in the functions&nbsp;<em>correctPIN()</em> and <em>incorrectPIN()</em>. And the PIN is set in the array&nbsp;<em>char PIN[6]</em>. With a little extra work you could create your own PIN-change function as well.&nbsp;</span></p>



<pre class="wp-block-preformatted lang:arduino decode:true">// PIN switch with 16-digit numeric keypad
// http://tronixstuff.com
#include "Keypad.h"
#include &lt;Wire.h&gt;
#include &lt;TWILiquidCrystal.h&gt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] =
{
  {
    '1','2','3','A'  }
  ,
  {
    '4','5','6','B'  }
  ,
  {
    '7','8','9','C'  }
  ,
  {
    '*','0','#','D'  }
};
byte rowPins[ROWS] = {
  5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  9, 8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

char PIN[6]={
  '1','2','A','D','5','6'}; // our secret (!) number
char attempt[6]={ 
  '0','0','0','0','0','0'}; // used for comparison
int z=0;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.print("PIN Lock ");
  delay(1000);
  lcd.clear();
  lcd.print("  Enter PIN...");
}

void correctPIN() // do this if correct PIN entered
{
  lcd.print("* Correct PIN *");
  delay(1000);
  lcd.clear();
  lcd.print("  Enter PIN...");
}

void incorrectPIN() // do this if incorrect PIN entered
{
  lcd.print(" * Try again *");
  delay(1000);
  lcd.clear();
  lcd.print("  Enter PIN...");
}

void checkPIN()
{
  int correct=0;
  int i;
  for ( i = 0;   i &lt; 6 ;  i++ )
  {

    if (attempt[i]==PIN[i])
    {
      correct++;
    }
  }
  if (correct==6)
  {
    correctPIN();
  } 
  else
  {
    incorrectPIN();
  }

  for (int zz=0; zz&lt;6; zz++) 
  {
    attempt[zz]='0';
  }
}

void readKeypad()
{
  char key = keypad.getKey();
  if (key != NO_KEY)
  {
    attempt[z]=key;
    z++;
    switch(key)
    {
    case '*':
      z=0;
      break;
    case '#':
      z=0;
      delay(100); // for extra debounce
      lcd.clear();
      checkPIN();
      break;
    }
  }
}

void loop()
{
  readKeypad();
}</pre>



<p>The project is <a href="http://www.youtube.com/watch?v=hJsanRXgRMk" target="_blank" rel="noopener">demonstrated in this video</a>.</p>


<div class="embed-youtube"><iframe title="Example Project - PIN access system" width="500" height="281" src="https://www.youtube.com/embed/hJsanRXgRMk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>



<p><em><strong>Conclusion</strong></em></p>



<p>So now you have the ability to use twelve and sixteen-button keypads with your Arduino systems. I&#8217;m sure you will come up with something useful and interesting using the keypads in the near future.</p>



<p>To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on x &#8211; <a href="https://twitter.com/tronixstuff" target="_blank" rel="noopener">@tronixstuff</a>.</p>



<p>I hope you enjoyed making this or at least reading about it. If you find this sort of thing interesting, please consider&nbsp;<a href="https://amzn.to/42ygWEh">ordering one or more of my books from amazon</a>.</p>



<p>And as always, have fun and make something.</p>





<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">14523</post-id>
		<media:thumbnail url="https://tronixstuff.com/wp-content/uploads/2013/12/0da91-arduino-numeric-keypads.jpg" />
		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/0da91-arduino-numeric-keypads.jpg" medium="image">
			<media:title type="html">Arduino numeric keypads</media:title>
		</media:content>

		<media:content url="https://0.gravatar.com/avatar/9400a3b9ecd811290fca5fce99a55ade1768d4e63b49c856ca7e68555894c406?s=96&#38;d=retro&#38;r=G" medium="image">
			<media:title type="html">johnboxall</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/keypad2.jpg" medium="image">
			<media:title type="html">Numeric keypads from PMD Way</media:title>
		</media:content>

		<media:content url="https://tronixstuff.com/wp-content/uploads/2013/12/keypad.jpg" medium="image">
			<media:title type="html">Numeric keypads from PMD Way</media:title>
		</media:content>
	</item>
	</channel>
</rss>
