<?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: FallingDownCat</title>
    <description>The latest articles on DEV Community by FallingDownCat (@fallingdowncat).</description>
    <link>https://dev.to/fallingdowncat</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%2F3866130%2Fc537f612-df6b-4198-a36c-11ab9f8d9e6b.png</url>
      <title>DEV Community: FallingDownCat</title>
      <link>https://dev.to/fallingdowncat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fallingdowncat"/>
    <language>en</language>
    <item>
      <title>Desk clock idea</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Wed, 08 Apr 2026 13:49:11 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/desk-clock-idea-2f0p</link>
      <guid>https://dev.to/fallingdowncat/desk-clock-idea-2f0p</guid>
      <description>&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%2Fmip4fgeddg73ojpe499z.jpg" 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%2Fmip4fgeddg73ojpe499z.jpg" alt="Desk clock idea" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This idea was in my head for quite a while. It actually started from an idea to make a product that i can sell, or at least try to sell. The market does not need any more clocks, however i didn't see much of this kind of clocks. There are a lot of led matrix clocks, and stock or crypto real time trackers that serve as a desk accessory. But this one will have the ability to display images alongside the numbers/text on the e-paper display. I'm not saying it's something revolutionary, in fact it's incredibly simple or might say dumb. But there is not much of those out there.&lt;/p&gt;

&lt;p&gt;The concept for how it will look is something like: A small 2.6 or 2.14 inch epaper display, that draws power from two AA batteries. And all of that is packaged in a case that is as small as all those components allow.&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%2F9057gh5ngvwdp4g9uk3h.jpg" 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%2F9057gh5ngvwdp4g9uk3h.jpg" alt="Desk clock idea" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't mind the bad drawings, but on image above there are two of those long epaper displays, and one small square one. The problem with small is that i don't know where to place the battery, and what battery to use. Maybe two coin batteries, but that won't last long. They don't deliver nearly close to 2xAA batteries. So that one will have to be scraped for the time being.&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%2F797ypw4lmqsc260vp53b.jpg" 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%2F797ypw4lmqsc260vp53b.jpg" alt="Desk clock idea" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And again in the image above is the backside of the clock showing two AA batteries. Additionally, there are 3 buttons at the top of the back panel, but still underneath the lid. Those buttons will be used for setting up the time at the beginning, and later for changing the style of the screen, for example image or font.&lt;/p&gt;

&lt;p&gt;Well in order to do it there needs to be some kind of schematic. Good thing is there are not many components that need to be implemented. It pretty much all can be done with one microcontroller, 3 buttons and a voltage regulator. At first i tried making it with ESP32 microcontroller, but that's an overkill. And it does not have RTC built in, so it needs one extra component from the outside, So i decided using STM32F103, aka Bluepill. A great and cheap microcontroller that will draw low power so batteries won't drain fast.&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%2Fk63i29vlejtcny1b8cbh.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%2Fk63i29vlejtcny1b8cbh.png" alt="Desk clock idea" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In KiCad, it is all straight forward, but that epaper display connector is a bit tricky. I don't understand it a single bit, but great thing is there are schematics from the display dealer. GoodDisplay is a company that sells those, maybe even manufactures, I'm not sure. However, they got the best prices out there and on their website there are all the documents and schematic i need.&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%2Fbuzquyaxbo77alzr49k0.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%2Fbuzquyaxbo77alzr49k0.png" alt="Desk clock idea" width="800" height="659"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have not yet made any PCB designs, actually i did once but scraped the whole PCB, it was really bad. But it will be exact dimensions as display so it can be glued to the back of it. And for casing i don't know how to make it before i get the PCB in my hands. I might export 3D object of a PCB from KiCad and try to make something in FreeCAD, but i don't have enough knowledge in there to utilize that workflow. I know how to make simple designs, and if there needs to be something complex i suppose i can make two separate pieces and then glue them xD. It's so bad to say it that way, but it is what it is.&lt;/p&gt;

&lt;p&gt;Additionally, I made some display mockups:&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%2F1jmgfzvmu1crqau3xjgl.jpg" 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%2F1jmgfzvmu1crqau3xjgl.jpg" alt="Desk clock idea" width="296" height="152"&gt;&lt;/a&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%2F9uphh8gmx6j1kqy6op21.jpg" 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%2F9uphh8gmx6j1kqy6op21.jpg" alt="Desk clock idea" width="296" height="152"&gt;&lt;/a&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%2F2rfabre5mtsiu4jw0zkd.jpg" 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%2F2rfabre5mtsiu4jw0zkd.jpg" alt="Desk clock idea" width="296" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem is it might not look that good. Those palm trees won't actually look gray, the screen works only in black and white, so they will be completely black. But i just wanted to show how cool it might look. Right now Peanuts and Scrooge McDuck are copyright problems, so they won't be there in production. But palm trees can look cool too. Or i might draw something myself xD.&lt;/p&gt;

&lt;p&gt;So how much all this can cost?&lt;br&gt;&lt;br&gt;
-STM32F103 - 2.4854$&lt;br&gt;&lt;br&gt;
-XC9140A331MR-G - 0.62$&lt;br&gt;&lt;br&gt;
-2.66 Inch E Ink Display - 5.27$&lt;br&gt;&lt;br&gt;
-Other passive components - 1$&lt;br&gt;&lt;br&gt;
-3D printer filament - 0.75$&lt;/p&gt;

&lt;p&gt;Total - 10.125$&lt;/p&gt;

&lt;p&gt;As with everything in electronics if components are bought in bulk the price goes down. That's the whole deal, in the near future if i think the idea might have a chance then a couple of PCB boards will be assembled. But i have a dilemma. It's only one of the ideas, and the clock is not particularly useful. I mean it shows time, but everything else shows time. It does not solve any serious problem It might look cool if assembled right, maybe there was a problem that clocks don't look cool, but i doubt it. Maybe i can get some feedback from this post. I guess that's why i wrote this.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>design</category>
      <category>iot</category>
      <category>sideprojects</category>
      <category>startup</category>
    </item>
    <item>
      <title>Can open source outperform proprietary software?</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Tue, 07 Apr 2026 12:03:07 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/can-open-source-outperform-proprietary-software-10ha</link>
      <guid>https://dev.to/fallingdowncat/can-open-source-outperform-proprietary-software-10ha</guid>
      <description>&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%2Fhtixa6ea7focejhm5rf9.jpg" 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%2Fhtixa6ea7focejhm5rf9.jpg" alt="Can open source outperform proprietary software?" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lately my YouTube algorithm decide i need to watch a lot of videos about Linus Torvalds, and how Linux was made. That was the start of this blog post. So thank you YouTube.&lt;/p&gt;

&lt;p&gt;To me, the open source software is so badass when compared to closed source. There is something so cool when it's all there on the open. Everyone in the world can just access it and maybe tweak it if enough knowledge is there. The question is: Can open source strategy beat closed source products of those big companies.&lt;/p&gt;

&lt;p&gt;It's not the case that close source software is bad. Actually it's great. But there is none of the freedom in that. Why would you need freedom to use a software? That's a valid question. But i have a feeling that the reason open source software succeed is that other people see the idea of that particular software different from developers that started it. And maybe that ideas is more true than the original one.&lt;/p&gt;

