<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DarioCasciato</title>
    <description>The latest articles on DEV Community by DarioCasciato (@dariocasciato).</description>
    <link>https://dev.to/dariocasciato</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F972357%2Fc856b4e4-6d8e-487b-bbc0-520727db350c.png</url>
      <title>DEV Community: DarioCasciato</title>
      <link>https://dev.to/dariocasciato</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dariocasciato"/>
    <language>en</language>
    <item>
      <title>Software Realtalk: Is Content and Code Quality Declining (Also on dev.to)? My Honest Opinion</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Tue, 31 Dec 2024 11:27:51 +0000</pubDate>
      <link>https://dev.to/dariocasciato/software-realtalk-is-content-and-code-quality-declining-also-on-devto-my-honest-opinion-1kf9</link>
      <guid>https://dev.to/dariocasciato/software-realtalk-is-content-and-code-quality-declining-also-on-devto-my-honest-opinion-1kf9</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Hey fellow developers!&lt;/p&gt;

&lt;p&gt;This is a topic i always wanted to talk about (and im sure also some of you too), but i was somewhat of reserved about it because of the potential reactions. Please read it thoughtfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI for good
&lt;/h2&gt;

&lt;p&gt;In the first year of the drop of ChatGPT, i was flabbergasted how incredibly advanced our technology has got and how powerful it was. I almost used it every day (still to this day, but not particularly for coding). It helped me a lot by teaching me how to code, and how to apply insights i learned. Especially since a 10 month firmware developer job was waiting for me after my apprenticeship.&lt;/p&gt;

&lt;h2&gt;
  
  
  The decline
&lt;/h2&gt;

&lt;p&gt;After 2 years, I didn’t see a reason to code as much anymore since ChatGPT was doing much of the work for me. Of course, i always made some adjustment or wrote some snippets by myself, but coding didn't feel the same anymore, since i could always ask ChatGPT for the right and working answer. This began really to hit, when i noticed that every day, everything started to slightly sound not authentic anymore. GitHub repos with questionable comments which no person would ever write, coding styles which seemed a little off, logic which quite didnt make sense. It felt like the personal touch was disappearing.&lt;/p&gt;

&lt;h2&gt;
  
  
  dev.to
&lt;/h2&gt;

&lt;p&gt;I joined dev.to in 2022. ChatGPT/AI was very new for this time and not a lot of people knew what it really was. For me, this was the golden times on dev.to. Everyone wrote about their insights on new things they learned, authentic opinions, authentic posts, authentic comments, and the list goes on.&lt;br&gt;
Sadly, this spirit of authenticity started to fade proportionally to the growth of ChatGPT. The Dead Internet Theory really began to grow on me with all the inauthentic content that was pushed on blogsites (not only dev.to). Every second post was/is like "top 10 git commands" or "portfolio page with x and y" or "top open source tools" or "xyz for beginners". Don't get me wrong, even i wrote a post similar to these categories (&lt;a href="https://dev.to/dariocasciato/optimize-embedded-development-must-have-vscode-extensions-5d91"&gt;Optimize Embedded Development: Must-Have VSCode Extensions&lt;/a&gt;). But the dev.to homepage just started to be posts on these categories, which started to become uninteresting, If i compare it with the posts that were on the homepage in 2022. The real life insights are just missing. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conlusion / Your opinion
&lt;/h2&gt;

&lt;p&gt;ChatGPT/AI really pushed the speed of the development of new technology, while also making our content inauthentic ad unoriginal, since we don't have to think hard anymore. This whole AI thing has gotten out of control in my honest opinion, and it won't slow down from here on.&lt;/p&gt;

&lt;p&gt;I'd love to hear your opinions about this topic below in the comments. Do you support my statements, are ou against them, or what do ou think in general? Let me know!&lt;/p&gt;

&lt;p&gt;Remain authentic! &lt;br&gt;
Regards&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>realtalk</category>
      <category>devto</category>
      <category>controversial</category>
    </item>
    <item>
      <title>Leaving the Comfort Zone Behind: The Journey to Developing a Plugin for Obsidian.md</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Tue, 06 Aug 2024 13:43:57 +0000</pubDate>
      <link>https://dev.to/dariocasciato/leaving-the-comfort-zone-behind-the-journey-to-developing-a-plugin-for-obsidianmd-53hi</link>
      <guid>https://dev.to/dariocasciato/leaving-the-comfort-zone-behind-the-journey-to-developing-a-plugin-for-obsidianmd-53hi</guid>
      <description>&lt;p&gt;In my daily work use of &lt;a href="https://obsidian.md/" rel="noopener noreferrer"&gt;Obsidian.md&lt;/a&gt;, something started to stress me out more and more: the way folders behaved when navigating through the vault. If you know Obsidian, you know how valuable it is to keep a clean and organized workspace, especially with a large number of files. But, there was a small feature that was noticeably not there – folders didn’t automatically collapse their subfolders when the parent folder was collapsed. This lack of automatic folder management led to a cluttered and overwhelming sidebar, and it was something I couldn't ignore.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Wouldn't It Be Great If..." Moment
&lt;/h3&gt;

&lt;p&gt;One day, after manually collapsing what felt like the number 1'547 nested folder, I had the classic developer thought: &lt;em&gt;Wouldn’t it be great if Obsidian had a feature that automatically collapsed all child folders when the parent folder is collapsed?&lt;/em&gt; The idea was simple but practical, and I could see how it would improve the workflow for many users (like myself).&lt;/p&gt;

&lt;p&gt;But, there was no existing feature or plugin that addressed this. That’s when the seed of developing a plugin started to take root in my mind.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Nervousness of Starting Something New
&lt;/h3&gt;

&lt;p&gt;I was both excited and nervous about diving into the development of a plugin. I had developed software before, but creating a plugin that would integrate smoothly with Obsidian felt different. The main challenge was being sure that when a parent folder is collapsed, all its child folders would collapse too without having any other efforts to do so manually.&lt;/p&gt;

&lt;p&gt;There was an underlying anxiety: &lt;em&gt;I have never used the Obsidian API&lt;/em&gt;. The idea seemed simple, but the implementation was a different story. I was worried about the potential roadblocks and the the fear of not knowing enough to make it work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting My Hands Dirty: Developing the Plugin
&lt;/h3&gt;

&lt;p&gt;Despite the nerves, I decided to take the plunge. I started by familiarizing myself with Obsidian’s plugin API and thinking about the rough processes that would be needed to have the desired functionality. The goal was clear, but the implementation needed to be just right.&lt;/p&gt;

&lt;p&gt;After some trial and error – a version with a refresh command that was removed - and more than a few moments of head-scratching – I finally got the core functionality working. The plugin I developed, which I named "Auto Folder Collapse," made sure that whenever a parent folder was collapsed, all its child folders would also collapse. It was a small tweak, but it had a veeery noticeable impact on the overall usability of Obsidian.&lt;/p&gt;

&lt;p&gt;Demonstration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy3swv648g9acb1iceskp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy3swv648g9acb1iceskp.gif" alt="Image description" width="400" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Pull Request: A New Kind of Anxiety
&lt;/h3&gt;

