<?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/"
	>

<channel>
	<title>precise Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/precise/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/precise/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Sun, 22 Jun 2025 17:30:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://nerd-corner.com/wp-content/uploads/2019/10/cropped-LogoNerdCorner-2-32x32.png</url>
	<title>precise Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/precise/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>DIY keypad lock &#8211; 3D printing and code</title>
		<link>https://nerd-corner.com/diy-keypad-lock-3d-printing-and-code/</link>
					<comments>https://nerd-corner.com/diy-keypad-lock-3d-printing-and-code/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Tue, 17 Dec 2024 20:44:05 +0000</pubDate>
				<category><![CDATA[Arduino projects]]></category>
		<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[barrel jack]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[jumper cable]]></category>
		<category><![CDATA[keypad]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[Solid Works]]></category>
		<category><![CDATA[user guide]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1677</guid>

					<description><![CDATA[<p>A cupboard that should always be locked and five people who need to access it &#8211; a classic challenge. The obvious solutions? Five keys in &#8230; </p>
<p>The post <a href="https://nerd-corner.com/diy-keypad-lock-3d-printing-and-code/">DIY keypad lock &#8211; 3D printing and code</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A cupboard that should always be locked and five people who need to access it &#8211; a classic challenge. The obvious solutions? Five keys in circulation or a single person who manages the key so that you have to borrow it every time. But we&#8217;ve all been there: the key ends up lying in the cupboard, under the carpet or behind the flower pot.</p>
<p>But wouldn&#8217;t it be much more practical to do away with physical keys altogether? Nowadays, there are numerous ways to open a lock: Fingerprint scanners, facial recognition, NFC, numeric codes, dials &#8211; or, of course, brute force methods such as explosives and brute force. But if you are looking for an inexpensive, non-violent and simple solution, the keypad lock comes into focus.</p>
<p>Surprisingly, there are hardly any really good DIY solutions for hobbyists on the Internet. So I tackle it myself &#8211; my first keypad lock, which I simply call “Version 1”.</p>
<p><em><strong>This might also be interesting for you: </strong><a href="https://nerd-corner.com/diy-powerbank-with-voltage-regulator-and-voltmeter/">Do it yourself powerbank with voltage regulator and voltmeter</a></em></p>
<h2>Construction of the housing</h2>
<p>The initial focus is on the housing and the keypad holder. The first question that always arises is: How big should it be? The answer depends on several factors:</p>
<ul>
<li>Which components are required? Each component takes up space and influences the design.</li>
<li>How much space do the components take up? A compact design is advantageous, but must not restrict functionality.</li>
<li>What are the haptics and operability like? The keypad should be comfortable to use without being too cramped or impractical.</li>
</ul>
<p>These considerations form the basis for the housing design &#8211; because good planning saves time and nerves later on.</p>
<h3>What will be inside the housing?</h3>
<p>The central component is, of course, the membrane keypad (1.0.1). It has the following dimensions:</p>
<ul>
<li>Width: 69 mm</li>
<li>Length: 76 mm</li>
<li>Thickness: 0.6 mm (or 0.95 mm above the keys)</li>
</ul>
<p>The keypad also has a ribbon cable with DuPont sockets for connection to a microcontroller. The cable itself is 85 mm long and 17.78 mm wide.</p>
<p>The control center of the lock is the Nano (1.0.2). To accommodate it neatly in the housing and to make the cable connections as convenient as possible, I opted for a Nano expansion board with screw terminals (1.0.4).</p>
<p>A hollow socket (5.5 x 2.1 mm, 1.0.4) is used for the emergency power supply so that the lock continues to function even in the event of a power failure.</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-1671 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1.jpg" alt="tastenfeldschloss Bauteile" width="2310" height="1324" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1.jpg 2318w, https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1-300x172.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1-1024x587.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1-768x440.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1-1536x881.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/1-0-1-2048x1174.jpg 2048w" sizes="(max-width: 2310px) 100vw, 2310px" /></p>
<p>The pin and socket connectors (1.1.1) serve as the central power distribution and are later soldered to the breadboard (1.1.2). Jumper cables (1.1.3) are used to ensure that all components are reliably connected. Depending on the position of the components, different lengths are required &#8211; in this case 10 cm and 20 cm.</p>
<p><img decoding="async" class="aligncenter wp-image-1670 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/1-1.jpg" alt="" width="2310" height="1327" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/1-1.jpg 2321w, https://nerd-corner.com/wp-content/uploads/2024/12/1-1-300x172.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/1-1-1024x588.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/1-1-768x441.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/1-1-1536x882.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/1-1-2048x1176.jpg 2048w" sizes="(max-width: 2310px) 100vw, 2310px" /></p>
<p>For the status display of the keypad lock, I use Neo Pixel addressable LEDs of type WS2812b (1.2.1). These can be used to control different colors and effects to visually display the current status of the lock.</p>
<p>I will go into the positioning of the screws in more detail later.</p>
<p><img decoding="async" class="aligncenter wp-image-1669 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/1-2.jpg" alt="" width="2320" height="1324" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/1-2.jpg 2331w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-300x171.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-1024x584.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-768x438.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-1536x876.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-2048x1169.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/12/1-2-1400x800.jpg 1400w" sizes="(max-width: 2320px) 100vw, 2320px" /></p>
<p>Now that the components have been determined, I can think about the size of the housing. This is not only determined by the installed elements, but above all by the usability and feel.</p>
<p>We encounter keypads every day &#8211; on ATMs, telephones, door lock systems and, of course, smartphones. The decision for the depth of the housing is based on a positive memory of my penultimate workplace: the keypad lock at the entrance was raised and easily accessible from both sides. You could operate it comfortably with your right or left thumb, and the rounded corners provided a pleasant feel when you put your hand on it.</p>
<h2>Keypad lock Housing design</h2>
<p>This results in a depth of 45 mm (2.0.3). For better ergonomics, the corners have a radius of 15 mm (R15) and the surrounding upper edges have a radius of 10 mm (R10). I am aware that these roundings slightly reduce the interior space, but the comfort and appearance outweigh this disadvantage.</p>
<p>The width and height of the housing are determined by the components to be installed. The space for the cabling must also be taken into account. Particularly important: When installed, the Nano should still be accessible with a standard USB mini cable, for example to be able to install new programs.</p>
<h3>Mounting and fastening</h3>
<ul>
<li>Four M3 threads (2.0.1) on the inside allow the support plate to be screwed on.</li>
<li>In addition, there are four mounting points with Ø4.2 mm holes for attaching the housing to a door, cover or wall.</li>
<li>The housing has a window (2.0.2) measuring 60 × 67 mm, which is intended for the keypad. This is later filled with the carrier plate.</li>
<li>Retaining columns with M2 threads and the opening for the hollow socket (1.0.4) are marked with orange ellipses (2.0.1, 2.0.3).</li>
<li>The next picture (2.0.4) shows the external dimensions: 110 mm wide and 117 mm high.</li>
<li>In addition, an aperture or slot 50 mm long is required for the LED cover (2.0.5).</li>
</ul>
<p>For the wall thickness of the housing, I have provided 2 mm throughout &#8211; stable enough for the intended purpose.</p>
<p>With the housing construction completed, we can now continue with the other components.</p>
<h3 data-start="1513" data-end="1546"><img loading="lazy" decoding="async" class="aligncenter wp-image-1668 zoooom" style="font-family: 'Source Sans Pro', Graphik, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1.jpg" alt="Tastenfeldschloss Gehäuse" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/2-0-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></h3>
<h3>The support plate &#8211; the central mounting element</h3>
<p>The next important component is the carrier plate. The name is self-explanatory: With the exception of the hollow bushing, all components are attached here. This system offers several advantages over direct mounting in the housing:</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Easy mounting outside the housing &#8211; More space and better handling when wiring.<br />
<img src="https://s.w.org/images/core/emoji/16.0.1/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Modularity &#8211; different carrier plates with different components are possible.<br />
<img src="https://s.w.org/images/core/emoji/16.0.1/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Simple enclosure design &#8211; The enclosure design remains simpler and more flexible.<br />
<img src="https://s.w.org/images/core/emoji/16.0.1/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Easy replacement &#8211; Components can be replaced or extended more easily.</p>
<p>But there is another decisive advantage for the keypad lock in particular:</p>
<p>The keypad is glued directly into a designated recess in the carrier plate (2.1.1). The carrier plate and keypad are then inserted into the housing from behind and fixed in place with M3 screws. The frame of the window in the housing completely covers the edge and the cables.</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f512.png" alt="🔒" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Safety aspect: The window is dimensioned in such a way that the edge and the cables remain concealed, but the buttons are fully visible and operable. This means that the keypad cannot be removed without destroying it &#8211; an important protective mechanism against tampering.</p>
<h3>Fastening the components to the carrier plate</h3>
<p>There are various mounting options for the electronics on the back (2.1.2) of the carrier plate:</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f7e1.png" alt="🟡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> M3 thread for the nano adapter (2.1.3) &#8211; As nano adapters on the Internet often have different hole spacings, there is an additional fastening thread on the right-hand side (2.1.2) for flexible adjustment. If the holes still do not fit exactly, they can be carefully widened &#8211; but without damaging the adapter&#8217;s conductor tracks.</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f534.png" alt="🔴" class="wp-smiley" style="height: 1em; max-height: 1em;" /> M2 thread for the Nano R3 ATMEGA168P (2.1.4) &#8211; An alternative, cost-effective solution instead of a Nano R3 with adapter.</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f535.png" alt="🔵" class="wp-smiley" style="height: 1em; max-height: 1em;" /> M2 thread for the breadboard (20×80 mm, 1.1.2, 2.1.5) &#8211; This is used for power distribution and connects all power supply lines neatly at a central point.</p>
<h3 data-start="1487" data-end="1545"><img loading="lazy" decoding="async" class="aligncenter wp-image-1667 zoooom" style="font-family: 'Source Sans Pro', Graphik, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1.jpg" alt="" width="2310" height="1329" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1.jpg 2317w, https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/2-1-1-2048x1178.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></h3>
<h3>The LED cover and its attachment</h3>
<p>The LED cover (2.2.1) has been designed so that it is clicked into the slot (2.0.5) of the housing from the rear. The radius on the outside of the LED cover corresponds to the housing radius, creating a smooth transition and allowing the cover to blend in seamlessly.</p>
<p>I don&#8217;t need to redesign the mounting bridge (front 2.2.2, back 2.2.3) as I have already used it successfully in other projects.</p>
<h3>Mounting the LEDs</h3>
<p>Now it remains to mount the three WS2812b LEDs (1.2.1). I will explain why exactly three LEDs are needed later in the programming section of this article.</p>
<p>The development of the LED holder (SMD50, 2.2.4) was more complex than expected. Of course, you could simply glue, clamp or hot glue the LED strips &#8211; but that seemed too unprofessional to me.</p>
<p>I therefore invested a lot of time and effort in designing a perfect holder. The result can be seen in picture 2.2.5.</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Further information:</p>
<p data-start="1181" data-end="1300"><a href="https://nerd-corner.com/click-and-clamp-system-smd5050-bracket/">For details on the construction, there is a separate article on NerdCorner.</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1666 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/2-2-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>3D printing of the components</h2>
<p>Once the design has been completed, the parts must now be printed.</p>
<p><img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Material selection for the individual components:</p>
<ul>
<li>Housing (3.0.1): Printed with ABS filament, consisting of front and back.</li>
<li>Carrier plate (3.0.2): made from PLA filament.</li>
<li>LED cover (3.0.3): produced upright in the printer, printed with PLA+ in the color “natural”.</li>
<li>LED terminals (3.0.4): also made of PLA+, manufactured in the same process as the LED cover.</li>
<li>Bridge for the hollow socket: printed from PLA filament, analogous to the carrier plate.</li>
</ul>
<p>With these materials, the mechanical and thermal properties of the components are optimally matched to their respective applications.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1665 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1.jpg" alt="" width="2310" height="1329" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1.jpg 2317w, https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/3-0-1-2048x1178.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Post-processing of the components</h2>
<p>After printing, both the printed parts and some purchased parts need to be processed.</p>
<p>1&#x20e3; Cleaning the 3D printed parts</p>
<ul>
<li>Removal of support material and protruding print residues.</li>
</ul>
<p>2&#x20e3; Cutting the thread<br />
Housing (4.0.1):</p>
<ul>
<li>Four M3 threads (Attention: blind holes! Proceed carefully when cutting so as not to push the base outwards).</li>
<li>Two M2 threads (4.0.2).</li>
<li>Support plate (4.0.3):
<ul>
<li>The M2 threads marked in blue must be cut in any case.</li>
<li>When using a nano adapter with screw terminals (2.1.4), the M2 threads marked in red must also be cut.</li>
</ul>
</li>
</ul>
<p>3&#x20e3; Shortening the perforated grid plate</p>
<ul>
<li>The perforated grid plate (4.0.4) must be shortened to 8 to a maximum of 10 perforated grids.<br />
Important: The mounting holes should be retained (see 4.0.5).</li>
</ul>
<p>4&#x20e3; Shortening the pin header</p>
<ul>
<li>Shorten the pin header to eight pins using a side cutter (4.0.6).</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1664 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2.jpg" alt="" width="2310" height="1394" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2-300x181.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2-1024x618.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2-768x464.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2-1536x927.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/4-0-2-2048x1236.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h3>Soldering the components</h3>
<p>Now it&#8217;s time to solder the parts. First we concentrate on the power supply board:</p>
<p>1&#x20e3; Soldering the power supply board</p>
<ul>
<li>Perforated grid plate (4.0.5): Soldering the base strip (1.1.1) and the pin strip (4.0.6).</li>
<li>Pin strip (4.1.2): A two-row pin and skirting board is soldered on. We connect the two rows on the back with solder.</li>
<li>The rows differ in male and female as well as in the colors: red for plus and black for minus. This makes it easier to connect the power supply.</li>
</ul>
<p>2&#x20e3; Soldering the WS2812B LEDs</p>
<ul>
<li>Soldering the connections of the WS2812B LED strip (4.1.3).</li>
</ul>
<p>3&#x20e3; Soldering the hollow socket</p>
<ul>
<li>Finally, the hollow socket (1.0.4) is soldered (4.1.4).</li>
<li>Detailed instructions <a href="https://nerd-corner.com/using-a-barrel-jack-as-a-switch/">on soldering the hollow socket can be found</a> in a separate article. It is important to know the exact procedure in order to avoid mistakes.</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1663 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2.jpg" alt="" width="2310" height="1329" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2.jpg 2317w, https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/4-1-2-2048x1178.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2 data-start="75" data-end="118">Assembling the keypad lock</h2>
<p data-start="75" data-end="118">1&#x20e3; Installing the LED cover</p>
<ul>
<li data-start="75" data-end="118">First click the LED cover (2.2.1) into the housing.</li>
<li data-start="75" data-end="118">Glue the LED cover in the intended places as shown in pictures 5.0.1 and 5.0.2.</li>
</ul>
<p>2&#x20e3; Plug in the Nano R3</p>
<ul>
<li data-start="75" data-end="118">Insert the Nano R3 (1.0.2) into the Nano adapter (5.0.3) of your choice.</li>
</ul>
<p>3&#x20e3; Installing the Nano adapter</p>
<ul>
<li data-start="75" data-end="118">Screw the Nano adapter (1.0.3) with the inserted Nano R3 (1.0.2) to the back of the carrier plate (4.0.3).</li>
<li data-start="75" data-end="118">Use the M3 threads on the carrier plate and the screws (1.2.2), as shown in pictures 5.0.4 and 5.0.5.</li>
</ul>
<p>4&#x20e3; Attaching the power supply</p>
<ul>
<li data-start="75" data-end="118">Attach the power supply (4.1.2) to the back of the carrier plate (4.0.3) using the screws (1.2.4).</li>
<li data-start="75" data-end="118">See figure 5.0.6.</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1662 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-0-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h3 data-start="75" data-end="127">Mounting the keypad on the support plate</h3>
<p>1&#x20e3; Selecting the screw length</p>
<ul>
<li data-start="75" data-end="127">Make sure to select the correct screw length as shown in Figure 5.1.1.</li>
<li data-start="75" data-end="127">Screws must not be too long, otherwise they will protrude from the adhesive surface when the keypad is attached and the keypad cannot be glued on cleanly.</li>
</ul>
<p>2&#x20e3; Preparing the keypad</p>
<ul>
<li data-start="75" data-end="127">Remove the protective film from the keypad (1.0.1).</li>
<li data-start="75" data-end="127">To remove the film, use a carpet knife to carefully get between the adhesive layer and the protective film at one corner (see 5.1.2).</li>
<li data-start="75" data-end="127">Once you have reached the corner, peel off the entire protective film (see 5.1.3).</li>
</ul>
<p>3&#x20e3; Stick on the keypad</p>
<ul>
<li data-start="75" data-end="127">Insert the keypad (1.0.1) into the recess on the front of the carrier plate (2.1.1) and press it firmly into place.</li>
<li data-start="75" data-end="127">The keypad must be completely recessed and must not protrude over the edge (see 5.1.4).</li>
<li data-start="75" data-end="127">Make sure that the cables are also in the recess (see 5.1.5).</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1661 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1.jpg" alt="" width="2340" height="1327" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1.jpg 2350w, https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1-300x170.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1-1024x581.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1-768x436.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1-1536x871.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-1-1-2048x1162.jpg 2048w" sizes="auto, (max-width: 2340px) 100vw, 2340px" /></p>
<h3 data-start="64" data-end="123">Wiring the keypad to the Arduino Nano R3</h3>
<p>1&#x20e3; Using jumper cables</p>
<ul>
<li data-start="64" data-end="123">Jumper cables (10 cm long, male-male) are used to connect the keypad to the Arduino Nano R3 (see 5.2.1).</li>
</ul>
<p>2&#x20e3; Connecting the cables</p>
<ul>
<li data-start="64" data-end="123">Make sure that you do not twist the cables, but only bend them.</li>
<li data-start="64" data-end="123">The left cable is connected to D2 of the Arduino and the right cable to D8.</li>
<li data-start="64" data-end="123">There are seven cables in total, which occupy the connections D2 to D8 (see 5.2.3).</li>
</ul>
<p>3&#x20e3; Use pin headers</p>
<ul>
<li data-start="64" data-end="123">As the pitch of the Arduino adapter and the keypad do not match, you can use pin strips to make the connection.</li>
</ul>
<p>4&#x20e3; Fastening the LED terminals</p>
<ul>
<li data-start="64" data-end="123">The clips (3.0.4) for the WS2812B LEDs are clicked onto the LEDs.</li>
<li data-start="64" data-end="123">It is best to do this on a flat surface (see 5.2.4).</li>
</ul>
<p>5&#x20e3; Attaching the LED strip</p>
<ul>
<li data-start="64" data-end="123">The WS2812B strip is now pushed onto the center of the top of the carrier plate (see 5.2.5 Front and 5.2.6 Rear).</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1660 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-2.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-2.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/5-2-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-2-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-2-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-2-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-2-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h3>Assembling the carrier plate and housing</h3>
<p>1&#x20e3; Screwing the support plate to the housing (5.3.1)</p>
<ul>
<li>Make sure that you use M3 screws that are not too long. Otherwise, they could push a bump into the front of the housing when tightened.</li>
<li>The alignment of the carrier plate in the housing is important: the LED strip should be on the same side as the LED cover.</li>
<li>After screwing, the keypad should be lightly pressed against the inner frame of the housing (see 5.3.2 and 5.3.3).</li>
</ul>
<p>2&#x20e3; Pre-assembly of the hollow socket for the emergency power supply</p>
<ul>
<li>For the emergency power supply, you must pre-assemble the hollow socket and screw it to the housing.</li>
<li>The hollow socket with bridge and nut is shown in Figure 5.3.4.</li>
<li>Insert the hollow bush into the round recess of the bridge.</li>
<li>Lock the hollow bushing with the nut on the other side of the bridge.</li>
</ul>
<p>3&#x20e3; Fastening the hollow bush in the housing</p>
<ul>
<li>The hollow bush with the bridge is then screwed to the retaining pillars provided in the housing using M2 screws (see 5.3.5 and 5.3.6).</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1659 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-3.jpg" alt="" width="2310" height="1329" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-3.jpg 2317w, https://nerd-corner.com/wp-content/uploads/2024/12/5-3-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-3-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-3-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-3-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-3-2048x1178.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h3>Connecting the cables and completing the power supply</h3>
<p>1&#x20e3; Connecting the control cable for the servo motor</p>
<ul>
<li>The control cable for the servo motor is connected to pin D9 of the Nano R3 (5.4.1).</li>
</ul>
<p>2&#x20e3; Connecting the power supply for the Nano R3</p>
<ul>
<li>The power supply for the Nano R3 is connected to the GND pin and the VIN pin of the Nano R3 (5.4.2).</li>
</ul>
<p>3&#x20e3; Connecting the control cable for the WS2812B</p>
<ul>
<li>The control cable for the WS2812B LED strip is connected to pin D10 of the Nano R3 (5.4.3).</li>
</ul>
<p>4&#x20e3; Wiring of the power distributor</p>
<ul>
<li>All remaining cables must be connected to the power distributor:
<ul>
<li>Servo motor connection</li>
<li>Arduino Nano R3</li>
<li>WS2812B LED strip</li>
<li>Hollow socket All connections are made with plus and minus (see 5.4.4 and 5.4.5).</li>
</ul>
</li>
</ul>
<p>5&#x20e3; Using different colors and connection types for the wiring</p>
<ul>
<li>It helps to use different cable colors:
<ul>
<li>Red for plus</li>
<li>Black for minus</li>
</ul>
</li>
<li>The power distributor has different connection types:
<ul>
<li>Male for plus</li>
<li>Female for minus</li>
</ul>
</li>
</ul>
<p>6&#x20e3; Note on the hollow socket</p>
<ul>
<li><a href="https://nerd-corner.com/using-a-barrel-jack-as-a-switch/">There is a separate article on wiring and connecting the hollow socket, which you should definitely read</a></li>
</ul>
<p>7&#x20e3; Attaching the connector housings for the servo motor and power supply</p>
<ul>
<li>A three-pin plug is required for the servo motor connection.</li>
<li>A two-pin plug is required for the external power supply.</li>
</ul>
<p><a href="https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/">Further details on the construction process and the download links for connector housings can be found here.</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1658 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-4.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-4.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/5-4-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-4-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-4-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-4-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-4-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Figure 5.5.1 shows the entire cabling again.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1657 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/5-5.jpg" alt="fritzing keypad lock" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/5-5.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/5-5-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/5-5-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/5-5-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/5-5-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/5-5-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Arduino code</h2>
<p>After the intensive work with the hardware and the 3D printer, we now turn our attention to the strategy and programming of the keypad lock. Why is a strategy important for a keypad lock? A well thought-out sequence of actions &#8211; i.e. the order in which the keypad lock is operated, which events result from certain actions and which goal is being pursued &#8211; forms the basis for functional control. This guideline is therefore also crucial for programming the keypad lock: it determines what should happen when and which hardware is used. The aim is to create a logical and comprehensible sequence of events, which in this case can also be understood visually.</p>
<p>Example 1:<br />
The keypad lock should display how many digits have already been entered. (See Figures 7.0.1 to 7.0.4)</p>
<p>Example 2:<br />
The keypad lock should indicate whether the password entered is correct after pressing a specific key. (See figure 7.0.5)</p>
<p>Example 3:<br />
The keypad lock should indicate if something has been entered incorrectly, such as an incorrect password or too many keystrokes. (See figure 7.0.8)</p>
<p>Example 4:<br />
The keypad lock should display the current status. (See Figures 7.0.5 to 7.0.7)</p>
<p>Now let&#8217;s move on to programming the keypad lock, which differs from conventional programs on the Internet in a few respects. To begin with, the three necessary libraries are included: &lt;Keypad.h&gt; for the keypad, &lt;Adafruit_NeoPixel.h&gt; for the WS2812B LEDs and &lt;Servo.h&gt; for the servo motor (Figure 6.0.1). In the following section, the pin assignment for the LEDs is defined, whereby pin D10 is used and the number of LEDs and the color scheme are determined. The brightness of the LEDs is also defined &#8211; this value can be adjusted depending on the location, with higher values providing more brightness (values from 0 to 255). (See figure 6.0.2) The third section is dedicated to the description of the keypad used, including the number of rows and columns and the assignment of the buttons. (See figure 6.0.3).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1656 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/6-0-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>In the fourth section, the servomotor is configured by defining the degree range it can cover and the speed at which it should move (see Figure 6.1.1). This is followed by the section for entering the password. Here you have the option of changing the default password 1516 to set a new four-digit password. The program will only work correctly if a four-digit code is entered. In this section, the control pin for the servo motor is also set to D9 (see Figure 6.1.2). The following section is dedicated to defining the colors for the various events.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1655 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/6-1-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>The last two sections explain the behavior of the keypad lock during certain actions. This description is of course only a rough overview of the program. In a future article for keypad lock version 2, we will explain the program in more detail and more comprehensively.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">//==========================================Librarys==============================================================
#include &lt;Keypad.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;
#include &lt;Servo.h&gt;
//========================================Neo-Pixel==============================================================
#define LED_PIN 10
#define LED_COUNT 3
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int led_strength = 75; //controlls Brighttness (0 - 255)
//========================================Keypad=================================================================
const byte rows = 4;
const byte cols = 3;
char keys[rows][cols] = {
 {'1', '2', '3'},
 {'4', '5', '6'},
 {'7', '8', '9'},
 {'*', '0', '#'}
};
byte rowPins[rows] = {8, 7, 6, 5};
byte colPins[cols] = {4, 3, 2};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
//=========================================Servo============================================================
Servo lock;
int pos = 0;
int servo_angle = 180;
int servo_speed = 15;
//======================================Password===============================================================
String input;
const String password = "1516"; //Set Password
int n = 1;

 

void setup() {
 input.reserve(password.length() +2);
 strip.begin();
 strip.show();
 lock.attach(9); //motor pin
}

void loop() {
//-------------------colours------------------------------------------------------------------- 
 uint32_t blue = strip.Color(0, 0, led_strength);
 uint32_t green = strip.Color(0, led_strength, 0);
 uint32_t red = strip.Color(led_strength, 0, 0);
 uint32_t orange = strip.Color(led_strength, led_strength/2, 0);

 char key = keypad.getKey();

if (key != NO_KEY) {
//-------------------------End conditions------------------------------------------------------
 if (key == '#') {
 if (input == password) {
 //unlock
 strip.clear();
 strip.fill(green, 0, LED_COUNT);
 strip.show();
 for (pos = 0; pos &lt;= servo_angle; pos += 1) {
 lock.write(pos);
 delay(servo_speed );
 }
 while (1 == 1)
 { char key = keypad.getKey();
 strip.clear();
 strip.fill(orange, 0, LED_COUNT);
 strip.show();
 if (key == '*')
 {
 strip.clear();
 strip.fill(green, 0, LED_COUNT);
 strip.show();
 break;
 }
 }

 for (pos = servo_angle; pos &gt;= 0; pos -= 1) {
 lock.write(pos);
 delay(servo_speed );
 }
 n = 1;
 input = "";
 delay (1000);
 strip.clear();
 strip.show();
 } else {
 //wrong password
 strip.clear();
 strip.fill(red, 0, LED_COUNT);
 strip.show();
 n = 1;
 input = "";
 delay (1000);
 strip.clear();
 strip.show();
 }
 }
 else if (n == password.length() + 1) {
 //Input too long
 strip.clear();
 strip.fill(red, 0, LED_COUNT);
 strip.show();
 n = 1;
 input = "";
 delay (1000);
 strip.clear();
 strip.show();
 }
//----------------------------------Buttons------------------------------------------
 else {
 input += key;
 if (n == password.length() ) {
 strip.clear();
 strip.fill(blue, 0, LED_COUNT); 
 strip.show();
 n++;
 }
 else {

 strip.clear();
 strip.setPixelColor(n-1, blue);
 strip.show();
 n++;
 }
 }
 }

}</pre>
<h2>Function</h2>
<p>Operating the keypad lock is very intuitive. As soon as the first button is pressed, the right-hand LED lights up blue (7.0.1). When the second button is pressed, the middle LED turns blue (7.0.2). After the third button is pressed, the left-hand LED lights up blue (7.0.3). Finally, with the fourth button, all three LEDs light up blue (7.0.4). When these three LEDs light up blue, the user knows that the # button must be pressed.</p>
<p>If the # button is pressed, the password is checked. If the password is correct, all three LEDs light up green at the same time and the servomotor is activated (7.0.5). The green light remains on as long as the servomotor has not yet reached its end position (open). As soon as the servomotor reaches the end position (open), the LEDs change from green to orange (7.0.6). The orange color remains until the user presses the * button.</p>
<p>After pressing the * button, the LEDs change back to green (7.0.7) and remain in this color until the servomotor has reached the end position (closed). If this is the case, the LEDs go out and the keypad lock is ready for new entries.</p>
<p>However, if the password is incorrect after pressing the # button in step 7.0.4, all three LEDs light up red (7.0.8). The red light is also displayed if more than four buttons, apart from the # button, are pressed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1654 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1.jpg" alt="keypad lock step by step guide" width="2310" height="1329" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1.jpg 2317w, https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/7-0-1-2048x1178.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Door mounting</h2>
<p>Of course, this variant is not intended for use on an ordinary door, where you simply walk through and the door closes by itself. The reason for this is that the lock remains open until the * button is pressed. But how can you press the * button when you are on the other side of the keypad lock, behind the wall? A delay in the program could help, but who knows how long it takes to pass through the door and close it behind you? A much more sensible solution would be to implement an additional switch that is placed on the other side of the door. When pressed, this switch would lead directly to point 7.0.6 and open the lock so that the door can be opened from the inside without having to enter a password.</p>
<p>But that&#8217;s for the future. Now we come to mounting the keypad lock on a door. I have provided four holes on the back of the housing for this purpose. These holes have a recess on the inside for conventional hexagon nuts M4 DIN 934. The corresponding holes can be seen in Figure 8.0.1 (rear view) and Figure 8.0.2 (front view), whereby the housing is shown slightly transparent for better visualization. Installing the nuts is very simple: After ensuring that all support material has been removed, the nut is pressed into the recess provided from behind. Press-in nuts should not be used as they are unnecessarily expensive.</p>
<p>I have developed a drilling template for fixing to the wall or door (Fig. 8.0.3). This template contains a hole with a diameter of 4 mm at each of the four corners. The distance between the holes corresponds to the distance between the holes on the housing. The template can be easily fixed to the surface of the door, for example with adhesive tape (Fig. 8.0.4). This saves you the tedious task of marking out the drill holes and avoids errors.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1653 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/8-0-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Figure 8.1.1 shows the drilled mounting holes from the front, marked by magenta-colored circles. Thanks to the drilling template, these holes are the correct distance apart. If the position slips slightly during drilling or is not exactly correct, this is not a problem. In this case, you can simply drill the mounting holes slightly larger to align the keypad lock precisely when screwing it on. In addition, two holes can be seen in yellow circles in this picture, which are unfortunately slightly broken out at the edge. These holes are intended for the servo cable and the power supply. Once the holes had been drilled, I fitted the keypad lock and fed the cables through the holes provided on the back of the door (Fig. 8.1.2).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1652 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/8-1.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/8-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/8-1-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/8-1-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/8-1-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/8-1-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/8-1-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>The entire assembly of the keypad lock is shown on the front side of the door in Image 8.2.1. If you are not satisfied with this mounting solution, don&#8217;t worry: As a final step, I have designed a back cover that allows the keypad lock to be mounted on a wall or frame (Image 8.2.2). To do this, simply place the housing of the keypad lock onto the back cover and secure it from behind using M4 countersunk screws (marked by magenta circles in Image 8.2.2). After that, the entire construction is mounted on the wall, for which two tabs with two holes each are available (yellow circles in Image 8.2.2).</p>
<p>It is also important to remember to add one or more openings in the housing for the servo and power supply cables. Additionally, the security risk should be considered, as an unauthorized person could potentially unscrew the keypad lock using the accessible screws.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1651 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/12/8-2.jpg" alt="" width="2310" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2024/12/8-2.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/12/8-2-300x173.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/12/8-2-1024x589.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/12/8-2-768x442.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/12/8-2-1536x884.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/12/8-2-2048x1179.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h3>Locking Mechanism</h3>
<p>If you&#8217;re still missing a real locking mechanism that goes beyond just a servo connection, you can look forward to the &#8220;Locking Unit,&#8221; which is already in development and will be featured in future versions of the keypad lock.</p>
<p>The development of the keypad lock was an exciting yet challenging task. Some key features of <strong>VERSION 1</strong> of the keypad lock are particularly noteworthy:</p>
<ul>
<li><strong>Compatibility with various Arduino Nano models and adapters</strong> – Ensures flexibility in hardware selection.</li>
<li><strong>Visual feedback</strong> – Users are directly informed about number input and the status of the keypad lock.</li>
<li><strong>Emergency power supply via barrel jack</strong> – Guarantees reliable operation in case of power failures.</li>
<li><strong>Stable software</strong> – Developed to ensure reliable functionality.</li>
<li><strong>Optimized ergonomics for both left- and right-handed users</strong> – Designed for comfortable use by all users.</li>
</ul>
<h2>Files for Download</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:6840254">Keypad lock housing</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/diy-keypad-lock-3d-printing-and-code/">DIY keypad lock &#8211; 3D printing and code</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/diy-keypad-lock-3d-printing-and-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Dupont Connector V1.1</title>
		<link>https://nerd-corner.com/dupont-connector-v1-1/</link>
					<comments>https://nerd-corner.com/dupont-connector-v1-1/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Wed, 14 Aug 2024 09:10:06 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[Solid Works]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1619</guid>

					<description><![CDATA[<p>In response to the extremely positive feedback on my quick connectors (Dupont connectors), I realized that their original purpose of only being used in the &#8230; </p>
<p>The post <a href="https://nerd-corner.com/dupont-connector-v1-1/">Dupont Connector V1.1</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In response to the extremely positive feedback on my quick connectors (Dupont connectors), I realized that their original purpose of only being used in the development environment has been extended to permanent use on various devices. Many people also expressed the wish to be able to mount the connectors permanently or screw them on. I have now fulfilled this wish.</p>
<p><em><strong>You may also be interested in:</strong> <a href="https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/">3D printed Dupont connector for jumper cables</a></em></p>
<h2>Implementation of the Dupont connector</h2>
<p>As with any new development or modification of an existing part, a number of decisions had to be made, but in this case not many were necessary.</p>
<ul>
<li><strong>Number of fixing lugs:</strong> two or four</li>
<li><strong>Diameter of the fixing holes:</strong> 2.2 mm</li>
<li><strong>Cover removable after fastening:</strong> yes</li>
</ul>
<p>With the number of fixing lugs, it is clear that a single lug will cause the housing to rotate around the screw if it is not tightened firmly enough. When the connection is inserted or removed, the housing tries to rotate around the screw. With two or more tabs, insertion and removal can be achieved without any problems, even if the screws are not fully tightened.</p>
<p>The diameter of the fixing holes has been set at 2.2 mm for M2 screws. Larger screws would make the lugs larger than the connector housing itself, and two M2 screws already provide sufficient holding force.</p>
<p>The decision as to whether the cover should still be removable after the connector had been attached was inevitable. As the clamping tabs of the cover protrude from the base of the housing, the fastening tabs had to be raised above the base anyway. If the lugs were flush with the base of the housing, the lid could rise by around 0.3 mm when the screws were tightened. Why were the fixing lugs not attached directly to the lid? The lid is not stable enough to support the side tabs. The distance between the surface and the base of the housing is 1.1 mm when screwed on, which is sufficient to remove the lid without any problems.</p>
<p>Regarding the fixing holes with a diameter of 2.2 mm: The hole spacing is always a multiple of 2.54 mm, which makes sense as the DuPont plugs also have a width and height of 2.54 mm. The hole spacing increases in proportion to the number of pins on the housing. A positive side effect: These distances also match the holes of a breadboard. In Figure 1.0.1 I have mounted two 4-pin connectors on a breadboard. For the attachment, I used the matching holes at the distance of the 4-pin connectors and cut threads with an M2 tap. As you can see, the screws hold perfectly without the need for a nut.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1614 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/1_1.jpg" alt="Dupont Steckverbindung" width="2310" height="1355" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/1_1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/10/1_1-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/1_1-1024x601.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/1_1-768x451.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/1_1-1536x901.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/1_1-2048x1202.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Yes, that&#8217;s almost it for this time &#8211; we&#8217;re actually finished now, but two things are still important to me. Firstly, I would like to talk about the versatility of the connectors. I&#8217;ve been using them for four years and am constantly discovering new ways to use them flexibly. Below are some examples with version one, which is identical to version 1.1 except for the screw-on option.</p>
<p>Figure 2.0.1 shows a 10-PIN connector with a 200 mm jumper cable. Figure 2.0.2 shows the difference between a 10-PIN connector with a 100 mm jumper cable and one with a 200 mm jumper cable.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1613 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/2.jpg" alt="Dupont connector" width="2310" height="1355" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/2.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/10/2-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1024x601.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/2-768x451.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1536x901.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2048x1202.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Figure 2.1.1 shows a 9-PIN connector on one side and three different connectors on the opposite side. Figure 2.1.2 shows this side enlarged. Here you can see the three connectors: a 4-PIN connector, next to it a 3-PIN connector and on the far left a 2-PIN connector. If you add up the pins of the three connectors, you get the nine pins as on the other side.</p>
<p>You have probably noticed that the DuPont plugs of the three connections are different. On the 4-PIN connector, all pins are male, i.e. pins. In contrast, all pins on the middle 3-PIN connector are female, i.e. sockets. The 2-PIN connector, which combines a male and a female connector, is particularly interesting. What is it all about? Here I would like to demonstrate the flexibility of Nerd-Corner&#8217;s tool-free connector system. As with the 2-PIN plug, these plugs can be used to install reverse polarity protection: The pin is the positive pole, the socket is the negative pole. The reverse is true for the mating connector, which means that the connection cannot be plugged in incorrectly!</p>
<p>The 2-PIN plug is the simplest example, but this principle can be applied to all plugs so that more complex protection systems can also be set up.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1612 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/2-1.jpg" alt="dupont steckverbindung" width="2310" height="1355" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/2-1.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1-1024x601.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1-768x451.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1-1536x901.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/2-1-2048x1202.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>The structure in Figure 2.2.1 shows another way of creating a wiring harness. There is a 10-PIN connector on the left-hand side and a 5-PIN connector on the far right, connected by a 200 mm jumper cable. The orange 3-PIN connector is connected to the 10-PIN connector via a 400 mm jumper cable, as is the 2-PIN connector, but with a 500 mm jumper cable. This solution offers unlimited flexibility across the entire connector family and is completely tool-free.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1611 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/2-2.jpg" alt="dupont connector" width="2310" height="1355" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/2-2.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2-1024x601.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2-768x451.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2-1536x901.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/2-2-2048x1202.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Assembling the Dupont connector</h2>
<p>I keep getting requests to build connector housings for 15 or 22 pins. Unfortunately, this is not impossible with this system, but it is a major challenge. The effort involved is disproportionate to the benefit &#8211; at least for me. I actually wanted to stop at the 6-PIN version, as the assembly requires a lot of fine motor skills and the holding force of the tabs decreases. I was able to solve the problem of the holding force from the 7-PIN version onwards by using a third tab, but this made assembly very difficult.</p>
<p>However, there is usually a solution, as can be seen in picture series 3.0.</p>
<p>In picture 3.0.1 you can see that a female connector comes into play, as we are using male (pin) cables here. A pin header could be used instead for female cables.</p>
<p>The procedure for assembling with male cables (pins) is as follows:</p>
<ol>
<li>Push the cables into the socket strip.</li>
<li>Press the inserted DuPont housings lightly into the base of the connector and press the cables into the recesses provided (see Fig. 3.0.1).</li>
<li>Press the DuPont housings fully into the base of the housing and push them towards the internal stop strip. Then pull the cables backwards one by one &#8211; the socket strip should not be removed (Fig. 3.0.2).</li>
<li>As soon as the DuPont plugs are fixed in the housing, the cover is fitted and snapped into place (Fig. 3.0.3).</li>
<li>Finally, the socket strip is removed and the assembly is complete (Fig. 3.0.4).</li>
</ol>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1610 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/3.jpg" alt="Dupont Stecker" width="2310" height="1355" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/3.jpg 2316w, https://nerd-corner.com/wp-content/uploads/2024/10/3-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/3-1024x601.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/3-768x451.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/3-1536x901.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2048x1202.jpg 2048w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Files to download</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:6515743" target="_blank" rel="noopener">Dupont Connector 3PIN</a></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/dupont-connector-v1-1/">Dupont Connector V1.1</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/dupont-connector-v1-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>3D printed Dupont connector for jumper cable</title>
		<link>https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/</link>
					<comments>https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Fri, 27 May 2022 10:10:38 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[cables]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[Dupont]]></category>
		<category><![CDATA[dupont connector]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[jumper cable]]></category>
		<category><![CDATA[jumper cables]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1236</guid>

					<description><![CDATA[<p>Many DIY projects are accompanied by chaos at the workbench. Screwdrivers, soldering irons, jumper cables, everything lies all over the place. Clean up is usually &#8230; </p>
<p>The post <a href="https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/">3D printed Dupont connector for jumper cable</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Many DIY projects are accompanied by chaos at the workbench. Screwdrivers, soldering irons, jumper cables, everything lies all over the place. Clean up is usually only at the end of the day or when the project is finished. I was annoyed by this mess, especially the jumper cables were everywhere. After I <a href="https://nerd-corner.com/printed-connector-as-soldering-aid-for-jumper-cables-and-led-strips/" target="_blank" rel="noopener">designed a connector as a soldering aid for jumper cables</a> and LED strips, I came up with an idea with which I could both get the chaos under control and increase the stability of the jumper cable PINs. The idea was to use a Dupont connector.</p>
<p>The following picture shows such a connection. I am absolutely thrilled with how practical these connectors are in everyday life. For example, several LED strips can be connected via a 4 PIN Dupont connector to a controller without any additional tools!</p>
<p><em><strong>This might also be interesting for you: </strong><a href="https://nerd-corner.com/printed-connector-as-soldering-aid-for-jumper-cables-and-led-strips/" target="_blank" rel="noopener">designed a connector as a soldering aid for jumper cables</a></em></p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1228 aligncenter" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-inside.jpg" alt="Dupont Steckverbindung" width="388" height="269" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-inside.jpg 388w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-inside-300x208.jpg 300w" sizes="auto, (max-width: 388px) 100vw, 388px" /></p>
<h2>List of components:</h2>
<ul>
<li>3D printer</li>
<li>Filament PLA</li>
<li>Jumper cables</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1221 size-full" src="https://nerd-corner.com/wp-content/uploads/2022/05/dupont-jumper-cable-housing-gif.gif" alt="Dupont connector Steckverbindung " width="462" height="273" /></p>
<article>
<h2>CAD design for Dupont connector</h2>
<p>As with any CAD design, you shouldn&#8217;t just start off without a plan, but rather clarify a few questions first.</p>
<ul>
<li>What manufacturing tolerance do the black housings of the jumper cables have?</li>
<li>What lengths exist for the black housings?</li>
<li>Are there different cable diameters?</li>
<li>How big should the lug on the cover be?</li>
<li>Which material should be used?</li>
</ul>
<p>The measurements (with a digital caliper) from different manufacturers of the jumper cables showed that there were hardly any deviations. The biggest deviation was the length from 12 mm to 14mm. Since most of them have a length of 14 mm, this measurement was also used for my CAD design.</p>
<p>The goal was to design a quick connector, i.e. put the cable in, press the lid on and it&#8217;s done. With this I wanted to avoid screws, cable ties, hose clamps, gluing or soldering.</p>
<h4>Material and Dimensioning</h4>
<p>To achieve this, I decided to use retaining lugs or claws. For this you have to pay attention to the dimensioning and the choice of the material. Probably the best material would be nylon. Unfortunately I don&#8217;t have the possibilities to print with nylon. This would have required a closed construction space. The same goes for ABS the second best solution. That leaves only PET or PLA. I still had a larger supply of colorless PLA, so I decided to use PLA. Note at this point: The color additive in the filament influences the printing properties and not insignificantly! For functional prints I always choose colorless PLA.</p>
<p>To be able to put 4 jumper cables into the case, I chose an inner dimension of 10.6 mm. For the side walls I chose a thickness of 1.7 mm and for the bottom a thickness of 1.46 mm. The outer dimensions were 4 mm x 14 mm x 25 mm.</p>
</article>
<h4>Lid construction</h4>
<p>For the lid, the dimensions are identical to the housing, but with an addition for the protruding tabs with the lugs. The dimensions of the tabs are based on my previous experience. I decided to use a second pair of tabs because it increases the holding force and distributes the force better. Also, if one tab should break, the lid would still hold securely to the case.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1231 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel.jpg" alt="Dupont Steckerverbindung Deckel" width="2280" height="1054" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel.jpg 2285w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel-300x139.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel-1024x473.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel-768x355.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel-1536x710.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Deckel-2048x946.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<p>The shape of the lug at the end of the tab (Detail A) is important, as the 3D printer will not print this exactly as designed on the CAD.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1230 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause.jpg" alt="Dupont Steckerverbinder Deckel" width="1870" height="963" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause.jpg 1874w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause-300x154.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause-1024x527.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause-768x395.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-Stecker-Gehause-1536x791.jpg 1536w" sizes="auto, (max-width: 1870px) 100vw, 1870px" /></p>
<div>
<p>As shown in detail B, an elevation was constructed on the inside of the lid. This elevation helps to press the cables down slightly when the lid is pressed onto the housing. The cables are fixed in the housing and pull the housing towards the stopper (detail D). The additional tension secures the cable housing more precisely. This works because the pressing takes place behind the fastening in the housing and the cables have some distance to the bottom of the housing. However, the height of the pressure bar (detail B) must not be too large, otherwise the lugs of the tabs cannot click into place on the bottom of the housing.</p>
</div>
<div></div>
<div><img loading="lazy" decoding="async" class="aligncenter wp-image-1229 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht.jpg" alt="Dupont Stecker innenansicht" width="2430" height="784" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht.jpg 2437w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht-300x97.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht-1024x330.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht-768x248.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht-1536x495.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-stecker-innenansicht-2048x661.jpg 2048w" sizes="auto, (max-width: 2430px) 100vw, 2430px" /></div>
<div></div>
<div>
<div class="accordion">
<p>The roundings on the cable seat (detail C) are used for easy insertion of the cables. The apertures or also called windows were originally intended for the opposite side of a connector as a holding point. However, I discarded this because the holding torque is more than sufficient. The rectangular apertures now help with orientation during assembly.</p>
</div>
</div>
<h2>Assembly</h2>
<p>The assembly is quick and easy. The first Dupont cable is placed from the front on one of the two side panels and the cable housing is pushed to the stop (detail D). Then hold the housing and pull on the cable to eliminate any gap between the crimp connection and the cable housing. Now press the cable into the cable guide on the connector housing. Do the same with cable number 2, 3 and 4 and then press the cover onto the housing until it clicks.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1227 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through.jpg" alt="Dupont Stecker zusammengebaut" width="2360" height="1381" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through.jpg 2369w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through-300x176.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through-1024x599.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through-1536x899.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-case-look-through-2048x1198.jpg 2048w" sizes="auto, (max-width: 2360px) 100vw, 2360px" /></p>
<h2>Applications for the Dupont connector</h2>
<p>Originally I had constructed this connector design for a project with many 4PIN RGB strips. After a short time I realized how practical the design was. I can use it for the Arduino, sensors, LED strips, Raspberry Pi and much more and that without soldering or using other tools. Of course, I know that you always have to leave a gap of 2 PINs between the connectors on the Arduino, but this doesn&#8217;t really bother me in everyday life.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1222 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-examples.jpg" alt="dupont connection jumper cable examples" width="1110" height="1221" srcset="https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-examples.jpg 1116w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-examples-273x300.jpg 273w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-examples-931x1024.jpg 931w, https://nerd-corner.com/wp-content/uploads/2022/05/Dupont-jumper-cable-examples-768x845.jpg 768w" sizes="auto, (max-width: 1110px) 100vw, 1110px" /></p>
<h4>Advantages of the Dupont connector:</h4>
<ul>
<li>Quick assembly</li>
<li>Universal use</li>
<li>Enormous holding force</li>
<li>Easy to print</li>
</ul>
<h4>Disadvantages of the Dupont connector:</h4>
<ul>
<li>Greater space requirement</li>
</ul>
<h2>Download files</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:5233256" target="_blank" rel="noopener">4 PIN variant STL file</a></li>
<li><a href="https://www.thingiverse.com/thing:5243255" target="_blank" rel="noopener">3 PIN variant STL file</a></li>
<li><a href="https://www.thingiverse.com/thing:5539871">5 PIN variant STL file</a></li>
<li><a href="https://www.thingiverse.com/thing:5576023">6 PIN variant STL file</a></li>
<li><a href="https://www.thingiverse.com/thing:5576064">7 PIN variant STL file</a></li>
<li><a href="https://www.thingiverse.com/thing:5835440">6 PIN variant STL file</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/">3D printed Dupont connector for jumper cable</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/3d-printed-dupont-connector-for-jumper-cable/feed/</wfw:commentRss>
			<slash:comments>17</slash:comments>
		
		
			</item>
		<item>
		<title>Improved LM2587S voltage converter (Step-Up Modul DC-DC)</title>
		<link>https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/</link>
					<comments>https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 27 Sep 2021 21:26:22 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[DC-DC]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[LM2587S]]></category>
		<category><![CDATA[LM2596]]></category>
		<category><![CDATA[LM2596S]]></category>
		<category><![CDATA[LM317]]></category>
		<category><![CDATA[MT3608]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[S7V8A]]></category>
		<category><![CDATA[Step down]]></category>
		<category><![CDATA[Step up]]></category>
		<category><![CDATA[U3V12F12]]></category>
		<category><![CDATA[voltage]]></category>
		<category><![CDATA[voltage converter]]></category>
		<category><![CDATA[voltage regulator]]></category>
		<category><![CDATA[voltage transformer]]></category>
		<category><![CDATA[XL4015]]></category>
		<category><![CDATA[XL6009]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1078</guid>

					<description><![CDATA[<p>I found some more possibilities to use the LM2587S voltage converter (step-up DC-DC module) after the development of the first case. The module is extremely &#8230; </p>
<p>The post <a href="https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/">Improved LM2587S voltage converter (Step-Up Modul DC-DC)</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I found some more possibilities to use the LM2587S voltage converter (step-up DC-DC module) after the development of the first case. The module is extremely useful to quickly supply other devices with voltage. Originally, I just wanted to use it to charge a vacuum cleaner battery and had to set the correct volts once for that.</p>
<p>However, it is impractical to vary the voltages for different devices. First, the input jack is located at the bottom of the case, which unfortunately creates an uncomfortable angle for holding the screwdriver when adjusting the voltage and leaves little room for your fingers. Second, a multimeter is needed each time to measure the voltage. The goal of the adjustments was to improve the handling and the design.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/step-up-modul-dc-dc-lm2587s/">Development of a charging device from a LM2587S Step-Up</a> </em></p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1069 aligncenter" src="https://nerd-corner.com/wp-content/uploads/2021/09/KPL_LED.gif" alt="LM2587S Gif" width="442" height="263" /></p>
<h2>Liste der Bauteile:</h2>
<ul>
<li>1x hollow plug 5.5 x 2.1</li>
<li>1x screw socket 5.5 x 2.1</li>
<li>2x flat head screw M2x6</li>
<li>2x flat head screw M2x4</li>
<li>4x raised countersunk head screw M2x10</li>
<li>1x Module LM2587S DC-DC Step Up</li>
<li>2x Pico fuse 3A 125V / 230V</li>
<li>1x Mini Voltmeter Digital with LED display 0,36&#8243; (optional)</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1070 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-scaled.jpg" alt="LM2587S Spannungswandler Gehäuse" width="2559" height="1441" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-300x169.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-1024x577.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-768x432.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-1536x865.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210505_101908-2048x1153.jpg 2048w" sizes="auto, (max-width: 2559px) 100vw, 2559px" /></p>
<h2>Housing construction of the LM2587S voltage converter</h2>
<p>The vertical position of the socket results from the housing length. Since the power input is now to be on the back, the housing had to be longer. 12 mm was sufficient to install the socket horizontally. Due to the length of the housing, the screwdriver can easily fasten the socket on the inside.</p>
<p>Alternatively, the socket could have been rotated 90°, which would have kept the socket on the side and the length of the housing the same. However, the distance to the opposite wall would be extremely small and problems would arise when screwing. You would need an angled screwdriver or drill mounting holes in the side panel.</p>
<p>Now the bridge bushings had to be modified. Otherwise the bridge would collide with the corner at the ends. The interfering parts on the bridge were removed in CAD. The column height remains the same, since the bottom thickness and the back wall thickness are the same. The lid also had to be adapted to the length and given a cutout or socket for the mini voltmeter.</p>
<h2>The voltmeter 3631AS-1</h2>
<p>When selecting the mini <a href="https://en.wikipedia.org/wiki/Voltmeter" target="_blank" rel="noopener">voltmeter</a>, I chose the &#8220;3631AS-1&#8221; variant. This voltmeter sits on a circuit board that has tabs with holes so that you can screw it to the housing cover. On this voltmeter the cables are already soldered with the correct colors (red for plus and black for minus). To protect the voltmeter from mechanical damage, I added a frame to the case lid.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1092 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-rotated.jpg" alt="voltmeter 3631AS-1" width="700" height="1244" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-rotated.jpg 900w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-169x300.jpg 169w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-576x1024.jpg 576w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-768x1365.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163011_1-1-864x1536.jpg 864w" sizes="auto, (max-width: 700px) 100vw, 700px" /></p>
<p>The case height does not have to be changed for the LM2587S voltage converter, because there was already enough space in the previous version. The work on the CAD is definitely an advantage here, because the lid can be extended easily without a cutout for the voltmeter and you get a variant &#8220;long&#8221; for those who do not need a voltmeter, but want to have the input at the back.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1071 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-scaled.jpg" alt="LM2587S Spannungswandler CAD LM2587S voltage converter" width="2559" height="1169" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-300x137.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-1024x468.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-768x351.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-1536x701.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LED-2048x935.jpg 2048w" sizes="auto, (max-width: 2559px) 100vw, 2559px" /></p>
<p>As always, the components were produced on the 3D printer and afterwards the thread was cut (in this case M2). Soldering is very simple, like with the predecessor, and the two additional cables from the voltmeter are screwed to the OUT cables on the hollow connector according to the color.</p>
<h2>Setting and adjustment of the LM2578S voltage converter</h2>
<p>Now to the adjustment of the LM2587S voltage transformer. Here was mainly the accuracy of the voltmeter interesting. Generally the adjustment should be done under load. That means with a connected load (e.g. a resistor). I repeated the measurements several times and was amazed about the accuracy of the mini voltmeter.</p>
<p>The maximum deviation was less than 0.04 V and this even with different input voltages. The device has been extensively tested from 4 V to 32 V. I recommend not using more than 30V output voltage for operation during longer operation, because the voltmeter is not suitable for higher voltages on a long-term basis.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1091 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-scaled.jpg" alt="volt meter" width="1000" height="1775" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-scaled.jpg 1442w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-169x300.jpg 169w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-577x1024.jpg 577w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-768x1364.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-865x1536.jpg 865w, https://nerd-corner.com/wp-content/uploads/2021/09/IMG_20210510_163254-1-1153x2048.jpg 1153w" sizes="auto, (max-width: 1000px) 100vw, 1000px" /></p>
<p>Of course, the contact resistance is important, because each additional connector reduces the voltage. Therefore follows:</p>
<ul>
<li>Avoid unnecessary plug connections</li>
<li>Always measure voltage at the last connection</li>
</ul>
<h2>Safety aspect</h2>
<p>The safety should not be forgotten either, since the step-up in contrast to the step-down has an open circuit, it should be provided with a fuse! At my step-up I have subsequently attached (unfortunately not visible in the photos) a lazy pico fuse with 3A at the positive terminal on both the input voltage and the output voltage. Thus, you can start using it!</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1073 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/LM2587SlongLedAbm.jpg" alt="LM2587S Spannungswandler Bauplan LM2587S voltage converter" width="1239" height="729" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/LM2587SlongLedAbm.jpg 1240w, https://nerd-corner.com/wp-content/uploads/2021/09/LM2587SlongLedAbm-300x177.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/09/LM2587SlongLedAbm-1024x603.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/09/LM2587SlongLedAbm-768x452.jpg 768w" sizes="auto, (max-width: 1239px) 100vw, 1239px" /> <img loading="lazy" decoding="async" class="aligncenter wp-image-1072 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LangAbm1.jpg" alt="LM2587S Spannungswandler Bauplan LM2587S voltage converter" width="1239" height="754" srcset="https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LangAbm1.jpg 1240w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LangAbm1-300x183.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LangAbm1-1024x623.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/09/Kpl_LangAbm1-768x468.jpg 768w" sizes="auto, (max-width: 1239px) 100vw, 1239px" /></p>
<h2>Download files:</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:4976242">STL files for 3D printing (with voltmeter)</a></li>
<li><a href="https://www.thingiverse.com/thing:4976248">STL files for 3D printing (long version without voltmeter)</a></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/">Improved LM2587S voltage converter (Step-Up Modul DC-DC)</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Upgrade: Data transfer via VLC and LiFi &#8211; Pi to Pi transfer</title>
		<link>https://nerd-corner.com/upgrade-data-transfer-via-vlc-and-lifi-pi-to-pi-transfer/</link>
					<comments>https://nerd-corner.com/upgrade-data-transfer-via-vlc-and-lifi-pi-to-pi-transfer/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 08 Jul 2021 14:27:07 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[cyclic redundancy check]]></category>
		<category><![CDATA[data transfer]]></category>
		<category><![CDATA[fan]]></category>
		<category><![CDATA[LiFi]]></category>
		<category><![CDATA[LiFI Router]]></category>
		<category><![CDATA[Light Fidelity]]></category>
		<category><![CDATA[LM393]]></category>
		<category><![CDATA[pi]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Timer]]></category>
		<category><![CDATA[visible Light communication]]></category>
		<category><![CDATA[visible light communication project]]></category>
		<category><![CDATA[VLC Raspberry Pi project]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=985</guid>

					<description><![CDATA[<p>After I already transferred simple text messages via light signals from a Raspberry Pi to an Arduino Uno ( Link: https://nerd-corner.com/sending-text-messages-with-visible-light-communication/ ), I wanted to &#8230; </p>
<p>The post <a href="https://nerd-corner.com/upgrade-data-transfer-via-vlc-and-lifi-pi-to-pi-transfer/">Upgrade: Data transfer via VLC and LiFi &#8211; Pi to Pi transfer</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After I already transferred simple text messages via light signals from a Raspberry Pi to an Arduino Uno ( Link: <a href="https://nerd-corner.com/sending-text-messages-with-visible-light-communication/" target="_blank" rel="noopener">https://nerd-corner.com/sending-text-messages-with-visible-light-communication/</a> ), I wanted to improve this system to be able to transfer any file formats in both directions. Since a Raspberry Pi uses Linux, this system can be transferred to any Linux device for data transfer via VLC (visual light communication). The software code and STL files can be downloaded at the end of the blog entry.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/sending-text-messages-with-visible-light-communication/" target="_blank" rel="noopener">Sending text messages with light signals</a></em></p>
<p><em><strong>Closely related to this article:</strong> <a href="https://nerd-corner.com/cyclic-redundancy-check-in-c-code/" target="_blank" rel="noopener">Error detection during data transmission</a></em></p>
<p><em><strong>Also relevant:</strong> <a href="https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/" target="_blank" rel="noopener">Precise Timer in C for data transfer</a></em></p>
<h2>List of components</h2>
<ul>
<li>2x Raspberry Pi 4</li>
<li>2x 5V Solar cell</li>
<li>2x 5V Laser diode</li>
<li>Jumper cables</li>
<li>3D printer</li>
<li>Filament</li>
<li>2x 5V Fan</li>
<li>NPN Transistor</li>
<li>2x ADC Board with a LM393 dual comparator</li>
</ul>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-966" src="https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-scaled.jpg" alt="Datenübertragung mit Licht Einzelteile Data transfer via VLC" width="2500" height="1681" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-300x202.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-1024x689.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-768x516.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-1536x1033.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-parts-2048x1377.jpg 2048w" sizes="auto, (max-width: 2500px) 100vw, 2500px" /></p>
<h2>Wiring</h2>
<p>Unlike the wiring in the last article, where text messages were sent from a Pi to an Arduino via light signals ( Link: <a href="https://nerd-corner.com/sending-text-messages-with-visible-light-communication/" target="_blank" rel="noopener">https://nerd-corner.com/sending-text-messages-with-visible-light-communication/</a> ), there is now no defined receiver and no defined transmitter. Instead, two identical stations are set up that can both send and receive data.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-965 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine.png" alt="Fritzing Pi VLC LiFI" width="2250" height="1459" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine.png 2270w, https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine-300x195.png 300w, https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine-1024x664.png 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine-768x498.png 768w, https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine-1536x996.png 1536w, https://nerd-corner.com/wp-content/uploads/2021/07/FritzingPiTransceiver_Steckplatine-2048x1328.png 2048w" sizes="auto, (max-width: 2250px) 100vw, 2250px" /></p>
<p>For this reason, the Raspberry Pi&#8217;s are connected to both a 5V laser and a 5V solar cell. For the laser the GPIO18 pin was chosen, which corresponds to pin 1 in the &#8220;wiringPi&#8221; library. The &#8220;wiringPi&#8221; library is used in the program code. Directly below GPIO18 is a ground, which is connected to the negative pole of the laser.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-967 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/07/GPIO.png" alt="Datenübertragung mittels Licht Pi" width="1500" height="1125" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/GPIO.png 1600w, https://nerd-corner.com/wp-content/uploads/2021/07/GPIO-300x225.png 300w, https://nerd-corner.com/wp-content/uploads/2021/07/GPIO-1024x768.png 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/GPIO-768x576.png 768w, https://nerd-corner.com/wp-content/uploads/2021/07/GPIO-1536x1152.png 1536w" sizes="auto, (max-width: 1500px) 100vw, 1500px" /></p>
<p>The solar cell provides a corresponding voltage value depending on the light intensity. But since the digital pins of the Raspberry Pi can only recognize 1 and 0, the analog value of the solar cell must be converted into a digital value with the help of a comparator. The process is explained in more detail in the section &#8220;ADC Board with an LM393 Comparator&#8221;. For the wiring, the plus and minus pole of the solar cell is connected to the plus and minus contacts of the ADC board. Then the ground of the ADC board is connected to a Raspberry Pi ground and for the power supply the plus pole of the ADC board is connected to 5V of the Pi. The D0 pin of the ADC board provides the digital value 0 or 1, depending on the light intensity of the solar cell. I connected this pin to GPIO17, which corresponds to pin 0 in the &#8220;wiringPi&#8221; library.</p>
<p>Since I noticed that the Pi gets very hot during operation, I connected a fan. So that the fan is not permanently in operation, which would have a negative effect on the performance of the laser, the fan can be switched on and off by a NPN transistor. Connect the positive pole of the fan directly to a 5V pin of the Raspberry Pi and the negative pole of the fan to the emitter of the NPN transistor. The collector of the transistor is connected to a ground of the Pi. To switch the fan on and off via the transistor, the transistor base is connected to a GPIO pin. For example I chose GPIO27 (corresponds to pin 2 in the &#8220;wiringPi&#8221; library). In the following table the pins of the Pi are compared to the numbering of the &#8220;wiringPi&#8221; library.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-940 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/06/pinbelegung-Pi.png" alt="VLC Textnachrichten visuelle Lichtkommunikation wiringPi Datenübertragung mit Licht" width="599" height="295" srcset="https://nerd-corner.com/wp-content/uploads/2021/06/pinbelegung-Pi.png 600w, https://nerd-corner.com/wp-content/uploads/2021/06/pinbelegung-Pi-300x148.png 300w" sizes="auto, (max-width: 599px) 100vw, 599px" /></p>
<h2>ADC Board with a LM393 camparator</h2>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-968 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/07/ADC-LM393.jpg" alt="ADC Board mit LM393 Komparator" width="450" height="319" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/ADC-LM393.jpg 771w, https://nerd-corner.com/wp-content/uploads/2021/07/ADC-LM393-300x213.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/07/ADC-LM393-768x545.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/07/ADC-LM393-120x85.jpg 120w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
<p>The solar cell returns a voltage value depending on the light intensity. Unfortunately the Raspberry Pi has no analog pins to read this voltage value. Therefore the analog signal has to be converted into a digital signal. This is possible with the help of the LM393 comparator. The comparator is often used on ADC boards. Here I simply replaced the original sensor (it was a photoresistor) through a solar cell. With the help of a potentiometer the comparator can be adjusted. That means, as soon as the voltage value of the solar cell, which depends on the light intensity, exceeds the adjusted value of the potentiometer, a digital 1 is measured, otherwise a digital 0.</p>
<h2>Structure of the data frame</h2>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-969" src="https://nerd-corner.com/wp-content/uploads/2021/07/MultipleFrames-1.jpg" alt="Aufbau Datenframe Lichtübertragung Daten Datentransfer mittels VLC" width="1300" height="469" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/MultipleFrames-1.jpg 1409w, https://nerd-corner.com/wp-content/uploads/2021/07/MultipleFrames-1-300x108.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/07/MultipleFrames-1-1024x369.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/MultipleFrames-1-768x277.jpg 768w" sizes="auto, (max-width: 1300px) 100vw, 1300px" /></p>
<p>The data frame for sending the text messages using visual light communication (Link: <a href="https://nerd-corner.com/sending-text-messages-with-visible-light-communication/" target="_blank" rel="noopener">https://nerd-corner.com/sending-text-messages-with-visible-light-communication/ </a>) consisted of a preamble, the length of the text message, the text content and the cyclic redundancy check. However, to be able to send all kinds of data instead of text messages, the file name, the file extension, the total number of packets and the number of the current packet must be specified instead of the length of the text message. Then the data content and the code of the cyclic redundancy check can be added.</p>
<h2>Software code for data transfer via VLC</h2>
<p>Basically, the receiver and sender scripts from the previous project on sending text messages using visual light communication (link: https://nerd-corner.com/de/textnachrichten-mittels-lichtsignale-senden-pi-zu-arduino/ ) were further developed and combined into one single script. Which is applied on both Raspberry Pi&#8217;s. For example, a &#8220;ReadFile&#8221; and &#8220;WriteFile&#8221; function was added, which can read files and combine and save received data packets to a file. The program was written in C again, because a high speed of data transfer should be achieved. Details about precise programming in C for fast data transfer are given in this article: <a href="https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/" target="_blank" rel="noopener">https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/</a> .</p>
<p>The complete software code for data transfer using VLC can be downloaded at the end of the article. The core of the program is again a state machine with the help of which can be selected whether data should be sent or received. In addition, the program automatically turns on the fan when no data transfer is taking place. Important: When compiling please do not forget the &#8220;wiringPi&#8221; library and the &#8220;math.h&#8221; library! The command is: &#8220;gcc -o transceiver transceiver.c -lwiringPi -lm&#8221;.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" data-enlighter-group="transceiver" data-enlighter-title="transceiver.c">while(1)
    {
        digitalWrite (2, HIGH);
        printf("Press the R button for Receiver Mode or any other key for Sender Moden");
        scanf(" %c",&amp;mode);
        
        if (mode=='R'||mode=='r')
        {
            digitalWrite(2,LOW);
            modeReceiver=true;
        }
        
        if (mode!='R'&amp;&amp;mode!='r')
        {
            digitalWrite(2,LOW);
            modeReceiver=false;
            
            char dataName[NAME_MAX];
            char dataExtension[NAME_MAX];
            
               
            printf("n Name of file WITHOUT extension: ");
            scanf("%s",dataName);

            printf("n Extension: ");
            scanf("%s",dataExtension);

            if (read_file(dataName, dataExtension, file_content) != OK)
            {
                printf("File read error, size exceeds array sizen");
                return -1;
            }
            BuildDataFrame(dataName, dataExtension, file_content);
        }
        
        
        
        while(modeReceiver)
        {
            gettimeofday(&amp;tval_after, NULL);
            timersub(&amp;tval_after, &amp;tval_before, &amp;tval_result);
            double time_elapsed = (double)tval_result.tv_sec + ((double)tval_result.tv_usec/1000000.0f);
            
            while(time_elapsed &lt; 0.001)
            {
                gettimeofday(&amp;tval_after, NULL);
                timersub(&amp;tval_after, &amp;tval_before, &amp;tval_result);
                time_elapsed = (double)tval_result.tv_sec + ((double)tval_result.tv_usec/1000000.0f);
            }
            gettimeofday(&amp;tval_before, NULL);
            
            int data = digitalRead(0);
            
            
            switch (state)
            {
                case 0:
                    //looking for preamble pattern
                    synchro_Done=false;
                    LookForSynchro(data);
                    
                    if (synchro_Done==true)
                    {
                        state=1;
                    }
                    break;
                    
                case 1:
                    //receive the actual data
                    receiveData_Done=false;
                    senderState=false;
                    ReceiveData(data);
                    
                    if(receiveData_Done&amp;&amp;senderState==false)
                    {
                        state=0;
                    }
                    if(senderState==true){
                        senderState=false;
                        state=0;
                        modeReceiver=false;
                        }
                    break;
                  
            }
            
        }
    }</pre>
<h2>Housing</h2>
<p>In order to be able to hold the components in place, a housing was constructed in CAD. This also has the advantage that no complicated alignment of the lasers and the solar cells is necessary for the data transmission. For beginners, <a href="https://www.tinkercad.com/" target="_blank" rel="noopener">TinkerCAD</a> is suitable for housing design. TinkerCAD is free and can be used directly in the browser. Alternatively, the STL files for the 3D printer can also be downloaded here.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-970" src="https://nerd-corner.com/wp-content/uploads/2021/07/gehaeuse-CAD.jpg" alt="Datenübertragung per Licht Gehäuse Datentransfer mittels VLC" width="600" height="530" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/gehaeuse-CAD.jpg 682w, https://nerd-corner.com/wp-content/uploads/2021/07/gehaeuse-CAD-300x265.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p>The housing for data transfer via VLC has an opening for the solar cell and the laser. In addition, an exhaust vent for the fan was constructed and space was also left free for a Raspberry Pi housing. The following picture shows the installation of the components.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-971 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-scaled.jpg" alt="Datenübertragung per Licht Lifi VLC" width="2500" height="1875" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-300x225.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-1024x768.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-768x576.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-1536x1152.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2021/07/assembly-end-2048x1536.jpg 2048w" sizes="auto, (max-width: 2500px) 100vw, 2500px" /></p>
<h2>Conclusion about data transfer via VLC</h2>
<p>The existing system for sending text messages by means of visual light signals was further developed so that all types of data can now be sent and received. The system works amazingly successfully. It is very robust and achieves a data rate of 1 kbps to 10 kbps. All incoming data packets can be directly assigned due to the intelligent structure of the data frame. Only an acknowledgement signal would be a useful addition. Such a signal would be a feedback from the receiver to the sender to inform the sender that all packets have arrived, or possibly a certain packet was faulty and must be sent again.</p>
<p>Also interesting for the future would be to investigate other types of modulation. In particular, I would like to explore color shift keying, which is specifically designed for visual light communication, and compare the resulting data rates.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-972" src="https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-scaled.jpg" alt="Datenübertragung per Licht Gehäuse Lifi VLC Datentransfer mittels VLC" width="2500" height="1125" srcset="https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-300x135.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-1024x461.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-768x346.jpg 768w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-1536x691.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2021/07/Assembly-finish-2048x922.jpg 2048w" sizes="auto, (max-width: 2500px) 100vw, 2500px" /></p>
<h2>Download files:</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/977/?tmstv=1756236028" rel="nofollow" id="download-link-977" data-redirect="false" >
	Softwarecode Transceiver</a>
</li>
<li><a href="https://cults3d.com/en/3d-model/various/visible-light-communication-pi-housing" target="_blank" rel="noopener">STL files housing</a></li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/991/?tmstv=1756236028" rel="nofollow" id="download-link-991" data-redirect="false" >
	Pi Case with free pins (Creative Common License from Thingiverse)</a>
</li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/upgrade-data-transfer-via-vlc-and-lifi-pi-to-pi-transfer/">Upgrade: Data transfer via VLC and LiFi &#8211; Pi to Pi transfer</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/upgrade-data-transfer-via-vlc-and-lifi-pi-to-pi-transfer/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>How to program a highly precise timer in C for Linux</title>
		<link>https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/</link>
					<comments>https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Sat, 27 Feb 2021 13:42:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[C Timer]]></category>
		<category><![CDATA[communication technique]]></category>
		<category><![CDATA[data transfer]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Timer]]></category>
		<category><![CDATA[Timer in C]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=831</guid>

					<description><![CDATA[<p>I wanted to program a timer in C for my Raspberry Pi, which executes precise work instructions for 1 ms as well as for 0.1 &#8230; </p>
<p>The post <a href="https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/">How to program a highly precise timer in C for Linux</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I wanted to program a timer in C for my Raspberry Pi, which executes precise work instructions for 1 ms as well as for 0.1 ms. Unfortunately, since Python is compiled at runtime, Python was way too slow for this purpose. For this reason, the program was written in C. The 1 ms and 0.1 ms were confirmed after programming with the help of an oscilloscope.</p>
<p>In the following is an explanation why the library &#8220;sys/time.h&#8221; was used, as well as a code example with subsequent explanation. This code example is very well suited for bit-wise data transmission in communication technology.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/" target="_blank" rel="noopener">How to program a highly precise Arduino Timer</a></em></p>
<h2>List of components</h2>
<ul>
<li>Linux operating system (for example Raspberry Pi)</li>
<li>Editor for C &#8211; Programming</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-848 zoooom" src="https://nerd-corner.com/wp-content/uploads/2021/02/proxy-image-3-1.jpg" alt="Timer in C" width="484" height="392" srcset="https://nerd-corner.com/wp-content/uploads/2021/02/proxy-image-3-1.jpg 1084w, https://nerd-corner.com/wp-content/uploads/2021/02/proxy-image-3-1-300x243.jpg 300w, https://nerd-corner.com/wp-content/uploads/2021/02/proxy-image-3-1-1024x830.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2021/02/proxy-image-3-1-768x623.jpg 768w" sizes="auto, (max-width: 484px) 100vw, 484px" /></p>
<p>&nbsp;</p>
<h2>The library „sys/time.h“</h2>
<p>Functions like &#8220;usleep()&#8221; or &#8220;nanosleep()&#8221; would stop the complete program. For simple applications this might be sufficient, but for my purposes this was too imprecise. I wanted a timer that really works exactly in a 1 ms or 0.1 ms cycle. So instead of &#8220;usleep()&#8221; or &#8220;nanosleep()&#8221; another solution was chosen. The library &#8220;sys/time.h&#8221;. This library is able to read and compare the current &#8220;System Clock Time&#8221;.</p>
<h2>Code example for a precise timer in C</h2>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include &lt;sys/time.h&gt;

int main()
{
    struct timeval tval_before, tval_after, tval_result;
    int counter=0;
    bool stop=false;
   
    gettimeofday(&amp;tval_before, NULL);
    while(stop!=true)
    {
        gettimeofday(&amp;tval_after, NULL);
        timersub(&amp;tval_after, &amp;tval_before, &amp;tval_result);
        double time_elapsed = (double)tval_result.tv_sec + ((double)tval_result.tv_usec/1000000.0f);
        
        while(time_elapsed &lt; 0.001)  //1ms; you can change your desired time interval here
        {
            gettimeofday(&amp;tval_after, NULL);
            timersub(&amp;tval_after, &amp;tval_before, &amp;tval_result);
            time_elapsed = (double)tval_result.tv_sec + ((double)tval_result.tv_usec/1000000.0f);
        }
        gettimeofday(&amp;tval_before, NULL);
        
        if (counter==10000)
        {
            stop=true;
        }
            
        else 
        {
            counter++;
        }
    }
    return 0;
}
</pre>
<h2>Explanation of the code example:</h2>
<p>A function &#8220;gettimeofday&#8221; writes the current system time into the variable &#8220;tval_before&#8221;. A While loop will then be executed until the actual task is completed.</p>
<p>Within the While loop the system time is stored again into a variable &#8220;tval_after&#8221;. Then the time difference between &#8220;tval_after&#8221; and &#8220;tval_before&#8221; is measured and stored in &#8220;tval_result&#8221;.</p>
<p>The next step of the timer in C is not immediately obvious: &#8220;tv_result&#8221; consists by definition of 2 parts. On the one hand a seconds part &#8220;.tv_sec&#8221; and on the other hand a microseconds part &#8220;.tv_usec&#8221;. This microsecond part has to be divided by one million to get the value in seconds. Afterwards, the microsecond part can be added to the second part.</p>
<p>The added value is called &#8220;time_elapsed&#8221;. If this value is less than one millisecond, another inner While loop is opened, which recalculates the value for &#8220;time_elapsed&#8221; until exactly 1 ms has passed. Afterwards, the value for &#8220;tval_before&#8221; is redefined using the &#8220;gettimeofday&#8221; function.</p>
<p>Since exactly 1 ms has passed at this point, the timer can now perform its actual operation. In this simple code example the variable &#8220;counter&#8221; is incremented by 1. That means for each interval step (in the code example 1 ms) the counter increases by 1. As soon as a fixed value for counter was reached the program stops. In this case the defined value is 10000. Then the While loop will be terminated. But this part of the code can be easily changed for your own purposes.</p>
<p>My measurements with an oscilloscope detected an exact frequency of 1 ms, even 0.1 ms was measured exactly. This code example is therefore also very suitable for an exact <a href="https://en.wikipedia.org/wiki/Data_transmission" target="_blank" rel="noopener">data transmission</a> in the communication technology.</p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/835/?tmstv=1756236028" rel="nofollow" id="download-link-835" data-redirect="false" >
	Downloadfile Timer in C</a>
</li>
</ul>
<p>The post <a href="https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/">How to program a highly precise timer in C for Linux</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/how-to-program-a-highly-precise-timer-in-c-for-linux/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Arduino Timer Interrupts – How to program Arduino registers</title>
		<link>https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/</link>
					<comments>https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 26 Nov 2020 21:30:19 +0000</pubDate>
				<category><![CDATA[Arduino projects]]></category>
		<category><![CDATA[Arduino Uno]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[delay()]]></category>
		<category><![CDATA[Interrupts]]></category>
		<category><![CDATA[Millis()]]></category>
		<category><![CDATA[OCR1A]]></category>
		<category><![CDATA[precise]]></category>
		<category><![CDATA[registers]]></category>
		<category><![CDATA[Timer]]></category>
		<category><![CDATA[Timer Interrupts]]></category>
		<category><![CDATA[Timer1]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=781</guid>

					<description><![CDATA[<p>If you want to achieve a regular time interval with the Arduino you can simply use the delay() function. This will pause the program of &#8230; </p>
<p>The post <a href="https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/">Arduino Timer Interrupts – How to program Arduino registers</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you want to achieve a regular time interval with the Arduino you can simply use the delay() function. This will pause the program of the Arduino for the appropriate amount of time. If the requirements are higher you can also use millis() or nanos() as timer. The delay() and millis() functions are probably sufficient for most applications, but if you don&#8217;t want to pause the whole program or achieve a 100% exact clock time it makes sense to use Arduino Timer Interrupts. We explain what timer interrupts are and how to use them. You can find the Arduino code at the end of the post.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/" target="_blank" rel="noopener noreferrer">How to control an Arduino via Bluetooth</a></em></p>
<h2>List of components</h2>
<ul>
<li>Arduino Uno</li>
<li>LED</li>
<li>220 Ohm resistor</li>
<li>Wires</li>
<li>Breadboard</li>
</ul>
<h2>What is a timer actually?</h2>
<p>A timer is basically nothing else than a certain register in the microcontroller, which is increased (or decreased) continuously by 1 under hardware control. Instead of coding instructions in the program that are executed regularly and increment a register by 1, the microcontroller does this all by itself!</p>
<p>This becomes useful, if an action is executed at certain counter values. One of these &#8216;certain counts&#8217; is for example the overflow. The count register of a timer can not be incremented arbitrarily long. E.g. the highest count that an 8-bit-timer can reach is 2^8 &#8211; 1 = 255. The next incrementing step is not 256, instead an overflow occurs, which makes the timer become 0 again. This is the magic! We can configure the controller so that an interrupt is triggered when the timer overflow occurs. We can write code in the Arduino program what should happen in case of an interrupt. For example, we can make an LED light up or query a certain sensor value.</p>
<h2>Arduino Uno Microcontroller ATMEGA328P</h2>
<p><img loading="lazy" decoding="async" class="alignright wp-image-784 size-medium zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/11/ATMEGA328P-300x274.jpg" alt="Microcontroller ATMEGA328P Nerd Corner Arduino Uno Timer Interrupts" width="300" height="274" srcset="https://nerd-corner.com/wp-content/uploads/2020/11/ATMEGA328P-300x274.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/11/ATMEGA328P.jpg 466w" sizes="auto, (max-width: 300px) 100vw, 300px" />The ATMEGA328P microcontroller is the heart of the Arduino Uno board. (ATTENTION: The Arduino Mega e.g. has a different microcontroller!) The ATMEGA328P microcontroller has 3 timers (<a href="https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf">datasheet</a>) which are partly used in Arduino functions and/or partly in libraries. Overwriting the timer registers can therefore lead to complications with existing timer functions like millis(), micros() or delay() and should be used with caution. The 3 timers are Timer0 (8Bit), Timer1 (16Bit) and Timer2 (8Bit).</p>
<ul>
<li>8 Bit-Timer0: used for functions millis(), micros(), delay() and for PWM at pin D5 and D6</li>
<li>16 Bit Timer1: Use e.g. for the Servo, VirtualWire and TimerOne library and for PWM at pin D9 and D10</li>
<li>8 Bit Timer2: Used for function tone() and for PWM at pin D3 and D11</li>
</ul>
<h2>How to vary the clock speed?</h2>
<p>The system clock of the Arduino Uno is 16 MHz (CPU frequency). This means Timer0, Timer1 and Timer2 increase 16 million times per second. For example, the 8 bit timers count from 0 to 255 each time. At 256 an overflow occurs and the timers start again from 0. This means 16000000/256 = 62500 overflows per second (62.5kHz clock rate). This is likely too fast for most timer applications!</p>
<p>Therefore there is a trick to slow down the clock rates. You use a so-called prescaler. A prescaler can be set to the values 1, 8, 64, 256 or 1024. It allows you to divide the system clock (16MHz) by the selected factor and set a lower clock rate for the timers. For example, a prescaler of 1024 would increase the timer registers by 1 only at the 1024th system clock pulse. This would be 16000000/1024=15625 increments per second and thus with an 8 bit timer 15625/256= 61.035 overflows per second (~61 Hz clock rate of the timer).</p>
<h2>Practical example LED should light up with 50Hz</h2>
<p>In the following, the triggering of Arduino Timer Interrupts is shown with the 16-bit timer1. With this a LED should light up in a 50 Hz cycle. Schematic, Arduino code and pictures are also included. (The procedure for the 8 bit timer0 and timer2 is analog.) For the time controlled pulse you need the so called &#8220;CTC Mode&#8221;.</p>
<p>In CTC mode (&#8220;Clear Timer on Compare Mode&#8221;) the counter is cleared when the value of the counter (TNCT1) matches either the value of the OCR1A register or the value of the ICR1 register (in our case OCR1A). So the OCR1A register determines the maximum value of the counter and thus its resolution.</p>
<h3>The 16 Bit Timer1 needs the following registers</h3>
<ul>
<li>Timer Counter Register 1: TCNT1</li>
<li>Output Compare Register A: OCR1A</li>
<li>Timer Counter Control Register A: TCCR1A</li>
<li>Timer Counter Control Register B: TCCR1B</li>
<li>Timer/Counter Interrupt Mask Register: TIMSK1</li>
<li>(For Timer0 and Timer2 the corresponding registers would be TCNT0 and TCNT2, respectively)</li>
</ul>
<h3>Calculate the OCR1A register for Arduino Timer Interrupts</h3>
<p>The value of the OCR1A register depends on the desired interrupt frequency and the selected prescaler. The following formula applies:</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-783 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/11/InterruptFrequency.jpg" alt="Formula for Arduino Timer Interrupt Frequency calculation OCR1A register" width="691" height="156" srcset="https://nerd-corner.com/wp-content/uploads/2020/11/InterruptFrequency.jpg 692w, https://nerd-corner.com/wp-content/uploads/2020/11/InterruptFrequency-300x68.jpg 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /></p>
<p>We put our specifications into the formula:</p>
<ul>
<li>CPU frequency Arduino Uno: 16.000.000 Hz</li>
<li>Desired interrupt frequency: 50 Hz (= 20 ms period duration)</li>
<li>Possible prescaler: 1, 8, 64, 256 or 1024</li>
</ul>
<p><strong>Calculation example with Prescaler 1024:</strong><br />
OCR1A= (16.000.000 / (1024 * 50)) &#8211; 1 = 311,5</p>
<p><strong>Calculation example with Prescaler 8:</strong><br />
OCR1A= (16,000,000 / (8 * 50)) &#8211; 1 = 39,999</p>
<p><strong>ATTENTION:</strong> The OCR1A value must be less than 65.536 (2^16 )!</p>
<p><strong>Therefore a prescaler 8 can NOT reach 10Hz interrupt frequency:</strong><br />
OCR1A= (16.000.000 / (8 * 10)) &#8211; 1 = 199.999</p>
<p>The value 199.999 is larger than the register with 65.536, therefore another prescaler must be used to reach 10 Hz</p>
<p><strong>Instead a prescaler 64 for 10 Hz interrupt frequency:</strong><br />
OCR1A= (16.000.000 / (64 * 10)) &#8211; 1 = 24.999</p>
<p><em>If a Timer1 interrupt is now triggered, the program flow jumps to an interrupt service routine to be created &#8220;ISR(TIMER1_COMPA_vect)&#8221;. (See Arduino Code)</em></p>
<h3>Bit combination for the desired prescaler</h3>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-785 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterrupts.jpg" alt="Arduino Uno timer interrupts Prescaler " width="1121" height="413" srcset="https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterrupts.jpg 1122w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterrupts-300x110.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterrupts-1024x377.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterrupts-768x283.jpg 768w" sizes="auto, (max-width: 1121px) 100vw, 1121px" /></p>
<h3>Arduino Timer Interrupts code for 50 Hz frequency</h3>
<pre class="EnlighterJSRAW" data-enlighter-language="c">void setup() {

  pinMode(11,OUTPUT);  //LED pin (to blink in 50Hz frequency)
  
//START TIMER SETUP
//TIMER SETUP for highly preceise timed measurements 

  cli();//stop all interrupts

  // turn on CTC mode
  TCCR1A = 0;// set entire TCCR1A register to 0
  TCCR1B = 0;// same for TCCR1B
  TCCR1B |= (1 &lt;&lt; WGM12);

  // Set CS11 bit for prescaler 8
  TCCR1B |= (1 &lt;&lt; CS11); 
  
  //initialize counter value to 0;
  TCNT1  = 0;
  
  // set timer count for 50Hz increments
  OCR1A = 39999;// = (16*10^6) / (50*8) - 1  
  
  // enable timer compare interrupt
  TIMSK1 |= (1 &lt;&lt; OCIE1A);
  
  sei();//allow interrupts
  //END TIMER SETUP
}



ISR(TIMER1_COMPA_vect) {//Interrupt at frequency of 50 Hz
 //write your timer code here

 digitalWrite(11,HIGH);
 delay(15);
 digitalWrite(11,LOW);
}




void loop() {

//when the timer is over, your program will stop in the loop function and jump to the timer code. 
//After the timer code it will jump back to the point where it left the loop function
}</pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-786 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED.jpg" alt="Arduino Timer Interrupt LED sketch" width="1649" height="839" srcset="https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED.jpg 1650w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED-300x153.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED-1024x521.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED-768x391.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/11/TimerInterruptLED-1536x782.jpg 1536w" sizes="auto, (max-width: 1649px) 100vw, 1649px" /></p>
<p>The post <a href="https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/">Arduino Timer Interrupts – How to program Arduino registers</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/arduino-timer-interrupts-how-to-program-arduino-registers/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