&lt;p&gt;Why would in this situation someone be more true? I guess the software gets popular amongst community if it does one particular thing in a good way, and if there is no amount of truth in that, then there would never be "the best" software of any kind. There wouldn't be tier list of software products.&lt;/p&gt;

&lt;p&gt;Right now I'm talking about software, but i guess anything can be open source. I guess that happens when someone decides not to put patent on something. But patents are a bit different, and a conversation for themselves.&lt;/p&gt;

&lt;p&gt;Let's take the case that I'm familiar with. Open source game engines. Godot in particular is a great example right now. Slay the Spire is currently popular game that was created in Godot. And Godot as an open source game engine was around for a while, but it wasn't used much in the industry. But games like this show that there is money to be made with open source tools. It's there for the taking.&lt;/p&gt;

&lt;p&gt;I remember a while a go i tried to make a game with Godot. And while researching the capabilities of game engine i found out that some features that are usually there in more professional game engines are not there in Godot. Features tied to finishing the game once when it's at the end of development. And i remember from that point i didn't like Godot that much. But now, years later. Those things are fixed and patched, hence all those released games with Godot. It's mostly small independent developers, but that's just a beginning i feel. If we pretend that those big game companies are greedy. Why wouldn't they make a game with a open source and free engine. I guess it's possible to make some kind of deals with proprietary game engine companies. But, i don't think that can be a deciding factor. After all, the most of the open source stuff is free.&lt;/p&gt;

&lt;p&gt;Now i need to get back to tracks. The original question was: Can open source outperform proprietary software. Why is usually the case that open source is less than, or worse than commercial software? I think i figured that one. Usually when it comes to how well someone can do something is due to time.&lt;/p&gt;

&lt;p&gt;Time spent doing it. And i believe time outperforms effort. One good example from my life is phones. Now this example has nothing to do with open source, but it shows how time can help. Usually i buy Samsung phones, but i also like cheap prices, so i bought Xiaomi phone. The problem with that was how Xiaomi just does not have or know certain things exist. For example, it could not connect to my Android Auto. My guess is that no one thought about it. While with Samsung, the pairing with Android Auto is flawless. Well Samsung had a lot of time to iron out all the quirks. The first phone Samsung made was 1988, and first phone Xiaomi made was 2011. That's a lot of years missing out if we compare to Samsung.&lt;/p&gt;

&lt;p&gt;So my case is that majority of open source software started after someone didn't like all the features of closed source software. That implies that most of open source is younger. Even if it's 1 or 2 years, it's still a lot of time. Even though maybe there is a lot more effort being put in with all the contributors of open source project. Majority of problems need time to be detected and solved.&lt;/p&gt;

&lt;p&gt;As i wrote all this it came to me why would big companies go for commercial closed source tools. When problem arrives the company can say to the company that made the software/tool just to fix it. And the developers of that software have to fix it fast. Maybe even write some kind of legal paper that will hold them accountable if software falls. In case of open source there is just a bunch of really smart people. And if someone came to them and said: Fix this right now, or else... They would just say "go to hell". So when something is open source there is no one to hold accountable.&lt;/p&gt;

&lt;p&gt;Maybe the point is that someone is held accountable, and maybe the point is that no one is held accountable. So my guess is that some things just have to be closed source, else it wouldn't be good as closed source. And some things just have to be closed source, because accountability is needed, or else it would be an anarchy. I guess it's a fine line that has to be explored, it's impossible to see the right answer. The right answers might show with time.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>linux</category>
      <category>opensource</category>
      <category>software</category>
    </item>
    <item>
      <title>Smallest keyboard layout</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Mon, 06 Apr 2026 07:46:34 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/smallest-keyboard-layout-3m77</link>
      <guid>https://dev.to/fallingdowncat/smallest-keyboard-layout-3m77</guid>
      <description>&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%2F3pfbgr2alphhyo2gch0z.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%2F3pfbgr2alphhyo2gch0z.png" alt="Smallest keyboard layout" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Smallest keyboard layout possible is called 40% keyboard. It has about 40 switches, and those are all letters and couple of necessary keys for writing, like space, enter, backspace... In order to make something like that keyboard, a microcontroller with HID capabilities is required. In my case i used STM32F103 aka Bluepill.&lt;/p&gt;

&lt;p&gt;It's possible to just buy one of those development board really cheap from China, and hand wire all the key switches to it and there is the keyboard. The problem with that kind of assembly is that it's unnecessarily bulky. It's too fat for my taste. The Cherry MX keyboard switches that i intend to use are bulky enough by itself, and when added a centimeter or so to it, it's really high for hand placement.&lt;/p&gt;

&lt;p&gt;The solution to that in my case is designing a PCB that will hold microcontroller and all the key switches. That's actually the reason i want to make the smallest keyboard possible. If the 40% is built successful, then i can take same microcontroller, and it's subcomponents and just copy those to new PCB and add a few more rows of key switches.&lt;/p&gt;

&lt;p&gt;What's the actual way that PCB will be made? KiCAD is the key. KiCAD will do almost half of the job for me.&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%2Fix3wosw8s6iv13heiwpz.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%2Fix3wosw8s6iv13heiwpz.png" alt="Smallest keyboard layout" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main schematic is actually easy enough. If one does not know, or has a hard time selecting and designing a schematic. There are a lot of open source keyboard schematics that can be used as a reference, or just copied. I found a lot of those on Github, and after i finish this project completely i will upload it to Github so it's available to others after me.&lt;/p&gt;

&lt;p&gt;Now onto the actual keyboard layout. There is a great tool on the internet that will plan everything out, and in case i want to change that plan a little, i can do it. It's &lt;a href="https://www.keyboard-layout-editor.com/?ref=fallingdowncat.com#/" rel="noopener noreferrer"&gt;keyboard-layout-editor.com&lt;/a&gt; , a tool that will plan out a keyboard, and then a plugin for KiCad can interpret that exact plan and position components on the PCB for me. The problem with keyboards is how those keys are positioned, it's not a perfect grid.&lt;/p&gt;

&lt;p&gt;All the rows are misaligned, and I'm not sure why is that. Perhaps that's how someone who first created a keyboard did it, and then everyone just copied. At the end of a day I'm copying it xD. Onwards.&lt;/p&gt;

&lt;p&gt;Keyboard footprints placer is a plugin for KiCAD that takes the layout that keyboard layout editor made and it just places all the keys in the order it's planned.&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%2Fozq1lc58az2rxmi6gvhu.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%2Fozq1lc58az2rxmi6gvhu.png" alt="Smallest keyboard layout" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One more thing for creating that layout is keyboard switch PCB footprints. For that there is one more KiCAD plugin called Keyswitch Kicad Library. It adds all the major key switch footprints, so only thing left is to assign those footprints. And after all the keys are in proper order, the only thing left is to position microcontroller and other components.&lt;/p&gt;

&lt;p&gt;Run all the traces, remove all the error that occur, and recommendation is to draw ground planes, so weird inputs never happen. To be honest i don't know the exact details of what happens if good ground connection is not implemented. Only thing is certain, is that if ground trace is not connected where it should be, the component just won't work, and if it's not connected or connection is broken from USB receptacle to components, then a whole keyboard just won't work. And after routing which is actually the most time consuming part of this process.&lt;/p&gt;