&lt;p&gt;With the plugin (finally) functioning as intended, the next step was to share it with the world. This meant forking the official &lt;a href="https://github.com/obsidianmd/obsidian-releases" rel="noopener noreferrer"&gt;obsidian-release&lt;/a&gt; repo, adding my plugin, and creating a pull request to have it included in the official community plugins list.&lt;br&gt;
(a more detailed description on how to publish a plugin: &lt;a href="https://docs.obsidian.md/Plugins/Releasing/Submit+your+plugin" rel="noopener noreferrer"&gt;Obsidian: Submit your plugin&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;This was more challenging than i thought, since this was the first time for me to contribute to a open-source project. The process of creating a pull request was straightforward, but I couldn’t help but worry about the potential feedback. &lt;em&gt;Would the maintainers find the plugin useful?&lt;/em&gt; &lt;em&gt;What if they pointed out flaws I hadn’t noticed?&lt;/em&gt; and &lt;em&gt;What if it doesn’t even fit the demands of Obsidian?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I submitted the pull request and then came the waiting game.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Sweet Moment of Approval
&lt;/h3&gt;

&lt;p&gt;Aftfer some description-fixing (and "Refresh-Command" removal), to my relief and excitement, the plugin was approved and merged into the official community plugins list. Seeing "Auto Folder Collapse" listed among other plugins in the community felt incredibly rewarding. It was a validation of the work I had put in and the idea that started as a small frustration.&lt;/p&gt;

&lt;p&gt;This means, that the plugin is now available for anyone to download and use. To install it, you can simply go to the "Community Plugins" section in Obsidian, search for "Auto Folder Collapse," and click the install button.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion: Reflecting on the Experience
&lt;/h3&gt;

&lt;p&gt;Developing and releasing "Auto Folder Collapse" was a learning experience in many ways. It wasn’t just about coding; it was about stepping out of my comfort zone, contributing to a community, and seeing an idea come to life in a way that could help others. The feeling of providing something that the world needs/wants is surely one of the best. After 6 days since the release, the plugin has been downloaded 132 times, which is a number I never expected to reach in this time.&lt;/p&gt;

&lt;p&gt;Link to the Repository: &lt;a href="https://github.com/DarioCasciato/obsidian-auto-folder-collapse" rel="noopener noreferrer"&gt;Auto Folder Collapse&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For anyone out there with a similar idea/itch – whether it’s a small feature you wish existed or a bug that needs fixing – I encourage you to take that leap. The journey might be a bit nerve-wracking, but the outcome can be incredibly rewarding. Plus, you never know how many people might benefit from that small idea you had. &lt;strong&gt;Always remember that your comfort zone is a nice place, but nothing ever grows there.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! If you have any thoughts or questions, feel free to leave a comment. Happy coding!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>obsidian</category>
      <category>plugin</category>
      <category>motivation</category>
    </item>
    <item>
      <title>Mini-exos: The IoT Web-based Access Control System</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Wed, 27 Mar 2024 13:23:57 +0000</pubDate>
      <link>https://dev.to/dariocasciato/mini-exos-the-iot-web-based-access-control-system-5hjk</link>
      <guid>https://dev.to/dariocasciato/mini-exos-the-iot-web-based-access-control-system-5hjk</guid>
      <description>&lt;p&gt;&lt;em&gt;Project Sorce Code &lt;a href="https://github.com/DarioCasciato/iot-access-controller" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Welcome to one of my biggest projects yet! The &lt;strong&gt;Mini-exos&lt;/strong&gt;! The Mini-exos is an Access Control System designed to manage and control access to secure areas or rooms. It includes an interface for managing users, access points, access assignments, and logging access attempts. The system allows for real-time access requests from microcontrollers (specifically ESP8266 in this project) equipped with MFRC522 RFID reader, for a modern access control solution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezczcwb8gd8qrxq07kzc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezczcwb8gd8qrxq07kzc.jpg" alt="Build Setup" width="800" height="1062"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Concept and Design
&lt;/h2&gt;

&lt;p&gt;The Mini-exos project is based on the access control &lt;a href="https://www.dormakaba.com/ch-en/offering/products/electronic-access-data/access-control-solutions-for-corporate/kaba-exos-9300-base-system--ka_500000" rel="noopener noreferrer"&gt;exos 9300&lt;/a&gt;, which is far more complex and feature-rich. The Mini-exos is a simplified version that was developed as a part of the new program of the trial internship at dormakaba Schweiz AG as a "GebäudeinformatikerIn EFZ" (Building Automation Engineer) in 2024. This project would give the intern a good understanding of the IoT and the access solutions offered by dormakaba.&lt;/p&gt;

&lt;p&gt;The whole project is also based on the design guidelines of dormakaba. The User Experience and User Interface are designed to be simple and intuitive, with a focus on ease of use for the end-user.&lt;/p&gt;

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

&lt;p&gt;The software architecture is rather simple. We have the reader (ESP8266) and the Frontend (Mini-exos Web panel) which the user can interact with. These are like the only "visible" parts of the system. The reader is responsible for reading an RFID Badge/Card and sending the data to the backend (Node Server).&lt;/p&gt;

&lt;p&gt;The Web panel is responsible for displaying the configurations and logs of the system. Everything that is displayed on the Web panel is fetched from the Node Server. Also, when changing or creating configurations, the Web panel sends the data to the Node Server, which then stores it in the database.&lt;/p&gt;

&lt;p&gt;The Node Server is the "brain" of the system. It is responsible for handling the data from the reader and the Web panel. It also stores the data in the database and sends the data to the Web panel when requested. The Server also handles the access requests from the reader and sends the result if it is allowed or not back to the reader.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqik6z0d2n15z9he6787j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqik6z0d2n15z9he6787j.png" alt="Software Architecture" width="800" height="958"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  User Interface
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Home Page
&lt;/h3&gt;

&lt;p&gt;The Homepage gives you an overview of all the functionalities of the system. The navigation is held rather simple.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7bca2tz2ua6bler0tto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7bca2tz2ua6bler0tto.png" alt="Home Page" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Access Point Configuration Page
&lt;/h3&gt;

&lt;p&gt;On this page, you can manage and configure existing or new access points. With the "Add Devices/Sync" button, the system will search for devices in the local network and list them to the user with the device ID and IP. If a device is found, the user can either add it directly to the system by also giving it a name, or the user can press the button "identify", which will make the found device light up to make it easier to identify it. When adding a device to the system, the node server sends its IP address to the device, so the device can now send its requests to the node server.&lt;/p&gt;

&lt;p&gt;The existing devices are listed in a table with the name, description, IP address, the identify button, and a button to delete the device. The user can also edit the name and description of the device by clicking on the respective field in the table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ms8veo2q0ma66d60id5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ms8veo2q0ma66d60id5.PNG" alt="Access Point Configuration Page" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  User Management
&lt;/h3&gt;

&lt;p&gt;The user management page is straightforward. It lists all the existing users in a table with the name, family name, and their Card UID. Every User that is created has also to be associated with a Card UID. Since we mostly don't know the UID of the card, we have the possibility to scan the card with a registered access point. The user can then select the access point and scan the card. The UID will then be displayed in the input field. The Access Point also signals when it is ready to scan a card.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzxwsnv0lmkjingpampa.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzxwsnv0lmkjingpampa.PNG" alt="User Management Page" width="800" height="382"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pdl5n8wo4luymn7lo6p.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7pdl5n8wo4luymn7lo6p.PNG" alt="User Creation" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Access Assignment Page
&lt;/h3&gt;

&lt;p&gt;Here is where the magic happens. The manager or administrator can assign access rights to users for specific access points. The manager or administrator can select a user from the dropdown menu, select an access point, and optionally even an expiration date. After the right is created, the user gets also listed in a table with the user, the access point, and the expiration date. From this moment on, the user can access the access point with its card.&lt;/p&gt;

&lt;p&gt;Expired access rights are highlighted in red in the table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkulv43zpi9js5t9ds79.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkulv43zpi9js5t9ds79.PNG" alt="Access Assignment Page" width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvu63ux1po2rr9s976hy8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvu63ux1po2rr9s976hy8.PNG" alt="Access Assignment create" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Log Overview Page
&lt;/h3&gt;

&lt;p&gt;The log overview page is a simple page that lists all the access attempts in a table. The table shows the user, the access point, the result of the attempt, and the date. It also features a filter to filter the logs by user and access point.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7ja0muxxvdye68rx22c.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7ja0muxxvdye68rx22c.PNG" alt="Log Overview Page" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Microcontroller Functionality
&lt;/h2&gt;

&lt;p&gt;An unregistered access point could be titled as "stupid": It doesn't know where to send the data to, so it sends it to nobody. And so it doesn't ever allow access.&lt;/p&gt;

&lt;p&gt;But even registered access points don't do a lot of work. If it is registered, it just sends a payload to the node server and waits for a response. The Access Point ultimately acts as a bridge between the RFID reader and the Node Server. The code of the Access Point is rather simple and looks like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;stateIdle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RFID&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;tagAvailable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getEdgePos&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="c1"&gt;// checks if a tag is available&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Tag detected! UID: %x"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;RFID&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;getUID&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

            &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Requesting access..."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="c1"&gt;// Send an access request to the server with the UID of the tag/card&lt;/span&gt;
            &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ResponseStatus&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RFID&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;getUID&lt;/span&gt;&lt;span class="p"&gt;()));&lt;/span&gt;

            &lt;span class="c1"&gt;// Handle the response&lt;/span&gt;
            &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ResponseStatus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Access granted!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;// Signal the user that the access is granted&lt;/span&gt;
                &lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;granted&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ResponseStatus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Denied&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Access denied!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;denied&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ResponseStatus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ConnectionFailed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Connection failed!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;connectionError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Access&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ResponseStatus&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ParseError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;Logging&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Parse error!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;Signal&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;connectionError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Handle host requests&lt;/span&gt;
        &lt;span class="n"&gt;Host&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;handleClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Check if the host has sent a request&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Microcontroller basically is just sitting in this code snippet and waits for a tag to be scanned. If a Card/Badge is scanned, the following payload is sent to the Node Server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deviceId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0x12345678"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Access&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Point&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"uid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1a2b3c4d"&lt;/span&gt;&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;UID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Card/Badge&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this information, the Node Server can now check if the user has access to the access point and send the result back to the Access Point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security Measures
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: The Mini-exos is not designed to be safe against attacks. It is a simple project to learn about IoT and Access Control Systems. So it should only be used in a local network for educational purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Repository
&lt;/h2&gt;

&lt;p&gt;The Project is stored on GitHub and is publicly available. You can find the repository here: &lt;a href="https://github.com/DarioCasciato/iot-access-controller" rel="noopener noreferrer"&gt;Mini-exos&lt;/a&gt;. There is also a more detailed README file in the repository on how to set up the project.&lt;/p&gt;

&lt;p&gt;The hardware that was used for this project, can be found &lt;a href="https://github.com/DarioCasciato/iot-access-controller/blob/main/readme.md#wiring" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;I think this was the most complex and educating project I have done so far. I learned a lot about IoT, Networks, API routes, and much more! I am very happy with the result and I hope you enjoyed reading about it! If you have any questions or feedback, feel free to comment below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>iot</category>
      <category>javascript</category>
      <category>cpp</category>
    </item>
    <item>
      <title>TLV: A Powerful Tool for handling Data in Embedded Systems</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Thu, 02 Nov 2023 12:43:33 +0000</pubDate>
      <link>https://dev.to/dariocasciato/tlv-a-powerful-tool-for-handling-data-in-embedded-systems-f4e</link>
      <guid>https://dev.to/dariocasciato/tlv-a-powerful-tool-for-handling-data-in-embedded-systems-f4e</guid>
      <description>&lt;p&gt;Today's article in the firmware 101 series is about TLVs. TLVs are a way to store or organize data. Since I've known about TLVs, I use them in almost every project, because of their simplicity and flexibility. In this article I will explain what TLVs are, how they work and how/where to use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are TLVs?
&lt;/h2&gt;

&lt;p&gt;The first time I've heard about TLV's, was about 2.5 months ago, when I started to work as a full-time embedded developer. (I firstly confused it with the Windows VLC media player).&lt;br&gt;
TLV stands for &lt;strong&gt;Tag&lt;/strong&gt;-&lt;strong&gt;Length&lt;/strong&gt;-&lt;strong&gt;Value&lt;/strong&gt;. If you illustrate them, they look something like this:&lt;/p&gt;

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

&lt;p&gt;TLV's are just a way to organize data and make it easy to interpret. TLV formats allows a compact representation of data, which is needed in embedded systems, where memory and storage are limited.&lt;/p&gt;

&lt;h2&gt;
  
  
  how do TLVs work?
&lt;/h2&gt;

&lt;p&gt;As mentioned before, a TLV is made up of 3 Parts: Tag, Length and Value:&lt;/p&gt;

&lt;h3&gt;
  
  
  Tag
&lt;/h3&gt;

&lt;p&gt;The Tag is like the ID of the data. It tells you what kind of data is stored in the TLV. For example, if you are searching for a specific data, you can just look for the corresponding tag. For example, if you have a device-number and a password, and you want to store them, you can just assign them tags. The tags could be something like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Device-ID: 0x01&lt;/li&gt;
&lt;li&gt;Password: 0x02&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Length
&lt;/h3&gt;

&lt;p&gt;The length is the length of the value. It tells you how many bytes the value is long.&lt;br&gt;
For example, if you have a 32-bit integer as value, the length would be 4 (bytes). The length is needed, because the value can be of any length. It could be a single byte, or a 32-bit integer, or even a string. The length is needed to know how many bytes you have to read for the value.&lt;br&gt;
The length is also needed when searching for a specific tag or value in a flash storage, for example. If you know the length of the value, you know how many bytes you have to skip to get to the next TLV.&lt;br&gt;
Here, for example, we are searching for a number that is stored in a flash storage with the TLV-Tag &lt;strong&gt;0x03&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FDarioCasciato%2Fdev.to%2Fmain%2Ftlv%2Fimg%2Fsearch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FDarioCasciato%2Fdev.to%2Fmain%2Ftlv%2Fimg%2Fsearch.png" alt="Search TLV"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we reach the TLV with the tag &lt;strong&gt;0x03&lt;/strong&gt;, we know that the value is 4 bytes long, so we can just read the next 4 bytes and we have the number!&lt;/p&gt;

&lt;h3&gt;
  
  
  Value
&lt;/h3&gt;

&lt;p&gt;The Value is the actual data. It can be of any length and any type. It can be a single byte, a 32-bit integer, a string, or even another TLV. The value is the actual data that you want to store or transmit.&lt;/p&gt;

&lt;p&gt;You can also store more than 1 value in a TLV. In a communication-protocol, it's very common to do so. This could look something like this:&lt;/p&gt;

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