&lt;p&gt;The finished board looks like this:&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%2Fc90yckhk59t7rbb64wl9.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%2Fc90yckhk59t7rbb64wl9.png" alt="Smallest keyboard layout" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I rounded the corners a little so it looks cool :). The problem i encountered is that there was no place at the top of the keyboard to place a USB-C receptacle, so i extended PCB a little on top so USB can fit. Even though the goal is to make those sides as small as possible, so they dont poke out too much when keyboard is assembled, i think when keyboard has a bit bigger top part, it still looks cool.&lt;/p&gt;

&lt;p&gt;Plans after the PCB is in:&lt;br&gt;&lt;br&gt;
Assemble the whole PCB, currently 5 units is ordered, my guess is i will screw one or two in soldering, and others should work. If everything goes well, produce another keyboard PCB. This time 65%, that one is my favorite, and with that order more 40% PCBs, maybe improve on this design if flaw are discovered.&lt;/p&gt;

&lt;p&gt;That's it, thanks for reading.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>showdev</category>
      <category>sideprojects</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>PI regulator in code</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Sun, 05 Apr 2026 16:19:53 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/pi-regulator-in-code-2pcn</link>
      <guid>https://dev.to/fallingdowncat/pi-regulator-in-code-2pcn</guid>
      <description>&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%2Fsjlrh0xfj7y2dgjjqddq.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%2Fsjlrh0xfj7y2dgjjqddq.png" alt="PI regulator in code" width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Goal of the day is understanding the PI regulator. Before anything there is a great resource that explains PI and other regulators in detail and its: &lt;a href="https://controlsystemsacademy.com/0007/0007.html?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;controlsystemsacademy.com&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;t&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="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Time vector&lt;/span&gt;
&lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Desired value&lt;/span&gt;
&lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Proportional gain(how strong the P part is)&lt;/span&gt;
&lt;span class="n"&gt;Ki&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Integral gain(how stron the integral part is)&lt;/span&gt;
&lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;% Output&lt;/span&gt;
&lt;span class="nb"&gt;integral&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="c1"&gt;% Integral accumulator&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;integral&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;integral&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Accumulate over time&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Ki&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;integral&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% PI control signal&lt;/span&gt;
    &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;setpoint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'r--'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Time'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;grid&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;For loop is doing all the work for us here. It does the calculations for proportional part, in other words it's just taking the difference between setpoint and current value and multiplies it by gain. On top of that it adds integral part, or in simpler words. It adds up the area underneath the current value as it rises or falls and sums it up and adds it to the current value. So that way it's actually possible to get to the desired value.&lt;/p&gt;

&lt;p&gt;The output looks like this:&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%2Fi6l3bmmeee748dmrz5dx.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%2Fi6l3bmmeee748dmrz5dx.png" alt="PI regulator in code" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PI regulator with disturbance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;t&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="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Time vector&lt;/span&gt;
&lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Desired value&lt;/span&gt;
&lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Proportional gain&lt;/span&gt;
&lt;span class="n"&gt;Ki&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Integral gain&lt;/span&gt;
&lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;disturbance_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% When disturbance kicks in&lt;/span&gt;
&lt;span class="n"&gt;disturbance_mag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Magnitude of disturbance&lt;/span&gt;

&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;% Output&lt;/span&gt;
&lt;span class="nb"&gt;integral&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="c1"&gt;% Integral accumulator&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;integral&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;integral&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Ki&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;integral&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;% Step disturbance added to the plant input&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;disturbance_mag&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;disturbance_time&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;setpoint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'r--'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;xline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;disturbance_time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'k:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Disturbance'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'LabelVerticalAlignment'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'bottom'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Time'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;grid&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Right here at the fifth second a step disturbance is applied, so we can see how it affects the system with PI regulator.&lt;/p&gt;

&lt;p&gt;Output:&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%2F2ftuqwvqyg6roqp07w0u.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%2F2ftuqwvqyg6roqp07w0u.png" alt="PI regulator in code" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's possible to see how system gets right back to the setpoint value after the disturbance is applied. As opposed to just proportional regulator which stays on the value of the initial disturbance.&lt;/p&gt;

&lt;p&gt;At the end i would like to show what i found on the Internet:&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%2Fnhnqdfql68qynry7gfd9.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%2Fnhnqdfql68qynry7gfd9.png" alt="PI regulator in code" width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a 3D graph showing how response is changing depending on Ki variable changing.&lt;/p&gt;

&lt;p&gt;PI regulator is used when just proportional regulator is not enough. It's used in motor speed control, thermal regulation, liquid flow control. It's baffling how important it is and how little i knew about it, and still know. The point of this is trying to understand it to the best of my ability. With code I'm somehow able to understand it easier, but when those math formulas get thrown in the picture, it's easy to just give up on it. But when we think about it, it's not that complicated.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>science</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Doing math the cool way (GNU Octave)</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Sat, 04 Apr 2026 15:26:50 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/doing-math-the-cool-way-gnu-octave-hjn</link>
      <guid>https://dev.to/fallingdowncat/doing-math-the-cool-way-gnu-octave-hjn</guid>
      <description>&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%2Fho1p2hgej686x1wbuxob.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%2Fho1p2hgej686x1wbuxob.png" alt="Doing math the cool way (GNU Octave)" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I remember in college, there was one math professor that did the problem examples on the whiteboard, but when he got stuck he will real quick go to his laptop, open GNU Octave and type in a short formula that will solve him the whole problem. And then he would say: "Ah i see where i went wrong", then he would go back to the whiteboard and complete the problem. That seemed so cool to me. But at that time i did not try doing anything like it because it seemed hard, and i have more on my plate than math problems. But now when I'm a bit older and smarter, i guess i can try a few things.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;mod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;21&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="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;To clear the command window type "clc", and to clear the variables type "clear all". Let's say the goal is to solve problem of two equations and two unknown variables then we use matrix method Ax = b (dont know how that method is called...).&lt;/p&gt;

&lt;p&gt;Let's say we have:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2x+3y=8 and x-y=1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we turn that into matrices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="n"&gt;Left&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;equal&lt;/span&gt; &lt;span class="nb"&gt;sign&lt;/span&gt;
&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="o"&gt;=&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="mi"&gt;3&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;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="n"&gt;Right&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;equal&lt;/span&gt; &lt;span class="nb"&gt;sign&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;And then we solve for x by doing:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;x = inv(A) * b&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;

   &lt;span class="mf"&gt;2.2000&lt;/span&gt;
   &lt;span class="mf"&gt;1.2000&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This is the fastest way to soling this kind of equations, and i believe it's the simplest way for computers to solve it, however i don't like it that much. But it is what it is. Onwards.&lt;/p&gt;

&lt;p&gt;It's possible to quickly make arrays with lots of numbers, actually in last post about proportional regulators there was a graph that was made with those.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;t&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This will make array that goes from 0 to 20 in increments of 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;

    &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;And on top of that it's possible to perform operations on that array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;
&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;

    &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;

    &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;

&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="nb"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;

    &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="mi"&gt;33&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt; &lt;span class="mi"&gt;39&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt; &lt;span class="mi"&gt;51&lt;/span&gt; &lt;span class="mi"&gt;54&lt;/span&gt; &lt;span class="mi"&gt;57&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;

&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Now i feel stupid for showing this, it feels like a second nature to everyone, so for the end i will show a little of control system functions. There is package called Control and is used specifically for simulating control systems. It's not that i know much about it, in fact i don't, but I'm trying to learn, and it seems so cool to use this tool.&lt;/p&gt;