&lt;p&gt;Since the receiver of the data knows what kind of command is received (because of the tag), it knows how to interpret the values. For example, if the tag is 0x01, the receiver knows that the first value is for example the device-number and the second value is a pin-code. The length of the TLV is just the sum of the lengths of these values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to use TLVs?
&lt;/h2&gt;

&lt;p&gt;There are a lot of applications that use TLVs. A common application is in communication protocols. For example, if you have a device that communicates with a host, you can use the TLV encoding to transmit the data, so it's easy to interpret for the host. It's also possible to set up a server that can handle TLVs. So if you want to request something from the server, you can just send a TLV with the tag of the request without any data (the length would be 0), and the server could then respond with the same tag and the requested data as value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FDarioCasciato%2Fdev.to%2Fmain%2Ftlv%2Fimg%2Fcomm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FDarioCasciato%2Fdev.to%2Fmain%2Ftlv%2Fimg%2Fcomm.png" alt="Server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, a common application is in flash storages. If you want to store a devices data, scores, credentials or something else, you can just store them in TLVs, and when you want to read them, you can just search for the corresponding tag and read the value. So it's also possible to update the data, by just overwriting the TLV with the same tag. But you have to be cautious! Because if the new value is longer than the old one, you have to make sure that there is enough unused space after the TLV, so you don't accidentally overwrite the next TLV (if there is one).&lt;/p&gt;

&lt;p&gt;Not long ago, I wrote an ID-Storage Library in C++ for Arduino, that exactly uses the principle of TLVs. It's a library that allows you to store and retrieve data in a flash/EEPROM storage. You can find it here: &lt;a href="https://github.com/DarioCasciato/arduino-template-oop/blob/main/utils/Storage/IDStorage.h" rel="noopener noreferrer"&gt;ID-Storage Library&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale
&lt;/h2&gt;

&lt;p&gt;Thank you for reading! I hope you learned something new from this article.&lt;/p&gt;

&lt;p&gt;Feel free to leave any comments or questions below, and I'll do my best to help you out!&lt;/p&gt;

&lt;p&gt;May your code be bug-free!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>embedded</category>
      <category>learning</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Is it worth creating an Udemy course?</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Tue, 10 Oct 2023 12:31:06 +0000</pubDate>
      <link>https://dev.to/dariocasciato/is-it-worth-creating-a-udemy-course-3ni8</link>
      <guid>https://dev.to/dariocasciato/is-it-worth-creating-a-udemy-course-3ni8</guid>
      <description>&lt;p&gt;I am considering creating an Udemy course about "Real Embedded C++ development on Arduino." &lt;br&gt;
However, I am concerned that I will put a lot of effort into the course, but that it will not be worth it in the end. &lt;/p&gt;

&lt;p&gt;Do you have any experience with something like this? What is your opinion?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>udemy</category>
      <category>embedded</category>
      <category>learning</category>
    </item>
    <item>
      <title>Optimize Embedded Development: Must-Have VSCode Extensions</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Wed, 20 Sep 2023 13:44:38 +0000</pubDate>
      <link>https://dev.to/dariocasciato/optimize-embedded-development-must-have-vscode-extensions-5d91</link>
      <guid>https://dev.to/dariocasciato/optimize-embedded-development-must-have-vscode-extensions-5d91</guid>
      <description>&lt;p&gt;And welcome back to a new article in the firmware 101 series! In this article, we won't focus on how to do things, but more on with what to do things. I will list the best VS-Code extensions for embedded development. I will also list some other extensions that are not directly related to embedded development, but are very useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;The Extensions that I will list are my personal favorites. These extensions are a must-have for me and I use them in every project. I am not sponsored by any of the extension developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extensions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools" rel="noopener noreferrer"&gt;C/C++ Extension&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is the most important extension. It is developed by Microsoft and is the official C/C++ extension for VS-Code. It is a must-have for embedded development. It provides IntelliSense, debugging, and code browsing capabilities. The IntelliSense aspect of this extension is the most important one. It provides code completion, parameter info, and member lists.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide" rel="noopener noreferrer"&gt;PlatformIO&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you are developing firmware for commonly used boards like Arduino, ESP8266 or ESP32, PlatformIO is a must-have. This extension allows you to directly upload your code to the board, and it also provides a serial monitor. It also has a library manager that allows you to easily add libraries to your project. PlatformIO also has a very nice feature called "Project Tasks". This allows you to run common tasks like building, uploading, cleaning, etc. with a single click. After you get comfortable using PlatformIO, &lt;strong&gt;you will never go back to the Arduino IDE&lt;/strong&gt;.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens" rel="noopener noreferrer"&gt;Error Lens&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The Error Lens extension is one of my favorite extension for VS-Code. Instead of showing errors with squiggly lines, it shows the error message directly on the line of code where the error is. The error is more visible, and you don't have to hover over the squiggly line to see the error message and save time.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=dionmunk.vscode-notes" rel="noopener noreferrer"&gt;Notes&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The Notes extension adds a new tab in the left sidebar. In this tab, you can add general notes that are not related to a specific file. These Notes are markdown friendly, and you can add links, images, etc. to them. I like to use it when I am working on a project and need to design the structure of the flash memory, or allocating pins for peripherals. e.g.:&lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot" rel="noopener noreferrer"&gt;GitHub Copilot&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Copilot is the only extension in this list that is a paid service. Copilot is an artificial intelligence that knows your workspace and gives you completions based on your code. It costs you $10 a month, but it's worth it, and it saves you a lot of time. Here is an example of copilot in action in one of my newest projects:&lt;/p&gt;

&lt;p&gt;Logic completion:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpghv4rxyosb47u9sc8a0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpghv4rxyosb47u9sc8a0.png" alt="Exmaple 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Function completion:&lt;/p&gt;

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

&lt;p&gt;Even if these are small snippets, over the project they save you a lot of time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale &amp;amp; your favorite extensions
&lt;/h2&gt;

&lt;p&gt;These are my favorite extensions for VS-Code. I hope you found some new extensions that you can use in your projects! Comment down below what your favorite extensions are for embedded development. I hope you enjoyed this article and see you in the next one!&lt;/p&gt;

&lt;p&gt;May your code be bug-free!&lt;/p&gt;

</description>
      <category>embedded</category>
      <category>c</category>
      <category>vscode</category>
      <category>extensions</category>
    </item>
    <item>
      <title>ATtiny85 Programming: Your Complete Guide with Arduino and PlatformIO!</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Sat, 05 Aug 2023 13:59:26 +0000</pubDate>
      <link>https://dev.to/dariocasciato/attiny85-programming-your-complete-guide-with-arduino-and-platformio-37do</link>
      <guid>https://dev.to/dariocasciato/attiny85-programming-your-complete-guide-with-arduino-and-platformio-37do</guid>
      <description>&lt;h2&gt;
  
  
  The Pain of Undocumented Programming
&lt;/h2&gt;

&lt;p&gt;I think finding out how to program a new microcontroller for the first time without proper documentation can be one of the most painful tasks in embedded systems. This task mostly involves finding YouTube videos that explain almost your case but not exactly, scrolling through websites and not finding any relevant information, and finally thinking you found the solution, but then an error pops up that has never been recorded in human history, so you don't find anything about it on the web.&lt;/p&gt;

&lt;p&gt;That's why I want to close a gap with this article about &lt;strong&gt;how to program an ATtiny85 with an Arduino via PlatformIO.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippets Repository
&lt;/h3&gt;

&lt;p&gt;All code snippets used in this article can be found in the accompanying &lt;a href="https://github.com/DarioCasciato/PlatformIO-ATtiny85-Programming-with-Arduino-Nano" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;, making it easy to access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disclaimer
&lt;/h3&gt;

&lt;p&gt;This article focuses only on how to program an ATtiny85. So it is not a complete guide on also how to set up and program an Arduino. In this article, I will do all examples with an Arduino Nano.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;These are the general steps on how to program the ATtiny85:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up the Arduino as ISP programmer&lt;/li&gt;
&lt;li&gt;Wiring up the ATtiny85&lt;/li&gt;
&lt;li&gt;Setting up the PlatformIO Project&lt;/li&gt;
&lt;li&gt;Program it!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Set up the Arduino as ISP programmer
&lt;/h2&gt;

&lt;p&gt;The first step is to modify the Arduino's behavior, transforming it into a capable ISP (In-System Programmer). This step is relatively simple: you just need to upload a code to the Arduino. It doesn't matter if you upload the code with the Arduino IDE or via PlatformIO.&lt;/p&gt;

&lt;p&gt;The Code can be found here: &lt;a href="https://github.com/DarioCasciato/PlatformIO-ATtiny85-Programming-with-Arduino-Nano/blob/main/Step%201%20%7C%20Set%20up%20the%20Arduino%20as%20ISP%20programmer/main.cpp%20(Arduino%20as%20ISP%20Code)" rel="noopener noreferrer"&gt;Arduino as ISP Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After this is done, you are ready to wire up the ATtiny85 with the Arduino!&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Wiring up the ATtiny85
&lt;/h2&gt;

&lt;p&gt;The wiring requires one additional part: a capacitor with a minimum capacity of 1µF is needed between the Reset and Ground Pin of the Arduino. The capacitor prevents the Arduino from resetting while programming the ATtiny85.&lt;/p&gt;

&lt;p&gt;These are the connections:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Arduino&lt;/th&gt;
&lt;th&gt;ATtiny85&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5V&lt;/td&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Digital pin 13&lt;/td&gt;
&lt;td&gt;GPIO 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Digital pin 12&lt;/td&gt;
&lt;td&gt;GPIO 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Digital pin 11&lt;/td&gt;
&lt;td&gt;GPIO 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Digital pin 10&lt;/td&gt;
&lt;td&gt;Reset&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here's an illustration of all connections:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxuh5jwchpb8fbry2m25.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxuh5jwchpb8fbry2m25.png" alt="Wiring" width="800" height="889"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/DarioCasciato/PlatformIO-ATtiny85-Programming-with-Arduino-Nano/blob/main/Step%202%20%7C%20Wiring%20up/Sources.txt" rel="noopener noreferrer"&gt;Image Sources&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;

&lt;p&gt;Even if there is an Arduino Nano in the illustration, you can use another Arduino (e.g., Uno, Mega, etc.) as long as you use the same digital Pins mentioned above.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Setting up the PlatformIO Project
&lt;/h2&gt;

&lt;p&gt;Now comes the important step: setting up the project. Open VSCode (in my case) and access the PlatformIO Home. In the "quick access" tab, select "New Project." There, you'll find three input fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;Board&lt;/li&gt;
&lt;li&gt;Framework&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give your project a suitable name.&lt;/p&gt;

&lt;p&gt;In the "Board" input field, type "ATtiny85". You should see one result called "Generic ATtiny85 (Atmel)," and select it. Ensure that the Framework is "Arduino."&lt;br&gt;
Optionally, you can change the Location of the Project on your computer by unticking the checkbox and selecting a location.&lt;br&gt;
If everything is done, click "Finish". PlatformIO will set up the Project, which usually takes a maximum of 20 seconds.&lt;/p&gt;

&lt;p&gt;After the Project is set up, the "platform.ini" file should open automatically. If not, you can find it in the main directory of the Project.&lt;br&gt;
In this file, you'll find all configurations for the project, such as how it should be uploaded, which framework it uses, which microcontroller it's for, etc.&lt;/p&gt;

&lt;p&gt;This is the critical file that needs to be changed to program the ATtiny with the Arduino. Delete the content of this file, and paste in the following snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[env:program_via_ArduinoISP]
platform = atmelavr
framework = arduino
board = attiny85
upload_protocol = stk500v1
; each flag in a new line
upload_flags =
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED

upload_speed = 19200
upload_port = COMX ; Set the port to the Arduino COM Port
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(You can find this snippet in the &lt;a href="https://github.com/DarioCasciato/PlatformIO-ATtiny85-Programming-with-Arduino-Nano/blob/main/Step%203%20%7C%20Setting%20up%20the%20PlatformIO%20Project/platform.ini%20(for%20ATtiny85)" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Here you have to make one customization. In the last line, you need to change "COMX" to the right COM Port of your Arduino. E.g., if your Arduino is connected to the COM Port 3, you have to change it to "COM3."&lt;/p&gt;

&lt;p&gt;Now the Project setup is finished, and the ATtiny can be programmed!&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Program it!
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;src&lt;/code&gt; directory, you can find the &lt;code&gt;main.cpp&lt;/code&gt; with the basic example code of the Arduino. Write your code into this file, and then you should be able to upload it.&lt;/p&gt;

&lt;p&gt;You can upload it in the PlatformIO tab on the left and click "Upload".&lt;/p&gt;

&lt;p&gt;The console output should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Building in release mode
Checking size .pio\build\program_via_ArduinoISP\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home &amp;gt; Project Inspect"
RAM:   [==        ]  16.4% (used 84 bytes from 512 bytes)
Flash: [==        ]  15.0% (used 1230 bytes from 8192 bytes)
Configuring upload protocol...
AVAILABLE: stk500v1
CURRENT: upload_protocol = stk500v1
Looking for upload port...
Uploading .pio\build\program_via_ArduinoISP\firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: erasing chip
avrdude: reading input file ".pio\build\program_via_ArduinoISP\firmware.hex"
avrdude: writing flash (1230 bytes):

Writing | ################################################## | 100% 1.81s

avrdude: 1230 bytes of flash written
avrdude: verifying flash memory against .pio\build\program_via_ArduinoISP\firmware.hex:
avrdude: load data flash data from input file .pio\build\program_via_ArduinoISP\firmware.hex:
avrdude: input file .pio\build\program_via_ArduinoISP\firmware.hex contains 1230 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.88s

avrdude: verifying ...
avrdude: 1230 bytes of flash verified

avrdude: safemode: Fuses OK (E:FF, H:DF, L:62)

avrdude done.  Thank you.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have successfully programmed your ATtiny85!&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this article! i hope it has been helpful for you with the programming of your ATtiny. I have plenty of other ideas for this series, so stay tuned!&lt;/p&gt;

&lt;p&gt;Feel free to leave any comments or questions below, and I'll do my best to help you out!&lt;/p&gt;

&lt;p&gt;May your code be bug-free!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>embedded</category>
      <category>c</category>
      <category>arduino</category>
    </item>
    <item>
      <title>Bits and Bytes: A Comprehensive Guide to Bit Manipulation</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Thu, 23 Feb 2023 12:20:25 +0000</pubDate>
      <link>https://dev.to/dariocasciato/bits-and-bytes-a-comprehensive-guide-to-bit-manipulation-for-developers-m5c</link>
      <guid>https://dev.to/dariocasciato/bits-and-bytes-a-comprehensive-guide-to-bit-manipulation-for-developers-m5c</guid>
      <description>&lt;p&gt;Ah, bit manipulation. Another classic when learning to develop embedded software. It saved me half of my lifetime once when I found out that I could &lt;a href="https://www.dictionary.com/browse/concatenate" rel="noopener noreferrer"&gt;concatenate&lt;/a&gt; values that are saved in an array. This was the piece of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;UID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;UID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an example of bit manipulation. The tempUID array holds one byte in every index. To concatenate them, you can use bit manipulation like this one.&lt;/p&gt;

&lt;p&gt;It looks complicated at first, I know. But after this article, you will exactly know how this works and feel like this (this was my case):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj13byn623wmxau2utiqm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj13byn623wmxau2utiqm.jpeg" alt="Feeling" width="800" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Bit Manipulation?
&lt;/h2&gt;

&lt;p&gt;Bit manipulation is the process of using bitwise operators to &lt;strong&gt;manipulate individual bits within a number or value&lt;/strong&gt;. It is very powerful when you have to make very specific operations.&lt;/p&gt;

&lt;p&gt;It's not to be confused with logical operations, which work on boolean values (e.g. true/false).&lt;/p&gt;

&lt;p&gt;So let's get straight into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;There are six different operators, of which the last two are very similar, to do bit manipulation. These are the operators:&lt;/p&gt;

&lt;h3&gt;
  
  
  AND Operator ( &amp;amp; )
&lt;/h3&gt;

&lt;p&gt;The bitwise AND operator, as it is in the name, sets the bit to "1" if the compared bits are both "1".&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input A&lt;/th&gt;
&lt;th&gt;Input B&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvosp43v8kv63q8tqcswk.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvosp43v8kv63q8tqcswk.PNG" alt="AND Illustration" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This operator is used for bit-masking. With bit-masking, you select specific bits to be read. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xF0&lt;/span&gt; &lt;span class="c1"&gt;// 0xF0 -&amp;gt; 11110000b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this mask (0xF0), the first four bits from the right do not have the possibility of becoming '1' because with the AND operator, both bits must be '1' to obtain a '1'.&lt;br&gt;
So if address, for example, is &lt;strong&gt;10100110&lt;/strong&gt;, the result would be &lt;strong&gt;10100000&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  OR Operator( | )
&lt;/h3&gt;

&lt;p&gt;The bitwise OR operator sets the bit to '1' if at least one bit is '1'.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input A&lt;/th&gt;
&lt;th&gt;Input B&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhdbzgtanhgqtpmzoma1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhdbzgtanhgqtpmzoma1.PNG" alt="OR Illustration" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This operator is used a lot for combining values or concatenating them (for concatenation you would also need bit-shifting).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;|=&lt;/span&gt; &lt;span class="mh"&gt;0x80&lt;/span&gt; &lt;span class="c1"&gt;// 0x80 -&amp;gt; 10000000&lt;/span&gt;
&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x80&lt;/span&gt; &lt;span class="c1"&gt;// same result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will set the 8th bit of the variable 'test' to '1', regardless of the value of 'test'.&lt;/p&gt;

&lt;h3&gt;
  
  
  XOR Operator ( ^ )
&lt;/h3&gt;

&lt;p&gt;The bitwise XOR operator is a very interesting one. In my &lt;a href="https://dev.to/dariocasciato/edgy-firmware-the-only-edge-detection-solution-youll-ever-need-1ma6"&gt;previous article&lt;/a&gt;, I mentioned that this operator can be very powerful. The XOR operator sets a bit to '1' if the two compared bits are unequal.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input A&lt;/th&gt;
&lt;th&gt;Input B&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5da3e5zld35j8rl7uvfo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5da3e5zld35j8rl7uvfo.PNG" alt="XOR Illustration" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many different use cases for the XOR operator, such as encryption with a key, toggling, or change detection. But there are many more. I used the change detection for &lt;a href="https://dev.to/dariocasciato/edgy-firmware-the-only-edge-detection-solution-youll-ever-need-1ma6"&gt;Edge detection&lt;/a&gt;. In this example, we are going to toggle values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt; &lt;span class="c1"&gt;// 0xFF -&amp;gt; 11111111&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every bit in value that is a '1' will turn to '0', since 1 XOR 1 will result in 0.&lt;/p&gt;

&lt;p&gt;Every bit in value that is a '0' will turn to '1', since 0 XOR 1 will result in 1.&lt;/p&gt;

&lt;h3&gt;
  
  
  NOT Operator ( ~ )
&lt;/h3&gt;

&lt;p&gt;The bitwise NOT operator is the easiest one to understand. It does exactly the same as in the example above for the XOR. It inverts every bit. The syntax is very simple.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosiwqadyeejc8g5554b1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosiwqadyeejc8g5554b1.PNG" alt="NOT Illustration" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This operator is very useful; for example, if you need to initialize a value inverted, you can use the bitwise NOT operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xF0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0xF0 -&amp;gt; 11110000&lt;/span&gt;

&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the operation, value is &lt;strong&gt;00001111&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  LEFTSHIFT Operator ( &amp;lt;&amp;lt; )
&lt;/h3&gt;

&lt;p&gt;Now the interesting ones begin. These operators do exactly the thing they are called. They shift! You only need to specify how many bits the value should be shifted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6tjt9tigbmxdt7j4hgql.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6tjt9tigbmxdt7j4hgql.PNG" alt="LEFTSHIFT Illustration" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned in the first example, this is very useful to concatenate values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0F&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0x0F -&amp;gt; 00001111&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have 2 inputs with this operator. The one on the left is the value that needs to be shifted, and the right one specifies how many bits it needs to be shifted. So the result of this example would be &lt;strong&gt;00111100&lt;/strong&gt;. You can also see that the new bits that are pushed in from the right are '0'. This is default and cannot be changed.&lt;/p&gt;

&lt;h3&gt;
  
  
  RIGHTSHIFT Operator ( &amp;gt;&amp;gt; )
&lt;/h3&gt;

&lt;p&gt;The right-shift bitwise operator also shifts bits. The only difference is that it shifts bits to the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzazawessd0q4a4ssn2xo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzazawessd0q4a4ssn2xo.PNG" alt="RIGHTSHIFT Illustration" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, this one can be used for concatenating values. It also comes in handy in encryption. You can shift a value in a direction by a known amount of times. Combining it with other operators makes this extremely powerful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x50&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0x50 -&amp;gt; 01010000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think you can already guess the result. If we shift 0x50 (01010000) to the right by 2, we get &lt;strong&gt;00010100&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the first example
&lt;/h2&gt;

&lt;p&gt;Now that the theoretical part is done, we should be able to understand the first example of bit manipulation I made. The goal is to concatenate them all together to get one value that contains all other values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="n"&gt;UID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;UID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To illustrate this, we assign a value to each array index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;                    &lt;span class="c1"&gt;//  HEX     BIN&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xA3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;//  0xA3    10100011&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;//  0xFF    11111111&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x67&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;//  0x67    01100111&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xF0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;//  0xF0    11110000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This bit manipulation involves two steps. The first step is to shift the values, and the second step is to combine them using the OR operator.&lt;/p&gt;

&lt;p&gt;We need to shift all the values by the number given in the calculation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="mi"&gt;10100011&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="c1"&gt;// shifted by 24&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;              &lt;span class="mi"&gt;11111111&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="c1"&gt;// shifted by 16&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                       &lt;span class="mo"&gt;01100111&lt;/span&gt; &lt;span class="mo"&gt;00000000&lt;/span&gt; &lt;span class="c1"&gt;// shifted by 8&lt;/span&gt;
&lt;span class="n"&gt;tempUID&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                                &lt;span class="mi"&gt;11110000&lt;/span&gt; &lt;span class="c1"&gt;// not shifted&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second step is to combine them using the OR operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;UID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10100011&lt;/span&gt; &lt;span class="mi"&gt;11111111&lt;/span&gt; &lt;span class="mo"&gt;01100111&lt;/span&gt; &lt;span class="mi"&gt;11110000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, That's it! When you first look at a calculation involving bit manipulation, it can be confusing. However, when you split up the whole process into steps, it becomes more comprehensible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale
&lt;/h2&gt;

&lt;p&gt;Thank you for reading! I hope you learned something new from this article. The series will continue soon with a new article about structuring your firmware.&lt;/p&gt;

&lt;p&gt;Feel free to leave any comments or questions below, and I'll do my best to help you out!&lt;/p&gt;

&lt;p&gt;May your code be bug-free!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>developer</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Edgy Firmware: The Only Edge Detection Solution You'll Ever Need</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Wed, 22 Feb 2023 09:49:30 +0000</pubDate>
      <link>https://dev.to/dariocasciato/edgy-firmware-the-only-edge-detection-solution-youll-ever-need-1ma6</link>
      <guid>https://dev.to/dariocasciato/edgy-firmware-the-only-edge-detection-solution-youll-ever-need-1ma6</guid>
      <description>&lt;h2&gt;
  
  
  My first experience
&lt;/h2&gt;

&lt;p&gt;I think this topic is a very classic, when you are writing your first more complex embedded program (rather than a blinking LED). E.g. You want to count how many times a button has been pressed. This was one of my first tasks I was ever given, when I was learning firmware development.&lt;br&gt;
I thought that it was as easy as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUTTON&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But this method resulted in the counter incrementing infinitely in a matter of seconds because it checked if the button was pressed and not if there was a change from not pressed to pressed.&lt;/p&gt;

&lt;p&gt;In my apprenticeship as an electronics engineer, I had a teacher that spoke more about his political opinions rather than coding. But the few times he talked about coding, he really taught us something. He once taught me five lines of code that changed the way I see the world and how I write code. These are the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;INPUT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_neg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OLD&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know this does not look like much, but after you read this article, you will realize that this is the perfect edge detection method.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set it up
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Struct
&lt;/h3&gt;

&lt;p&gt;To make it as much "clean code" as possible, it's very nice to use a struct for this case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;edge_pos&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;edge_neg&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;edge_t&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Detection
&lt;/h3&gt;

&lt;p&gt;Now the five sacred lines of code follow. They are inserted at the top of the while or infinite program loop. Don't forget to initialize the edge_t struct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;edge_t&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUTTON&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_neg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OLD&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


        &lt;span class="c1"&gt;// Inifinite loop, user code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, I am reading the input from a button that is connected to one of the digital pins on an Arduino.&lt;/p&gt;

&lt;p&gt;Now we are set! At the beginning, it looks a bit clunky, but you will understand how easy it works below.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it?
&lt;/h2&gt;

&lt;p&gt;If you only have one button in your circuit/project, it's going to be incredibly easy to use this edge detection.&lt;/p&gt;

&lt;p&gt;We have the possibility to detect/get the following properties of the button:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The current state&lt;/li&gt;
&lt;li&gt;The state it had in the previous cycle&lt;/li&gt;
&lt;li&gt;Change of state&lt;/li&gt;
&lt;li&gt;Positive edge&lt;/li&gt;
&lt;li&gt;Negative edge&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is how you can detect/get these properties:&lt;/p&gt;

&lt;h3&gt;
  
  
  The current state
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Button is pressed!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Detects if the button is pressed. equivalent of "if(digitalRead(BUTTON))"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The button state in the previous cycle
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Button was pressed last cycle!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Detects if the button was pressed the cycle before&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Change of state
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Button State changed!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Detects if the button changed from not pressed to pressed, and vice versa&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Positive Edge
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Button pressed down!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Detects if the button changed from not pressed to pressed (Positive Edge)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Negative Edge
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_neg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Button released!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Detects if the button changed from pressed to not pressed (Negative Edge)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;Now follows the explanation of these code lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUTTON&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_neg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;To illustrate the states of the boolean values, I will be using Level Diagrams, where each square represents one iteration of the infinite program loop.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  btn.act
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUTTON&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(In this example, we are again reading a button input that is connected to a digital pin of an Arduino)&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;act&lt;/strong&gt; value is straightforward to understand, as it always has the same value as &lt;strong&gt;digitalRead(BUTTON)&lt;/strong&gt;. Throughout the rest of the explanation, I will refer to the current button state as &lt;strong&gt;act&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5fyvib7z15jrnhpw3q9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5fyvib7z15jrnhpw3q9.PNG" alt=" " width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  btn.old
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUTTON&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;old&lt;/strong&gt; value refers to the state of the button in the previous iteration of the program loop. It is always the state of the button in the previous cycle. We save the value &lt;strong&gt;act&lt;/strong&gt; into &lt;strong&gt;old&lt;/strong&gt;, and then first we get the new value for &lt;strong&gt;act&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsw2tsszefc2xuix7128x.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsw2tsszefc2xuix7128x.PNG" alt=" " width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  btn.edge
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it gets interesting. The "^" operator, also known as the XOR operator, detects whether two values are different. It returns true if the values are different and false if the values are the same. So now we have the possibility to detect a change in the state of the button, if we compare &lt;strong&gt;act&lt;/strong&gt; and &lt;strong&gt;old&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feyfpec3ypwu10dy26z4t.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feyfpec3ypwu10dy26z4t.PNG" alt=" " width="800" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  btn.edge_pos
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the &lt;strong&gt;edge_pos&lt;/strong&gt; is the one we are all looking for! This detects the positive edge, or the change from not pressed to pressed.&lt;/p&gt;

&lt;p&gt;We compare the value &lt;strong&gt;edge&lt;/strong&gt; and &lt;strong&gt;act&lt;/strong&gt; with an AND operator. The AND operator returns true if both values are true.&lt;/p&gt;

&lt;p&gt;If &lt;strong&gt;edge&lt;/strong&gt; is true, we know that we had a change in the button state. The change is detected if &lt;strong&gt;act&lt;/strong&gt; and &lt;strong&gt;old&lt;/strong&gt; are unequal.&lt;/p&gt;

&lt;p&gt;If we have a change from not pressed to pressed, act is true and old is false. If we have a change from pressed to not pressed, act is false and old is true. That's why we can compare &lt;strong&gt;edge&lt;/strong&gt; and &lt;strong&gt;act&lt;/strong&gt; with the AND operator to get the positive edge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs253uy5koeu4x5zsvtez.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs253uy5koeu4x5zsvtez.PNG" alt=" " width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  btn.edge_neg
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_neg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are cases where you have to read the negative edge of a signal.&lt;/p&gt;

&lt;p&gt;As I explained before, if we have a change from pressed to not pressed, &lt;strong&gt;act&lt;/strong&gt; is false and &lt;strong&gt;old&lt;/strong&gt; is true. So now we can compare &lt;strong&gt;edge&lt;/strong&gt; and &lt;strong&gt;old&lt;/strong&gt; with the AND operator to get the negative edge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6ri2do4ysmqzicjw8hd.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6ri2do4ysmqzicjw8hd.PNG" alt=" " width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  More than one button?
&lt;/h2&gt;

&lt;p&gt;So, you have more than one button in your project, and every button needs edge detection? Don't think that you have to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;edge_t&lt;/span&gt; &lt;span class="n"&gt;btn1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="n"&gt;edge_t&lt;/span&gt; &lt;span class="n"&gt;btn2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="n"&gt;edge_t&lt;/span&gt; &lt;span class="n"&gt;btn3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="n"&gt;edge_t&lt;/span&gt; &lt;span class="n"&gt;btn4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since every value in the struct is declared as uint8_t, we have 8 bits to use in every value! The only thing we have to do to have more than just one button is to redefine the &lt;strong&gt;act&lt;/strong&gt; value.&lt;/p&gt;

&lt;p&gt;I'm going to make an example where I have 8 buttons, and every button is connected to one digital pin of an Arduino from pin 1 to 8:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;act&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;   &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://dev.to/dariocasciato/bits-and-bytes-a-comprehensive-guide-to-bit-manipulation-for-developers-m5c"&gt;My Article about Bit-Manipulation&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, every bit of &lt;strong&gt;act&lt;/strong&gt; corresponds to one button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frz8bkn2gpsy3g4ihbkst.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frz8bkn2gpsy3g4ihbkst.PNG" alt=" " width="649" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can't use &lt;strong&gt;if(btn.edge_pos)&lt;/strong&gt; anymore. We need to specify which button we want to detect. This can be done with a bit mask.&lt;/p&gt;

&lt;p&gt;I like to create &lt;strong&gt;Defines&lt;/strong&gt; for every button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;//                  HEX         BINARY&lt;/span&gt;
&lt;span class="cp"&gt;#define BUTTON_1    0x01    //  00000001
#define BUTTON_2    0x02    //  00000010
#define BUTTON_3    0x04    //  00000100
#define BUTTON_4    0x08    //  00001000
#define BUTTON_5    0x10    //  00010000
#define BUTTON_6    0x20    //  00100000
#define BUTTON_7    0x40    //  01000000
#define BUTTON_8    0x80    //  10000000
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every value I gave the defines represents one bit for the &lt;strong&gt;uint8_t act&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;From here, it is straightforward. If we want to detect, for example, the positive edge of the third button, we can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;edge_pos&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;BUTTON_3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this bit mask, we allow it to detect changes only for the specific bit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale
&lt;/h2&gt;

&lt;p&gt;Thank you for reading! I encourage you to continue exploring this topic further and see how you can apply it in your projects. I am excited to announce that I will be continuing this series on Firmware Basics!&lt;/p&gt;

&lt;p&gt;Feel free to leave any comments or questions below, and I'll do my best to help you out!&lt;/p&gt;

&lt;p&gt;May your code be bug-free!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>website</category>
    </item>
    <item>
      <title>Countdown to Chaos: What You Need to Know About the Unix Time Stamp Problem in 2038</title>
      <dc:creator>DarioCasciato</dc:creator>
      <pubDate>Mon, 20 Feb 2023 13:04:12 +0000</pubDate>
      <link>https://dev.to/dariocasciato/countdown-to-chaos-what-you-need-to-know-about-the-unix-time-stamp-problem-in-2038-3oad</link>
      <guid>https://dev.to/dariocasciato/countdown-to-chaos-what-you-need-to-know-about-the-unix-time-stamp-problem-in-2038-3oad</guid>
      <description>&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Integer_overflow#/media/File:Odometer_rollover.jpg" rel="noopener noreferrer"&gt;(Title Picture)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We've heard about the Unix Time Stamp issue that's looming on the horizon. It's a problem that could impact a variety of computer systems in the year 2038, but why is this such a big deal?&lt;/p&gt;

&lt;h2&gt;
  
  
  Unix Time Stamp: The Basics
&lt;/h2&gt;

&lt;p&gt;To start, let's go over the basics. The Unix Time Stamp is a system that measures the number of seconds that have passed since &lt;strong&gt;January 1st, 1970 at 00:00:00 UTC&lt;/strong&gt;. This system is used by many different computer systems, including Linux, macOS, and various programming languages.&lt;/p&gt;

&lt;p&gt;The Unix Time Stamp is stored as a 32-bit signed integer, which means it can only represent up to 2,147,483,647 seconds. This number corresponds to &lt;strong&gt;January 19th, 2038 at 03:14:07 UTC&lt;/strong&gt;. After this point, the Unix Time Stamp will reset to zero and cause a malfunction in a variety of computer systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  The New Y2K?
&lt;/h2&gt;

&lt;p&gt;The Unix Time Stamp issue has been likened to the &lt;a href="https://education.nationalgeographic.org/resource/Y2K-bug/" rel="noopener noreferrer"&gt;Y2K bug&lt;/a&gt;, which was a problem that occurred in the year 2000. The Y2K bug occurred because many computer systems used a two-digit representation of the year, which meant they couldn't tell the difference between the year 1900 and the year 2000. This caused a variety of computer systems to malfunction and led to concerns about significant disruption.&lt;/p&gt;

&lt;p&gt;In the same way, the Unix Time Stamp issue will cause a variety of computer systems to malfunction after the year 2038. This is because the system will interpret the overflowed value as a negative number, which can cause problems with date calculations, software installations, and other crucial functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Impacts of the Unix Time Stamp Issue
&lt;/h2&gt;

&lt;p&gt;The effects of the Unix Time Stamp issue are difficult to predict, but they could be disastrous. The problem will impact a variety of critical infrastructure systems, including power grids, transportation systems, and financial systems. These systems depend on accurate time measurements to function correctly, and any disturbance could result in significant issues.&lt;/p&gt;

&lt;p&gt;Additionally, the problem will also impact a variety of software systems, including web servers, databases, and mobile devices. This could cause crashes, data corruption, and other problems that could have an impact on the user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Can Be Done?
&lt;/h2&gt;

&lt;p&gt;There are several different ways to address the impacts of the Unix Time Stamp issue. One solution is to switch to a 64-bit Unix Time Stamp, which would allow for much larger values and eliminate the overflow problem. Another solution is to switch to a different system for measuring time, such as the Network Time Protocol (NTP).&lt;/p&gt;

&lt;p&gt;However, these solutions are not easy to implement and will require significant effort from software developers, system administrators, and other stakeholders. It's also possible that many legacy systems will not be updated in time, which could lead to widespread disruption.&lt;/p&gt;

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

&lt;p&gt;The Unix Time Stamp issue is a problem that could impact a variety of computer systems in the year 2038. The issue will cause critical infrastructure systems to malfunction and could potentially result in significant disruption. Although there are solutions available to address the problem, they will require a significant effort from everyone involved. As we approach the year 2038, it's important that we take the necessary steps to prepare for this problem and ensure that our computer systems are ready for the next millennium.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;(This Article was written with the help of AI)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>unixtime</category>
      <category>bug</category>
      <category>problem</category>
      <category>future</category>
    </item>
  </channel>
</rss>