&lt;p&gt;Here is the proportional regulator, aka P regulator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pkg&lt;/span&gt; &lt;span class="nb"&gt;load&lt;/span&gt; &lt;span class="n"&gt;control&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;t&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="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Kp&lt;/span&gt;&lt;span class="p"&gt;,&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="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;Kp&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;lsim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;octave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="s1"&gt;'r--'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&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%2Fem5b66lo3crzdw5y979e.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%2Fem5b66lo3crzdw5y979e.png" alt="Doing math the cool way (GNU Octave)" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it made a graph. It's great. I forgot something earlier. The command "who" is to show what variables are currently in use, and then "clear all" is to delete them all.&lt;/p&gt;

&lt;p&gt;That's it, thanks for reading.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>programming</category>
      <category>science</category>
      <category>tooling</category>
    </item>
    <item>
      <title>What's a proportional controller?</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Fri, 03 Apr 2026 19:53:22 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/whats-a-proportional-controller-3mjd</link>
      <guid>https://dev.to/fallingdowncat/whats-a-proportional-controller-3mjd</guid>
      <description>&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%2Fmkuq8tykvsbx4tfzthcy.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%2Fmkuq8tykvsbx4tfzthcy.png" alt="What's a proportional controller?" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even though system control was main subject for me for a while in college, i did not grasp on that subject too well. The main outline is clear to me. We got closed loop and in place of the controller it's possible to put all kinds of controllers.&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%2Fggamtq9qkpowqo7273fw.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%2Fggamtq9qkpowqo7273fw.png" alt="What's a proportional controller?" width="689" height="283"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;From Tutorialspoint website&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For example P, or PI, or PID. The goal for today is understanding P (proportional) controller a little bit more. To do that i figured its easiest trough code.&lt;/p&gt;

&lt;p&gt;Why code? Because there is no calculus to be deciphered. It's just a for loop that sums up everything every time it loops trough time. The next code is written in GNU Octave, it's a free and open source software similar to Matlab, and it's especially made for calculating almost anything.&lt;/p&gt;

&lt;p&gt;P controller code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;t&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="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Time vector&lt;/span&gt;
&lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Desired value&lt;/span&gt;
&lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% Proportional gain&lt;/span&gt;

&lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;% Output&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;setpoint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'r--'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Time'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output y(t)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Setpoint'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'P Regulator (Kp = %.1f)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nb"&gt;grid&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;-First there is t=0:0.01:10; And that's making an array from 0 to 10 with increments of 0.01.&lt;br&gt;&lt;br&gt;
-"setpoint" is desired value the system has to follow, for example this can be a temperature on a thermostat.&lt;br&gt;&lt;br&gt;
-"Kp" is literally a gain by which is system defined, in other words, how strong does it react to changes.&lt;br&gt;&lt;br&gt;
-"dt" is an increment of time between steps, it's also how much is increment in the first variable called "t".&lt;/p&gt;

&lt;p&gt;For loop in octave goes something like this:&lt;br&gt;&lt;br&gt;
for i = 1:5 (This means every loop i will be incremented by 1 until it gets to 5.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="nb"&gt;disp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;


&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;So in this case the for loop serves as a substitute for integral. It's less accurate, but accurate enough if the processor that runs the code is fast enough for my use case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If i try to go through one loop i get:&lt;br&gt;&lt;br&gt;
e = 1 - 0,&lt;br&gt;&lt;br&gt;
u = 2 * 1,&lt;br&gt;&lt;br&gt;
dy = (0 + 2) * 0.01,&lt;br&gt;&lt;br&gt;
y(1) = 0 + 0.02,&lt;/p&gt;

&lt;p&gt;And then code does that for as many times as there is increments and plots the whole array y against time.&lt;/p&gt;

&lt;p&gt;Output:&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%2Fcgb2vbmdugi5lsh76m5j.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%2Fcgb2vbmdugi5lsh76m5j.png" alt="What's a proportional controller?" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;P controller code with disturbance at 5 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight matlab"&gt;&lt;code&gt;&lt;span class="n"&gt;t&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="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;% Disturbance: step at t=5&lt;/span&gt;
&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setpoint&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;% &amp;lt;-- disturbance added here&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&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="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;setpoint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'r--'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'g:'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Time'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Output y(t)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Setpoint'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Disturbance'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'P Regulator with Step Disturbance (Kp = %.1f)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Kp&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nb"&gt;grid&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&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%2F79gweqwre20cfi85pv3y.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%2F79gweqwre20cfi85pv3y.png" alt="What's a proportional controller?" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right here disturbance is added at the fifth second.&lt;/p&gt;

&lt;p&gt;d = 0.5 * (t&amp;gt;=5), is a step function that switches only after t is bigger than 5.&lt;/p&gt;

&lt;p&gt;So in: dy = (-y(i-1) + u + d(i)) * dt; Until t is 5, the equation is the same as without disturbance, but after t is 5, then dy is bigger by 5.&lt;/p&gt;

&lt;p&gt;That's it, I'm sure i have complicated it more than needed. Thanks for reading.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>beginners</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Rotary Encoder is a cool component</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Mon, 23 Mar 2026 19:37:50 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/rotary-encoder-is-a-cool-component-59o0</link>
      <guid>https://dev.to/fallingdowncat/rotary-encoder-is-a-cool-component-59o0</guid>
      <description>&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%2Fw6lima73excmmxisgs81.jpg" 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%2Fw6lima73excmmxisgs81.jpg" alt="Rotary Encoder is a cool component" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found this little rotary encoder. At first i didn't know what that is, it looks like a potentiometer, but pins are weird. The pins are: GND, VCC, MS, DT, CLK It turns out it's a mechanical rotary encoder.&lt;/p&gt;

&lt;p&gt;What's rotary encoder used for?&lt;br&gt;&lt;br&gt;
First thing that comes to mind is volume button in my car. It can turn in any direction indefinitely. It's a cool thing, and I'm planning to pair it with stepper motor so that stepper motor follows my input in the encoder. In other words where i turn encoder, the motor should follow it 1 to 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;To the wiring and code:&lt;/strong&gt;
&lt;/h2&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%2Fyzz0z73x4ynh2qbez0bp.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%2Fyzz0z73x4ynh2qbez0bp.png" alt="Rotary Encoder is a cool component" width="795" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually encoders will have a button integrated in them, so that when knob is pressed it acts as a button. That's why there is one extra pin that i did not connect, i don't need that button currently.&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%2Fiw8siu1r3sap6p57g38r.jpg" 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%2Fiw8siu1r3sap6p57g38r.jpg" alt="Rotary Encoder is a cool component" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Arduino code:&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define CLK 2
#define DT 3
&lt;/span&gt;
&lt;span class="k"&gt;volatile&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;position&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="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CLK&lt;/span&gt;&lt;span class="p"&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;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DT&lt;/span&gt;&lt;span class="p"&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;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Trigger interrupt when CLK changes&lt;/span&gt;
  &lt;span class="n"&gt;attachInterrupt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalPinToInterrupt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CLK&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;readEncoder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CHANGE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;lastPosition&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;lastPosition&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;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Position: "&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="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;lastPosition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;position&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;// Interrupt function&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;readEncoder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;clkState&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;CLK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;dtState&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;DT&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;clkState&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dtState&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// clockwise&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// counterclockwise&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;The code uses interrupts. I don't like interrupts in the code, because I'm bad at it, but for this they are crucial. It's possible to make code work without interrupts, but it's less accurate, and sometimes it misses input, or just skips the input.&lt;/p&gt;

&lt;p&gt;The serial monitor will display current position of the encoder.&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%2Fpxijo0tmheop3ut0w050.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%2Fpxijo0tmheop3ut0w050.png" alt="Rotary Encoder is a cool component" width="586" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all. Thanks for reading!&lt;/p&gt;

</description>
      <category>project</category>
    </item>
    <item>
      <title>Cost of Making Mechanical Keyboard</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Sun, 22 Mar 2026 18:21:08 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/cost-of-making-mechanical-keyboard-4o9e</link>
      <guid>https://dev.to/fallingdowncat/cost-of-making-mechanical-keyboard-4o9e</guid>
      <description>&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%2Fulntskvzmfvkf2wy0myu.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%2Fulntskvzmfvkf2wy0myu.jpeg" alt="Cost of Making Mechanical Keyboard" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Considering how this is my &lt;a href="https://www.fallingdowncat.com/mechanical-keyboard-economics/" rel="noopener noreferrer"&gt;second post&lt;/a&gt; on the topic, and the first one didn't go well. I will try to redeem myself by performing a small exploration into how much it costs to make a mechanical keyboard from zero. Now there are some limitations to this. Of course i don't have direct experience with keyboard parts i will describe here, so quality of components may vary. But despite that my intention is to cram as much information, as many choices of components as possible, so there is a different choice for everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Conclusion is on the top so all this below is research that may not be interesting. Let's say the goal is to make the cheapest keyboard possible, without thinking of quality. Of course there is a correlation between quality and price, but in this case I'm pretending there is none.&lt;/p&gt;

&lt;p&gt;The keyboard is 65% format.&lt;br&gt;&lt;br&gt;
Key switches: 68 * 0.08€ = 5.44€,&lt;br&gt;&lt;br&gt;
Keycaps: 8€,&lt;br&gt;&lt;br&gt;
PCB: 3€,&lt;br&gt;&lt;br&gt;
Electronics components: 5.55€,&lt;br&gt;&lt;br&gt;
Casing(3D print): 2.15€&lt;/p&gt;

&lt;p&gt;In total, it's 24.14€ per keyboard.&lt;/p&gt;

&lt;p&gt;In case multiple is ordered and assembled then the price will be better:&lt;br&gt;&lt;br&gt;
Key switches: 68 * 0.08€ = 5.44€,&lt;br&gt;&lt;br&gt;
Keycaps: 8€,&lt;br&gt;&lt;br&gt;
PCB: 2.3€,&lt;br&gt;&lt;br&gt;
Electronics components: 5.15€,&lt;br&gt;&lt;br&gt;
Casing(3D print): 2.15€&lt;/p&gt;

&lt;p&gt;Total price: 23€.&lt;/p&gt;

&lt;p&gt;Mind you in this price the shipping is not included. The price will go up by 300% i can imagine when shipping is included. So the bulk order is actually even more suitable when we count in the shipping.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Switches:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Head first into the hardest part. First destination for ordering key switches was &lt;strong&gt;AliExpress&lt;/strong&gt;. Usually there is a cheaper alternative for almost everything, and i case of switches it absolutely is. Virtually any kind and type of keyboard switches, with most prominent Cherry MX type switches. Prices range from 0.2€ and upwards. Myself i bought two kinds of switches from Outemu store on AliExpress and both are good.&lt;/p&gt;

&lt;p&gt;Next in line that is also known to me and is not a common place to buy switches is &lt;a href="https://www.lcsc.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;LCSC Electronics&lt;/strong&gt;&lt;/a&gt;. It's an electronics component supplier that sells all kinds of components e.g. Resistors, capacitors, IC Chips... Amongst all of that there are a few kinds of mechanical keyboard switches. There is just a few Cherry MX types, but price is ridiculous.&lt;/p&gt;

&lt;p&gt;About &lt;strong&gt;0.08€&lt;/strong&gt; per key switch. It's a bit hard to find them, because they are described just with "Brown switch", "Red switch", "Black switch" labels. I ordered a couple just for fun, expecting nothing, but it turns out they are real and they work.&lt;/p&gt;

&lt;p&gt;Moving on. Now we are entering in the trenches. From here on out i did not try any of the services, it's just that people on Reddit seem to recommend all of these distributors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://akkogear.eu/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Akkogear.eu&lt;/strong&gt;&lt;/a&gt; is a shop only with key switches. It has nice prices e.g. &lt;strong&gt;0.18€&lt;/strong&gt; per switch, and upwards from there, depending on how fancy the switches are. There is a whole active subreddit dedicated to them r/akkogear.&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%2F9k788miv34tw6oll7qtv.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%2F9k788miv34tw6oll7qtv.png" alt="Cost of Making Mechanical Keyboard" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next is &lt;a href="https://milktooth.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Milktooth.com&lt;/strong&gt;&lt;/a&gt;. First impression is that they are a bit pricey, but with a bit of digging it turns out they have a big range of key switches. Some of them as low as &lt;strong&gt;0.19€&lt;/strong&gt; per switch. On the internet it seems that they are regarded as a quality distributor, with quality service.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/comments/1hyi72v/my_experience_with_milktooth/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;My experience with Milktooth&lt;/a&gt;&lt;br&gt;&lt;br&gt;
by&lt;a href="https://www.reddit.com/user/AerosolFNTM/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;u/AerosolFNTM&lt;/a&gt; in&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;MechanicalKeyboards&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next is &lt;a href="https://divinikey.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Divinikey.com&lt;/strong&gt;&lt;/a&gt; and they seem fancy. Why fancy? Because of prices. It seems that cheapest option is about &lt;strong&gt;0.24€&lt;/strong&gt;. Not groundbreaking expensive, but a bit higher than others. However, it seems that everyone on the forums likes them, and they are around for a few years now.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/comments/1alijwz/huge_shouts_to_divinikey/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;Huge shouts to Divinikey&lt;/a&gt;&lt;br&gt;&lt;br&gt;
by&lt;a href="https://www.reddit.com/user/MizuKumaa/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;u/MizuKumaa&lt;/a&gt; in&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;MechanicalKeyboards&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.gateron.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Gateron.com&lt;/strong&gt;&lt;/a&gt; seems like a well known name in the community. Same as previous shop. It seems they aren't braking any records with low prices, and the cheapest switches i could find are &lt;strong&gt;0.235€&lt;/strong&gt; a piece. However, people on Reddit all leave positive reviews.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/comments/1fv24ih/appreciation_for_gateron_switches/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;Appreciation for Gateron Switches&lt;/a&gt;&lt;br&gt;&lt;br&gt;
by&lt;a href="https://www.reddit.com/user/notapedophile3/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;u/notapedophile3&lt;/a&gt; in&lt;a href="https://www.reddit.com/r/MechanicalKeyboards/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;MechanicalKeyboards&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next is &lt;a href="https://www.gloriousgaming.com/en-eu?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Gloriousgaming.com&lt;/strong&gt;&lt;/a&gt;, and here is where things are becoming to be real. In a bad way. I don't know if it's my mistake or i couldn't find any key switch that's lower than &lt;strong&gt;0.6€&lt;/strong&gt; per piece. However, it seems that GloriousGaming has a huge following, with its own subreddit r/Glorious.&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%2F4spplaoxwj1lyyv25tcv.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%2F4spplaoxwj1lyyv25tcv.png" alt="Cost of Making Mechanical Keyboard" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's hard not to sound stupid now, but it's a bit too fancy for me.&lt;/p&gt;

&lt;p&gt;Next in line is &lt;a href="https://www.keychron.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Keychron.com&lt;/strong&gt;&lt;/a&gt;, as the leader in this hobby. Probably the most followed brand here. Has its own subreddit r/Keychron with almost 50k members.&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%2F7sph1crfh2otg1ndwd5h.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%2F7sph1crfh2otg1ndwd5h.png" alt="Cost of Making Mechanical Keyboard" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cheapest key switches i could find are about &lt;strong&gt;0.156€&lt;/strong&gt; per piece. Seems like Keychron has more than key switches. On their website they got displayed all kinds of keyboard and mice variations.&lt;/p&gt;

&lt;p&gt;Last on the list is &lt;a href="https://www.monsgeek.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Monsgeek.eu&lt;/strong&gt;&lt;/a&gt;. Another one with subreddit r/Monsgeek.&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%2Fbtnfbux8mgt8r5qytces.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%2Fbtnfbux8mgt8r5qytces.png" alt="Cost of Making Mechanical Keyboard" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cheapest switch i could find is &lt;strong&gt;0.27€&lt;/strong&gt; a piece.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Keycaps:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Well considering how i just went through all of these shops, and a lot of them have keycaps for sale, i will just list some prices. Mind you, prices are for a whole set of keycaps.&lt;/p&gt;

&lt;p&gt;AliExpress 8€ - 23€&lt;br&gt;&lt;br&gt;
Akkogear 12€ - 70€&lt;br&gt;&lt;br&gt;
Milktooth 33€ - 77€&lt;br&gt;&lt;br&gt;
Divinikey 50€-70€ (Price may vary, don't understand the pricing)&lt;br&gt;&lt;br&gt;
Keychron 15€ - 43€&lt;br&gt;&lt;br&gt;
Monsgeek 12€ - 48€&lt;/p&gt;

&lt;p&gt;Seems like no one can beat AliExpress, but Akkogear and Monsgeek have competitive prices. Problem is i did not research shipping prices, i know that for 8€ on AliExpress keycaps the shipping is included in the price. Crazy.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;PCB&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Printing a PCB.The price of designing a PCB will not be included considering how i can design it. So the questions is how much would it cost to print those PCBs and how much would components cost. So far i have used two services for printing PCBs. First is JLCPCB, and second is PCBWay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JLCPCB:&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%2Fw8asgg7tjjr9djt9esgr.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%2Fw8asgg7tjjr9djt9esgr.png" alt="Cost of Making Mechanical Keyboard" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If 5 boards are ordered, the price per board is &lt;strong&gt;3€&lt;/strong&gt;. However, if 30 boards are ordered, the price is &lt;strong&gt;2.3€&lt;/strong&gt;. And for fun if 500 boards are ordered then it's &lt;strong&gt;1.4€&lt;/strong&gt; , however shipping is about 300€ then.&lt;/p&gt;

&lt;p&gt;Which leads to the shipping cost. Shipping for 5 boards is 15.6€, for 30 boards it's 49€.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PCBWay&lt;/strong&gt; is a bit more expensive, however i have ordered with them in the past and everything went well.&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%2Fgwcng70hkz7623y62oem.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%2Fgwcng70hkz7623y62oem.png" alt="Cost of Making Mechanical Keyboard" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Price per PCB if 5 is ordered is 10€, if 30 then &lt;strong&gt;4.2€&lt;/strong&gt;. Shipping is virtually the same, because same standard shipping options are available.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Components&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Components are tricky because I'm lazy. There are a lot of components, but it's possible to just not count those small ones. For example the cost of one resistor can be about 0.0001€. So i will just calculate the biggest component which is the main microcontroller, and on top of that will add &lt;strong&gt;1€&lt;/strong&gt; that will cover all the small components.&lt;/p&gt;

&lt;p&gt;In this case the microcontroller is Atmega32U4. The best place to buy it is Mouser, for the price of 4.55€, and if 25 pieces are ordered then it's 4.16€.&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%2Fyvame7q3nl9k958ivx7y.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%2Fyvame7q3nl9k958ivx7y.png" alt="Cost of Making Mechanical Keyboard" width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is straight up the cheapest, but in case someone want's to explore more options i made a post called &lt;a href="https://www.fallingdowncat.com/where-to-buy-electronic-components/" rel="noopener noreferrer"&gt;&lt;strong&gt;Where to buy electronic components?&lt;/strong&gt;&lt;/a&gt; , and there i tried to find the cheapest microcontroller on the market. It's not Atmega32U4, but perhaps someone can do the steps i took there for this microcontroller.&lt;/p&gt;

&lt;p&gt;As for component conclusion the price for all components is 5.55€ for individual board, and for bulk of 30 boards it's 5.16€. I forgot to add soldering paste. The soldering paste is used to solder components to the board, and it's not the cheapest, but for the sake of this exploration i will forget about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Casing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Keyboard casing will be 3D printed. It is lower quality, but it will work. There are services provided by PCBWay and JLCPCB for manufacturing a more serious casing e.g. By injection molding. But i have never done that and don't know how to calculate the price for that.&lt;/p&gt;

&lt;p&gt;So for the price of 3D printing i will just explore how much 3D printer filament costs. In order to calculate how much 3D printing would cost i need to know how much filament will printer use for keyboard case. For that i found a &lt;a href="https://www.thingiverse.com/thing:3478494?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;nice keyboard casing on Thingiverse&lt;/a&gt; that will help.&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%2Fbbv662jw272q04f15p3h.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%2Fbbv662jw272q04f15p3h.png" alt="Cost of Making Mechanical Keyboard" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a whole casing it will take 255 grams of filament. While printing with on 3D printer, there are two main materials: PLA and PETG. Considering how usually PLA is euro or two cheaper than PETG, but PETG is more durable. On keyboard i believe PLA will work out just fine, so i will try to calculate the prices just for PLA material.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.elegoo.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Elegoo.com&lt;/strong&gt;&lt;/a&gt; sells PLA filaments for a price of &lt;strong&gt;12.5€&lt;/strong&gt; per Kg.&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%2Fhmn5zhmd36qf2lbpma40.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%2Fhmn5zhmd36qf2lbpma40.png" alt="Cost of Making Mechanical Keyboard" width="800" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the cost of &lt;strong&gt;3.2€&lt;/strong&gt; per keyboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://store.sunlu.com/collections/3d-printer-filament?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Sunlu.com&lt;/strong&gt;&lt;/a&gt; has a bit better prices with &lt;strong&gt;11.2€&lt;/strong&gt; per Kg.&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%2F63fm0vkl7a666a70ec5u.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%2F63fm0vkl7a666a70ec5u.png" alt="Cost of Making Mechanical Keyboard" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the price will be &lt;strong&gt;2.86€&lt;/strong&gt; per piece.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jayo3d.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;jayo3d.com&lt;/strong&gt;&lt;/a&gt; has great prices for PLA.&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%2Fig5dt4l9fgfxc2sspz75.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%2Fig5dt4l9fgfxc2sspz75.png" alt="Cost of Making Mechanical Keyboard" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;9.5€&lt;/strong&gt; per Kg. Calculating the comes to &lt;strong&gt;2.4€&lt;/strong&gt; per case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeetech.com/?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Geeetech.com&lt;/strong&gt;&lt;/a&gt; leads with 8.45€ per Kg.&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%2Fge3v0vcm2svx2ectkzxq.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%2Fge3v0vcm2svx2ectkzxq.png" alt="Cost of Making Mechanical Keyboard" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the case would cost 2.15€&lt;/p&gt;

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

&lt;p&gt;Conclusion is on the top.&lt;/p&gt;

&lt;p&gt;That's all. Thank you for reading.&lt;/p&gt;

</description>
      <category>project</category>
    </item>
    <item>
      <title>Where to buy electronic components?</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Fri, 13 Mar 2026 17:56:35 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/where-to-buy-electronic-components-13h1</link>
      <guid>https://dev.to/fallingdowncat/where-to-buy-electronic-components-13h1</guid>
      <description>&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%2Fvnn3t03jbwohscdb6gi9.jpg" 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%2Fvnn3t03jbwohscdb6gi9.jpg" alt="Where to buy electronic components?" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once i started assembling my own project usually i just went with LCSC electronics, or Mouser electronics. Those two options are the ones everyone talks about and i just took their word. But what if i dig a little deeper.&lt;/p&gt;

&lt;p&gt;This post will be purely exploratory thinking, because only places i ordered from in the past are Mouser and LCSC, but the plan is to test some of these newly discovered options. So this post will serve sort of as a reminder for the future projects of mine.&lt;/p&gt;

&lt;p&gt;My current projects use STM32F103C8T6, and STM32F401RET6 microcontrollers, so those two will be used to test the prices of all the markets shown. Keep in mind options are catered more towards European market, because I'm there.&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%2F8ybpkd8nlujkgwwz0kzq.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%2F8ybpkd8nlujkgwwz0kzq.png" alt="Where to buy electronic components?" width="800" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mouser&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Mouser gets mentioned Immediately in a conversation about components. And for a good reason. Mouser is American company that has offices and warehouses all over the world, including the Europe. Mouser offers a free delivery if the purchase is more than $50&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 4.96 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 5.18 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DigiKey&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
One more that gets mentioned in every conversation. Another American owned company that has many offices all around the world, including EU. Compared to Mouser, when ordering with DigiKey free shipping get applied after $100 purchase.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 5.17 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 5.26 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LCSC Electronics&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
First time when i ordered electronics components i used LCSC Electronics. And by far they got the best website amongst all. Another great thing about them is that their database is directly compatible with EasyEDA editor, so each component they got displayed has dedicated footprint and icon, but only in EasyEDA. They are located in China.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 1.46 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 1.89 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TME(&lt;em&gt;Transfer Multisort Elektronik&lt;/em&gt;)&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Never ordered from them, however seems like they are the closest country to my. Located in Poland, only good things on the internet about them.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 3.7 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 6.1 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow Electronics&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
US based company with offices around the world, amongst them one in Germany. Never personally ordered from them but feedback from people on the internet is positive.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 2.22 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 3.35 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Farnell&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Company from UK, with many offices around the world. Again never ordered there but seems like it's well known amongst electronics community.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 4.80 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: 5.34 EUR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schukat Electronic&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Based in Germany, another one close to me and never ordered from them. Didn't hear much about it on the internet, however seems like a big company that sells electronics.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 2.32 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: ---&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bürklin Elektronik&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Another company based in Germany that has really nice website. People seem to recommend them on forums.&lt;/p&gt;

&lt;p&gt;STM32F103C8T6: 2.3205 EUR&lt;br&gt;&lt;br&gt;
STM32F401RET6: ---&lt;/p&gt;

&lt;p&gt;That's all i could find that deliver to Europe. Considering how i only used LCSC Electronics and Mouser before, and they are great, but in the future i have to try one of these Germany or Poland based to see how shipping costs compare.&lt;/p&gt;

&lt;p&gt;That's all there is.&lt;br&gt;&lt;br&gt;
Thanks for reading.&lt;/p&gt;

</description>
      <category>project</category>
    </item>
    <item>
      <title>Mechanical Keyboard Economics</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Thu, 12 Mar 2026 18:07:15 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/mechanical-keyboard-economics-1jc8</link>
      <guid>https://dev.to/fallingdowncat/mechanical-keyboard-economics-1jc8</guid>
      <description>&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%2Flgqnulk7gmggr2wg2yom.jpg" 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%2Flgqnulk7gmggr2wg2yom.jpg" alt="Mechanical Keyboard Economics" width="800" height="1067"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can remember a long time a go while browsing for videos on YouTube, there were a lot of tutorials on how to assemble mechanical keyboard. I said assemble because I'm pretty sure they didn't use PCB to wire everything. Instead, they built a frame that holds key switches and then solder the wires to each key switch.&lt;/p&gt;

&lt;p&gt;It was nice to watch that, but i never tried it myself, because of the prices they threw at me through the video. At the time they paid $1 to $2 per switch. That's greatly overpriced. But not only key switches are overpriced.&lt;/p&gt;

&lt;p&gt;If you want a keyboard PCB, and you want to buy it from some well known seller. The prices are from 30€ and up to 50€, maybe even more. I think the market is madly overpriced, especially for non-electronic people that just want to assemble their own keyboard. Today my keyboard PCB arrived from PCB manufacturer.&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%2Fh94728k7lp6b5fwfzd8c.jpg" 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%2Fh94728k7lp6b5fwfzd8c.jpg" alt="Mechanical Keyboard Economics" width="800" height="1067"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It costs about 3€ per piece, and i requested 5 PCBs, so its 15€. 5 PCBs is a minimal amount, if i request 10, or 25, or 50, or 100, the price goes down. I'm pretty sure if 50 pieces is ordered, the cost would fall below 1.5€. The same goes for the components. If everything is ordered in bulk, the price cant go over 8€, maybe even 7€.&lt;/p&gt;

&lt;p&gt;For the end a little life hack for saving money. Since those PCBs are crazy overpriced, there is a great place where one can get them under 20€. Tindie.com is a small marketplace where people sell DIY electronics that they made or designed. And keyboard PCBs can go for 10€ there.&lt;/p&gt;

&lt;p&gt;And as for key switches, there is AliExpress, and i bought two kinds, one silent and one silent but a bit louder that other. And both for about 0.2€ a piece. That's all i got to say.&lt;/p&gt;

&lt;p&gt;Thanks for reading&lt;/p&gt;

</description>
      <category>project</category>
    </item>
    <item>
      <title>How to run a stepper motor with DRV8825</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Wed, 11 Mar 2026 16:35:07 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/how-to-run-a-stepper-motor-with-drv8825-42hd</link>
      <guid>https://dev.to/fallingdowncat/how-to-run-a-stepper-motor-with-drv8825-42hd</guid>
      <description>&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%2Fa4l0op4kds3tof7l3tv6.jpg" 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%2Fa4l0op4kds3tof7l3tv6.jpg" alt="How to run a stepper motor with DRV8825" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right away i will skip the internals of the DRV8825 chip, and just show the simplest way to set up and run the stepper motor with the driver. However, if someone finds internals of the DRV8825 interesting i found this website that describes it nicely:&lt;/p&gt;

&lt;p&gt;[&lt;/p&gt;

&lt;p&gt;Pololu - DRV8825 Stepper Motor Driver Carrier, High Current&lt;/p&gt;

&lt;p&gt;This breakout board for TI’s DRV8825 microstepping bipolar stepper motor driver features adjustable current limiting, over-current and over-temperature protection, and six microstep resolutions (down to 1/32-step). It operates from 8.2 V to 45 V and can deliver up to approximately 1.5 A per phase without a heat sink or forced air flow (rated for up to 2.2 A per coil with sufficient additional cooling). The driver has a pinout and interface that are nearly identical to those of our A4988 stepper motor driver carriers, so it can be used as a higher-performance drop-in replacement for those boards in many applications. This board ships with 0.1″ male header pins included but not soldered in.&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%2Fxrv1782t2mx62r2qwg6q.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%2Fxrv1782t2mx62r2qwg6q.png" alt="How to run a stepper motor with DRV8825" width="192" height="192"&gt;&lt;/a&gt;DRV8825 Stepper Motor Driver Carrier, High Current&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%2Fwg1rcdr647bpubdrgzad.jpg" 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%2Fwg1rcdr647bpubdrgzad.jpg" alt="How to run a stepper motor with DRV8825" width="800" height="418"&gt;&lt;/a&gt;&lt;br&gt;
](&lt;a href="https://www.pololu.com/product/2133?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;https://www.pololu.com/product/2133?ref=fallingdowncat.com&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;For the setup i will use:&lt;br&gt;&lt;br&gt;
-Arduinu UNO R4 minima,&lt;br&gt;&lt;br&gt;
-Nema 17 stepper motor (1.5 A max current)&lt;br&gt;&lt;br&gt;
-DRV8825 and breakout board,&lt;br&gt;&lt;br&gt;
-Lab voltage supply,&lt;br&gt;&lt;br&gt;
-and a simple two pin button.&lt;/p&gt;

&lt;p&gt;Before hooking up everything it's required to set up a reference voltage on the driver.&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%2Fdo6tswl7k9efeouixh1p.jpg" 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%2Fdo6tswl7k9efeouixh1p.jpg" alt="How to run a stepper motor with DRV8825" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hook up everything except motor (image above). Now the current limit of the driver needs to be adjusted with potentiometer.&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%2Ff0broenhw78cc6ps8fkx.jpg" 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%2Ff0broenhw78cc6ps8fkx.jpg" alt="How to run a stepper motor with DRV8825" width="800" height="793"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to calculate that, the next equation is used:&lt;br&gt;&lt;br&gt;
Vref = Imax * 0.5 (in my case it's 1.5 * 0.5 = 0.75V)&lt;/p&gt;

&lt;p&gt;Imax is max current of the motor, and it can be found in the datasheet.&lt;/p&gt;

&lt;p&gt;Now with multimeter we set it to voltage measuring and measure voltage across that small potentiometer that looks like a screw. By turning the potentiometer the voltage changes, and in my case when it's 0.75 V, it's all set.&lt;/p&gt;

&lt;p&gt;Now the motor can be plugged in:&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%2F81svggecfxaqywtml26d.jpg" 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%2F81svggecfxaqywtml26d.jpg" alt="How to run a stepper motor with DRV8825" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last thing is to write a code. In code i used AccelStepper.h library by Mike McCauley. It has a couple of example codes that can be tried right away, below is slightly modified version of example code that uses button. When button is pressed the motor turns in one direction with constant speed.&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="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;AccelStepper.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="c1"&gt;// Stepper driver pins&lt;/span&gt;
&lt;span class="cp"&gt;#define STEP_PIN 2
#define DIR_PIN 5
&lt;/span&gt;
&lt;span class="c1"&gt;// Stepper object&lt;/span&gt;
&lt;span class="n"&gt;AccelStepper&lt;/span&gt; &lt;span class="nf"&gt;stepper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AccelStepper&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;DRIVER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;STEP_PIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DIR_PIN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;buttonPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buttonPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT_PULLUP&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;stepper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setMaxSpeed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;stepper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setSpeed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// constant speed&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&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;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buttonPin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// button pressed&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;stepper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;runSpeed&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// run at constant speed&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;That's all there is.&lt;/p&gt;

&lt;p&gt;Of course there is much more to be explained internally, but me pretending to know that would be lying :P&lt;/p&gt;

</description>
      <category>project</category>
    </item>
    <item>
      <title>AS5600 Magnetic Encoder</title>
      <dc:creator>FallingDownCat</dc:creator>
      <pubDate>Tue, 10 Mar 2026 18:55:36 +0000</pubDate>
      <link>https://dev.to/fallingdowncat/as5600-magnetic-encoder-3mii</link>
      <guid>https://dev.to/fallingdowncat/as5600-magnetic-encoder-3mii</guid>
      <description>&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%2Fvyox017ljg99jibmdn51.jpg" 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%2Fvyox017ljg99jibmdn51.jpg" alt="AS5600 Magnetic Encoder" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First goal with AS5700 was to track the movement of a stepper motor, but as i dug in tutorial it seems that the IC is not meant for it. It works great for tracking the rotation of the motor shaft, but magnetic encoders are used in those rotating dials that can rotate in both direction indefinitely.&lt;/p&gt;

&lt;p&gt;AS5700 goes for about 3 EUR for 3 x ICs, on AliExpress.&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%2Fmb97t0ixog2dw0sxw0ew.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%2Fmb97t0ixog2dw0sxw0ew.png" alt="AS5600 Magnetic Encoder" width="611" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It comes with a small magnet that you glue to the shaft of the stepper motor. For doing so i recommend using tweezers and superglue, and a lot of patience.&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%2Ft09zj84mqiv847rrylb9.jpg" 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%2Ft09zj84mqiv847rrylb9.jpg" alt="AS5600 Magnetic Encoder" width="800" height="910"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that we need to set that small chip just under the magnet. I did that by printing a stand for AS5700 that i found on &lt;a href="https://www.thingiverse.com/thing:4647150?ref=fallingdowncat.com" rel="noopener noreferrer"&gt;Thingiverse&lt;/a&gt;. Great thing about that particular 3D model is that it requires no screws.&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%2F3hg4s26eyie5chsrr14l.jpg" 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%2F3hg4s26eyie5chsrr14l.jpg" alt="AS5600 Magnetic Encoder" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wiring for Arduino uno R4:&lt;br&gt;&lt;br&gt;
VCC -&amp;gt; 5V/3V&lt;br&gt;&lt;br&gt;
GND -&amp;gt; GND&lt;br&gt;&lt;br&gt;
SCL -&amp;gt; A5&lt;br&gt;&lt;br&gt;
SDA -&amp;gt; A4&lt;/p&gt;

&lt;p&gt;That's for communicating over I2C protocol, and I'm pretty sure it can be done in another way but i never did that. For the coding part there is a great library by Adafruit called Adafruit AS5600 Library... When said library is installed among Examples should be an example for basic reading of the magnetic position.&lt;/p&gt;

&lt;p&gt;And that's it, the setup is working.&lt;/p&gt;

</description>
      <category>project</category>
    </item>
  </channel>
</rss>
