<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>InfectedBytes</title>
		<description>Software development blog for personal projects.</description>
		<link></link>
		<atom:link href="/feed.xml" rel="self" type="application/rss+xml" />
		
			<item>
				<title>Published Entity Composer</title>
				<description>&lt;h2 id=&quot;entity-composer&quot;&gt;Entity Composer&lt;/h2&gt;
&lt;p&gt;Game data management solution for designer and developers.&lt;/p&gt;

&lt;p&gt;No more spreadsheets or direct json file editing, instead manage all your games data in a simple UI and export it to a format of your choice.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://infectedbytes.gitlab.io/entitycomposer/&quot;&gt;Website/Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://infectedbytes.itch.io/entity-composer&quot;&gt;Download&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;compose-your-entities&quot;&gt;Compose your Entities&lt;/h2&gt;
&lt;p&gt;Define your entities by simply adding components to them. Each component can consist of any number of fields, you can even define your own custom data types.&lt;/p&gt;

&lt;p&gt;Create Items, Enemies, Spells, or anything else via a data driven design.&lt;/p&gt;
</description>
				<pubDate>Tue, 07 Sep 2021 19:04:00 +0000</pubDate>
				<link>/2021/09/entity-composer.html</link>
				<guid isPermaLink="true">/2021/09/entity-composer.html</guid>
			</item>
		
			<item>
				<title>Homepage Migration</title>
				<description>&lt;h1 id=&quot;homepage-migration&quot;&gt;Homepage Migration&lt;/h1&gt;
&lt;p&gt;My previous homepage was using the Drupal CMS, which is of course very powerful, but actually much more than I actually need. Furthermore Drupal and it’s modules are a bit error prone and tend to have security issues. Of course these issues are typically fixed very fast, but it still is an inconvenience for me as a Drupal user.&lt;/p&gt;

&lt;p&gt;Therefore I decided to switch to Jekyll. Instead of using a database, it takes the static content, renders markdown or liquid templates, and produces a complete, static website.&lt;br /&gt;
Because of this it simply can’t have a security hole. Additionally it doesn’t require php or mysql and is therefore super fast.&lt;/p&gt;

&lt;h2 id=&quot;missing-blog-posts&quot;&gt;Missing blog posts&lt;/h2&gt;
&lt;p&gt;As you may have noticed, there are plenty of blog posts missing here. This is the case, because I’m too lazy to import them here. Yes, there are automatic importers, but they can’t fully import everything and I would have to manually correct the import errors.&lt;/p&gt;

&lt;p&gt;Therefore I decided to only import the important posts (according to Google Analytics).&lt;/p&gt;

</description>
				<pubDate>Fri, 14 Sep 2018 20:44:00 +0000</pubDate>
				<link>/2018/09/homepage-migration.html</link>
				<guid isPermaLink="true">/2018/09/homepage-migration.html</guid>
			</item>
		
			<item>
				<title>Published Coding Essentials</title>
				<description>&lt;h2 id=&quot;coding-essentials&quot;&gt;Coding Essentials&lt;/h2&gt;
&lt;p&gt;Unity is a great engine that makes use of the powerful &lt;code class=&quot;highlighter-rouge&quot;&gt;Mono Project&lt;/code&gt;, which is an open source implementation of the .NET Framwork. But since Unity doesn’t use the latest version of it, some important things are missing, like a Restart method for the Stopwatch or the different Tuple classes. Therefore this package provides you with these missing pieces.&lt;br /&gt;
Furthermore this package provides you with several fundamental data structures and algorithms, that are important for modern game development with Unity. For example this package contains a serializable dictionary and priority queues. Some other features are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;FastList&lt;/code&gt;: fast and serializable list data structure + custom inspector&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;UnityDictionary&lt;/code&gt;: fast and serializable dictionary + custom inspector&lt;/li&gt;
  &lt;li&gt;Mutable and immutable tuple classes and structs&lt;/li&gt;
  &lt;li&gt;Several programming design patterns, like: &lt;code class=&quot;highlighter-rouge&quot;&gt;Singleton&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;Observer&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Different tree data structures:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Binary tree&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Quadtree&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Octree&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;…&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;HSV and HSL colors&lt;/li&gt;
  &lt;li&gt;Integer vectors&lt;/li&gt;
  &lt;li&gt;Large set of extension methods for faster development&lt;/li&gt;
  &lt;li&gt;… and much more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All in all this package contains over 100 fully documented classes with full source code.&lt;/p&gt;

&lt;h2 id=&quot;documentation&quot;&gt;Documentation&lt;/h2&gt;
&lt;p&gt;The source code of this package is fully documented, furthermore the complete API documentation can be found online: &lt;a href=&quot;https://unity_assetstore.gitlab.io/UnityCodingEssentials/&quot;&gt;Coding Essentials Docs&lt;/a&gt;&lt;br /&gt;
The documentation also provides you with several articles for a quick start into game development.&lt;br /&gt;
AssetStore&lt;br /&gt;
Get it now from the Unity3d AssetStore: &lt;a href=&quot;http://u3d.as/EfW&quot;&gt;Coding Essentials&lt;/a&gt;&lt;br /&gt;
Leave a comment if you have any questions.&lt;/p&gt;

</description>
				<pubDate>Thu, 26 Jan 2017 15:29:15 +0000</pubDate>
				<link>/2017/01/published-coding-essentials.html</link>
				<guid isPermaLink="true">/2017/01/published-coding-essentials.html</guid>
			</item>
		
			<item>
				<title>Project: InfinityPi #5 (Simple Test)</title>
				<description>&lt;h2 id=&quot;portable-power&quot;&gt;Portable Power&lt;/h2&gt;
&lt;p&gt;The parts for portable power are nothing special:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/powerparts.jpg&quot; alt=&quot;Battery Pack + Charger&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;6600mAh LiPo&lt;/li&gt;
  &lt;li&gt;Adafruit PowerBoost 1000 Charger&lt;/li&gt;
  &lt;li&gt;Sparkfun LiPo Fuel Gauge&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LiPo has a voltage of 3.7V, but the Pi needs 5V. Therefore I use the Adafruit powerbooster, which will converts the output to 5V. Furthermore it has a load-sharing circuit built-in, which means that I can load the battery while it is in use. The gauge is not mandatory, but it is very useful, because with its help, the Pi can measure the voltage and display a warning if the power goes down.&lt;/p&gt;

&lt;h2 id=&quot;test-run&quot;&gt;Test Run&lt;/h2&gt;
&lt;p&gt;For a quick test, I just connected the LiPo with the Powerbooster, which in turn is connected to the pi. Furthermore I connected the demo gamepad from the last blog post to the pi. After a few seconds RetroPie is running and I can play some games with this little gamepad.&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/basictest.jpg&quot; alt=&quot;Test Setup&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;to-be-continued&quot;&gt;To be continued&lt;/h2&gt;
&lt;p&gt;This was just a little test of the most important components. Next time I will continue with the actual gamepad logic and a little PCB for the buttons.&lt;/p&gt;

</description>
				<pubDate>Sat, 30 Jul 2016 22:34:00 +0000</pubDate>
				<link>/2016/07/infinity-pi-5.html</link>
				<guid isPermaLink="true">/2016/07/infinity-pi-5.html</guid>
			</item>
		
			<item>
				<title>Project: InfinityPi #4 (Joystick)</title>
				<description>&lt;h2 id=&quot;wiring&quot;&gt;Wiring&lt;/h2&gt;
&lt;p&gt;This time it is important to use an Arduino with an ATmega32u4 chip, like the micro. For testing purposes I just use two joysticks and 8 buttons. The buttons are connected via a shift register, while the joysticks are connected directly to an analog pin. For more info on the shift register, take a look at &lt;a href=&quot;/2016/07/infinity-pi-3.html&quot;&gt;InfinityPi #3&lt;/a&gt; or &lt;a href=&quot;/2016/07/arduino-shiftin.html&quot;&gt;Arduino ShiftIn&lt;/a&gt;.&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/joystick_test.png&quot; alt=&quot;Joystick wiring&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The pload pin of the shift register is connected to pin 12 (gray wire). The clockEnablePin is connected to pin 10 (orange wire). The dataPin is connected to pin 9 (yellow wire) and the clockPin is connected to pin 11 (purple wire).&lt;br /&gt;
The x- and y-pins of the joysticks are connected to the A0 to A3 pins.&lt;/p&gt;

&lt;h2 id=&quot;joystick-library&quot;&gt;Joystick Library&lt;/h2&gt;
&lt;p&gt;I use the joystick library (version 2) from MHeironimus. It is a nice little library that allows your Arduino to be recognized as a gamepad/joystick. The library can be found here: &lt;a href=&quot;https://github.com/MHeironimus/ArduinoJoystickLibrary/tree/version-2.0&quot;&gt;ArduinoJoystickLibrary&lt;/a&gt;. At the moment of writing the library is only in a beta state, but it works well. If the library is installed and included, you have to instantiate an instance of the Joystick_ class (the underscore is &lt;em&gt;not&lt;/em&gt; a typo). After calling the begin function of this instance in your setup function, everything is ready to go. You can set your axis values by calling the &lt;code class=&quot;highlighter-rouge&quot;&gt;setXAxis&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;setYAxis&lt;/code&gt;, … methods with a value between 0 and 1023 as a parameter. In order to press or release a button you could call setButton(idx, value) with a value of 0 or 1.&lt;/p&gt;

&lt;p&gt;The basic code for my test gamepad is super easy:&lt;/p&gt;
&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;ShiftIn.h&amp;gt;
#include &amp;lt;Joystick.h&amp;gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ShiftIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// use one shift register&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Joystick_&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// set pins of the shift register&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// init joystick&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// analogRead will read the axis value (0-1023)&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// set*Axis will set the axis value and automatically sends the change&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setXAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analogRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setYAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analogRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setRxAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analogRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setRyAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analogRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
  
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getDataWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;joystick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setButton&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// just press or release the button&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After uploading this sktech to your Arduino, it will be recognized as a gamepad. Just go to your system control panel and take a look at the connected devices (on Windows 10, you could just open the menu and type “devices”). And there you will find this sweet icon:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/micropad.png&quot; alt=&quot;Gamepad Icon&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now go to the controller settings and play a bit around:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/joystick_settings.png&quot; alt=&quot;Gamepad Settings&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;to-be-continued&quot;&gt;To be continued&lt;/h2&gt;
&lt;p&gt;So basically we now have all gamepad parts together. The next big step awaits us: We have to build a small PCB for our buttons and we must of course implement the actual gamepad logic.&lt;br /&gt;
Furthermore it is time to think a bit about the triggers…&lt;/p&gt;

</description>
				<pubDate>Sat, 30 Jul 2016 22:34:00 +0000</pubDate>
				<link>/2016/07/infinity-pi-4.html</link>
				<guid isPermaLink="true">/2016/07/infinity-pi-4.html</guid>
			</item>
		
			<item>
				<title>Project: InfinityPi #3 (analog IO)</title>
				<description>&lt;h2 id=&quot;pro-micro&quot;&gt;Pro Micro&lt;/h2&gt;
&lt;p&gt;The Arduino Micro ist super useful and small, but it’s maybe not the best choice if you want to embedded it in a project, because 20€ is not that cheap. I searched a bit around and found a nice little alternative. The “Pro Micro Module Board” is similar to an “Pro Mini”, but with the nice ATmega32u4 on board, therefore you can use it as an input device for your computer. It is compatible to an Arduino Leonardo/Micro, but with less IO pins. It only has 12 digital pins and four analog pins, but in most cases this will be enough and if not, you could extend it with some ICs. I bought a 3 pieces bundle from Amazon for just 15€, so one piece costs only a quarter of a micro, much better :)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.amazon.de/gp/product/B01HAZ2M8A/ref=as_li_ss_il?ie=UTF8&amp;amp;psc=1&amp;amp;linkCode=li3&amp;amp;tag=infect-21&amp;amp;linkId=b3818c7f87a5a0695d85ee442db7ffd9&quot;&gt;&lt;img src=&quot;http://ws-eu.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B01HAZ2M8A&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=DE&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=infect-21&quot; alt=&quot;Arduino Micro&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is also a way smaller than the micro, which is very nice for an embedded project. Here is a little comparison to the micro:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/micro_cmp.jpg&quot; alt=&quot;Arduino size comparison&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You program it just like an Arduino Leonardo/Micro, in fact you will tell your Arduino IDE that it is a Leonardo board (Menu &amp;gt; Tools &amp;gt; Board &amp;gt; Arduino Leonardo).&lt;/p&gt;

&lt;h2 id=&quot;analog-input-multiplexer&quot;&gt;Analog Input Multiplexer&lt;/h2&gt;
&lt;p&gt;Let’s go back to the gamepad. The ultimate goal is to implement a full featured gamepad. That means that we need six analog inputs, two for each thumbstick and one for each trigger. So if we would use a normal micro, then everything is fine, because it has enough pins. In the case of the cheaper version, we only have four pins. So we either drop two analog inputs (obviously the triggers) or we use an input multiplexer. Let’s take a look at the multiplexer:&lt;/p&gt;

&lt;h3 id=&quot;analog-multiplexerdemultiplexer-4051&quot;&gt;Analog Multiplexer/Demultiplexer 4051&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/infinitypi/4051.png&quot; alt=&quot;Arduino Multiplexer&quot; style=&quot;float: right;margin-right: 7px;margin-top: 7px;&quot; /&gt;&lt;br /&gt;
A (de)multiplexer enables you to expand your in- or output pins of your Arduino. The 4051 is able to do both, you could either use it as a multiplexer or as a demultiplexer. We will only look at the input multiplexer.&lt;br /&gt;
You have to connect three digital pins to this chip and one analog pin. The pins s0, s1 and s2 are used to select one of the eight pins, you can then read the corresponding value from your analog input. Each of the three pins is basically a single bit of a 3 bit long number. So in order to select the third analog input, you set s0 and s1 to HIGH and s2 to LOW.&lt;br /&gt;
For testing purposes I connected two “normal” joysticks and two PSP joysticks to this chip:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/analog.png&quot; alt=&quot;Arduino analog IO&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You may have noticed that there are three pins connected to GND. The outer most one ist just the normal GND pin. The next one is the Vee pin, the negative supply pin. You could connect a negative voltage to this pin, which enables this chip to accept analog values in the range of Vee to Vcc. The Arduino cannot handle a negative supply, therefore we just connect it to GND in order to limit the range to 0-Vcc. The next pin is the “enable input” pin. If this pin is grounded, the chip will be used as a multiplexer, otherwise it will be used as a demultiplexer.&lt;/p&gt;
&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Mux&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Mux&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;pinMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;pinMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;pinMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;digitalWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bitRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;digitalWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bitRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;digitalWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bitRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;analogRead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Mux&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mux&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// show all 8 sensor readings&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mux&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course there is no need to put it in an extra class, but I like it more this way, because it looks better and now you could also put it into a separate library.&lt;br /&gt;
The code itself is straight forward, before I read the analog input, I just select the correct pin via the s0 to s2 pins.&lt;/p&gt;

&lt;p&gt;Looking at the Serial monitor, we can now see the ranges of the two different joystick types:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Joystick Axis&lt;/th&gt;
      &lt;th&gt;min&lt;/th&gt;
      &lt;th&gt;center&lt;/th&gt;
      &lt;th&gt;max&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Joystick X&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;512&lt;/td&gt;
      &lt;td&gt;1023&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Joystick Y&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;512&lt;/td&gt;
      &lt;td&gt;1023&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PSP X&lt;/td&gt;
      &lt;td&gt;146&lt;/td&gt;
      &lt;td&gt;482&lt;/td&gt;
      &lt;td&gt;859&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PSP Y&lt;/td&gt;
      &lt;td&gt;142&lt;/td&gt;
      &lt;td&gt;487&lt;/td&gt;
      &lt;td&gt;840&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;As you can see, the PSP joystick is a bit crappy. Therefore I hope to have enough space for the bigger one on my InfinityPi.&lt;/p&gt;

&lt;h2 id=&quot;to-be-continued&quot;&gt;To be continued&lt;/h2&gt;
&lt;p&gt;Next we will check out the actual Joystick behavior and we will make a first test gamepad that can be used by any computer.&lt;/p&gt;

</description>
				<pubDate>Thu, 28 Jul 2016 19:23:00 +0000</pubDate>
				<link>/2016/07/infinity-pi-3.html</link>
				<guid isPermaLink="true">/2016/07/infinity-pi-3.html</guid>
			</item>
		
			<item>
				<title>Project: InfinityPi #2 (digital IO)</title>
				<description>&lt;h2 id=&quot;arduino-leonardomicro&quot;&gt;Arduino Leonardo/Micro&lt;/h2&gt;
&lt;p&gt;First of all the Arduino Micro is basically just an Arduino Leonardo in a much smaller form factor. They both have 20 digital IO pins of which 7 can be used as PWM outputs and 12 as analog inputs. But what makes them “better” than other Arduino boards? Why do I want to use an Arduino Micro?&lt;br /&gt;
One nice thing is the small form factor. But the most important part is that the Micro is based on the ATmega32u4 microcontroller, which has built-in USB communication. This allows the Micro to appear as a mouse, keyboard or joystick to a connected computer! Therefore I don’t have to write any complex device driver. It will just work, without any hassle :)&lt;/p&gt;

&lt;h2 id=&quot;the-parts&quot;&gt;The parts&lt;/h2&gt;
&lt;p&gt;Ideally the integrated gamepad should have all buttons and axes of a normal, modern gamepad, like the famous XBox360 controller.&lt;br /&gt;
Therefore it should have:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;2 thumbsticks, each one consisting of an x and y axis&lt;/li&gt;
  &lt;li&gt;2 analog triggers&lt;/li&gt;
  &lt;li&gt;1 hat switch (or POV or D-Pad)&lt;/li&gt;
  &lt;li&gt;10 buttons (ABXY, Start, Back, LB, RB, LS, RS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okey, the 10 buttons and the hat switch are easy, I could just use ordinary push buttons for those, nothing special.&lt;br /&gt;
The triggers are something special. I haven’t found a real solution yet. Of course I could just use normal buttons, but I really, really want to have them analog (like real triggers), but that’s not an easy task. I will try to solve this problem and I will keep you up to date.&lt;br /&gt;
The thumbsticks are easy again, but there I have different options:&lt;/p&gt;

&lt;h2 id=&quot;joystick&quot;&gt;Joystick&lt;/h2&gt;
&lt;p&gt;Basically a real thumbstick, with each axis going from 0 to 1023. Furthermore it also has a push button, just like the XBox thumbsticks. So it has a nice range, good automatic centering and a pushbutton! Really nice, but there is a little downside. It is kind of big for a portable gaming station.&lt;br /&gt;
&lt;a href=&quot;https://www.amazon.de/SunFounder-Joystick-Module-Arduino-Raspberry/dp/B013G8KSB8/ref=as_li_ss_il?ie=UTF8&amp;amp;qid=1469631059&amp;amp;sr=8-1&amp;amp;keywords=arduino+joystick&amp;amp;linkCode=li2&amp;amp;tag=infect-21&amp;amp;linkId=39b8901760d2e29e415a1b71b45fcaec&quot;&gt;&lt;img src=&quot;http://ws-eu.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B013G8KSB8&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=DE&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=infect-21&quot; alt=&quot;Joystick&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;psp-joystick&quot;&gt;PSP Joystick&lt;/h2&gt;
&lt;p&gt;This is a replacement part for a PSP. Of course the size is much better for a portable gaming station, but it doesn’t have a pushbutton :(&lt;br /&gt;
Furthermore its range is a bit small, it goes from about 160 to 820. The automatic centering is really bad, the centered state goes from 490 to 540, so even if you don’t touch it, it might be a bit beneath the real center.&lt;br /&gt;
&lt;a href=&quot;https://www.amazon.de/Adafruit-Analoger-2-Achsen-Daumenjoystick-PSP/dp/B00Q6Y74GM/ref=as_li_ss_il?ie=UTF8&amp;amp;qid=1469631059&amp;amp;sr=8-2&amp;amp;keywords=arduino+joystick&amp;amp;linkCode=li2&amp;amp;tag=infect-21&amp;amp;linkId=b474db24e0bbed72a9bd882d31669d4d&quot;&gt;&lt;img src=&quot;http://ws-eu.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00Q6Y74GM&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=DE&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=infect-21&quot; alt=&quot;PSP Joystick&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;which-one&quot;&gt;Which one?&lt;/h2&gt;
&lt;p&gt;Actually I would love to use the real thumbstick, because its range is better, the centering is better, …. everything is better, except that it is a way bigger than the tiny PSP joystick. At the moment I am a bit undecided, but I tend to use the real joystick. Maybe I will later decide to use the PSP version, but we will see this later.&lt;br /&gt;
And here a little comparison of the dimensions:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/joystick_cmp.jpg&quot; alt=&quot;Joystick comparison&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Left one: 38mm * 38mm * 34mm&lt;/li&gt;
  &lt;li&gt;Right one: 19mm * 19mm * 9mm&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;not-enough-pins&quot;&gt;Not enough pins!&lt;/h2&gt;
&lt;p&gt;You may have noticed that this setup would consume all Arduino pins (14 buttons + 6 analog axis). So there’s no way to add any more buttons or any outputs. That’s really bad, because I’d like to add a switch button for different modes, like a normal gamepad mode and a keyboard mode, in which I could control the mouse via a thumbstick.&lt;br /&gt;
Luckily the solution is really simple (and cheap). I just use shift registers. A single shift register has 8 digital inputs, while itself only uses 4 of your Arduino pins. Furthermore you can daisy-chain several of them by still only consuming the same 4 pins as before. Therefore I can use 16 buttons with only 4 pins, awesome :)&lt;br /&gt;
There are several shift registers out there, I used the 74HC165 and I also wrote a little library for it:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/2016/07/arduino-shiftin&quot;&gt;Blog post&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/InfectedBytes/ArduinoShiftIn&quot;&gt;Github project&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;test-wiring&quot;&gt;Test wiring&lt;/h2&gt;
&lt;p&gt;For testing the shift registers I build a little test setup with my Arduino Uno and used my library.&lt;br /&gt;
&lt;img src=&quot;/assets/images/arduino/layout2.png&quot; alt=&quot;Joystick wiring layout&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The example code is super simple:&lt;/p&gt;
&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;ShiftIn.h&amp;gt;
&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// Init ShiftIn instance with two chips.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// The number in brackets defines the number of daisy-chained 74HC165 chips&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// So if you are using only one chip, you would write: ShiftIn&amp;lt;1&amp;gt; shift;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ShiftIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// declare pins: pLoadPin, clockEnablePin, dataPin, clockPin&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;displayValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getDataWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// get state of button i&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// read in all values. returns true if any button has changed&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;displayValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Whenever I press or release a button, the state of every buttons is send via &lt;code class=&quot;highlighter-rouge&quot;&gt;Serial.print&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And here the real world example with small buttons:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/protowiring.jpg&quot; alt=&quot;Joystick wiring&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;to-be-continued&quot;&gt;To be continued&lt;/h2&gt;
&lt;p&gt;In the next post I will write more about the analog axes and I will show you another microcontroller that is also based on the Atmega32u4, but that is even smaller than the Arduino micro. See you next time :)&lt;/p&gt;
</description>
				<pubDate>Tue, 26 Jul 2016 21:39:00 +0000</pubDate>
				<link>/2016/07/infinity-pi-2.html</link>
				<guid isPermaLink="true">/2016/07/infinity-pi-2.html</guid>
			</item>
		
			<item>
				<title>Project: InfinityPi (Portable RetroPi) #1</title>
				<description>&lt;h2 id=&quot;the-vision&quot;&gt;The Vision&lt;/h2&gt;
&lt;p&gt;As most of you already know, the Raspberry Pi is a super tiny single-board computer. In the current version (Raspberry Pi 3 Model B) it has a 1.2 GHz quad-core ARM CPU with 1 GB RAM. Of course this is not much compared to a normal PC, but it is just enough for a nice little emulation station. So I decided to build a portable one.&lt;br /&gt;
My plan so far is to add a nice little LCD on top of the pi and to add a full set of gamepad inputs. Just like most modern gamepads, it should support two thumbsticks, all the buttons and ideally also two triggers. The Pi itself can’t handle analog inputs, but my plan is to use an Arduino with an ATmega32u4 chip. It does not only support analog inputs, but furthermore it can be recognized as an HID device, therefore I could use it as real a gamepad, without any GPIO hacks!&lt;/p&gt;

&lt;p&gt;Of course I will also need some portable power…a lot of power, because gaming is very power hungry. I think I will use a few lithium polymer batteries, hopefully they will power my pi for several hours. In order to charge the battery while it is in use, I have to add some load sharing logic, but for now I will focus on the input.&lt;/p&gt;

&lt;p&gt;Last but not least I have to model and 3D print a nice case. That’s a bit tricky, because I don’t actually know how robust the material will be. But this is also a step far, far away in the future, because I can only start this step when I have finished all the other tasks.&lt;/p&gt;

&lt;h2 id=&quot;which-lcd&quot;&gt;Which LCD?&lt;/h2&gt;
&lt;p&gt;I first wanted to use a 3.5 inch TFT from Adafruit, with a resolution of 480&lt;em&gt;320 pixels, but then I encountered a problem. First of all, yes the resolution is really that small, but that’s not the problem. The problem with this display is, that it is only connected to the GPIO pins of the Raspberry Pi and it therefore sends each pxel, one after another to the screen. Because of this, it totally bypasses the GPU! And that’s especially bad for gaming, because it is one of the most important components for games.&lt;br /&gt;
Yes, there is a way to overcome this issue. You could pretend to render to your HDMI screen, but instead of really sending your image to the HDMI screen, you just copy the framebuffer and send it over GPIO to your LCD.This way you get hardware acceleration, but copying the framebuffer costs additional time and sending the data over GPIO is also really slow. Therefore Adafruit recommends the smaller version of the screen, with only 320&lt;/em&gt;240 pixels. But that’s a way too small!&lt;br /&gt;
So what now? I decided to use an even bigger screen, with a resolution of 800*480! The nice thing about this screen is, that it is connected via HDMI and therefore I don’t have any of the problems above! The downside is that this screen is much bigger (5 inch), so the complete system will be a bit bigger… But hey, why not?&lt;/p&gt;

&lt;p&gt;I found a cheap one on &lt;a href=&quot;http://amzn.to/2aomjeY&quot;&gt;Amazon&lt;/a&gt;, which is even cheaper than the 3.5 inch screen :)&lt;br /&gt;
And here it is:&lt;br /&gt;
&lt;img src=&quot;/assets/images/infinitypi/tft.jpg&quot; alt=&quot;TFT screen&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;sd-card&quot;&gt;SD Card&lt;/h2&gt;
&lt;p&gt;Of course you also need a micro SD card. Because we want to add many, many games, the sd card should be really big, at least 16 GB, better more. I only had 8 GB cards of normal size, but the Raspberry Pi 3 needs micro SD cards, so I had to buy a new one. I was really amazed to see how cheap SD cards are. A few years ago I bought my last SD card with 8 GB storage for about 30€ and now a 64 GB one costs about 20€, nice :)&lt;br /&gt;
If you buy a card with more than 32 GB, it is typically formatted with exFat and not with FAT32. Unfortunately Windows don’t give you the option to format it with FAT32 in the format dialog. Instead you have to use a third party tool or you have to format the sd card via the console. I chose the later option, but the third party tool might be easier. After that you can copy NOOBS or berryboot on the sd card. Of course you could also skip this whole step and flash your OS image directly on the card. That’s up to you.&lt;/p&gt;

&lt;h2 id=&quot;to-be-continued&quot;&gt;To be continued&lt;/h2&gt;
&lt;p&gt;That’s all for now, I will continue the next days with a few words on the input system and the wiring + programming.&lt;br /&gt;
Thanks for reading :)&lt;/p&gt;

</description>
				<pubDate>Tue, 26 Jul 2016 20:15:00 +0000</pubDate>
				<link>/2016/07/infinity-pi-1.html</link>
				<guid isPermaLink="true">/2016/07/infinity-pi-1.html</guid>
			</item>
		
			<item>
				<title>Arduino ShiftIn</title>
				<description>&lt;h2 id=&quot;shift-register-74hc165&quot;&gt;Shift Register 74HC165&lt;/h2&gt;
&lt;p&gt;The 74HC165 is an 8-bit serial-in shift register. It uses only 4 Arduino pins, while itself can read in from 8 digital pins. If the parallel load pin (PL) is LOW, the data is read from the A to H pins in parallel. When PL is HIGH, the Q pin is set to the value of the first bit. Each time you change the value from your clock pin from LOW to HIGH, the next bit is send to the Q pin. Therefore you can read in all 8 bits sequentially. Furthermore you can daisy-chain several shift registers, while still using only 4 Arduino pins!&lt;br /&gt;
The data sheet can be found here: &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/General/sn74hc165.pdf&quot;&gt;SN74HC165&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;shiftin-library&quot;&gt;ShiftIn Library&lt;/h2&gt;
&lt;p&gt;In order to simplify the usage of shift registers, I wrote a small library that handles the communication between the Arduino and the shift register. It is hosted on &lt;a href=&quot;https://github.com/InfectedBytes/ArduinoShiftIn&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Usage:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;ShiftIn.h&amp;gt;
&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// Init ShiftIn instance with one chip.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// The number in brackets defines the number of daisy-chained 74HC165 chips&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// So if you are using two chips, you would write: ShiftIn&amp;lt;2&amp;gt; shift;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ShiftIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// declare pins: pLoadPin, clockEnablePin, dataPin, clockPin&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;displayValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getDataWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// get state of button i&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// read in all values. returns true if any button has changed&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;displayValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Easy, isn’t it?&lt;/p&gt;

&lt;p&gt;Of course you also need to wire up your board with some buttons:&lt;br /&gt;
&lt;img src=&quot;/assets/images/arduino/layout1.png&quot; alt=&quot;Arduino layout&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now you can press those nice buttons and you will see their states via your serial monitor.&lt;/p&gt;

&lt;h2 id=&quot;more-shift-registers&quot;&gt;More shift registers&lt;/h2&gt;
&lt;p&gt;If you want to daisy-chain some shift registers, you only have to change a single number in your code. You have to change&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;ShiftIn&amp;lt;1&amp;gt; shift;&lt;/code&gt;&lt;br /&gt;
to&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;ShiftIn&amp;lt;2&amp;gt; shift;&lt;/code&gt;&lt;br /&gt;
The second shift register is connected the same way as the first one. the only difference is the Q pin, instead of connecting it to your data pin, you connect it to the SER pin of your first register. If you plan to add more registers, you will connect the third Q pin to the SER pin of the second register, the fourth Q to the third SER, and so…&lt;br /&gt;
The breadboard layout for two registers will now look like this:&lt;br /&gt;
&lt;img src=&quot;/assets/images/arduino/layout2.png&quot; alt=&quot;Arduino layout&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;thanks-for-reading&quot;&gt;Thanks for reading!&lt;/h2&gt;
&lt;p&gt;I hope this little blog entry was useful to you! Have fun with my library :)&lt;/p&gt;

</description>
				<pubDate>Sun, 24 Jul 2016 22:56:15 +0000</pubDate>
				<link>/2016/07/arduino-shiftin.html</link>
				<guid isPermaLink="true">/2016/07/arduino-shiftin.html</guid>
			</item>
		
			<item>
				<title>Published Unified Input Manager</title>
				<description>&lt;h2 id=&quot;unified-input-manager-carboninput&quot;&gt;Unified Input Manager (CarbonInput)&lt;/h2&gt;
&lt;p&gt;CarbonInput is a simple extension for better gamepad management in Unity. Unity itself already provides a simple input facility for gamepads. It is based on defining the buttons and axes beforehand and uses them at runtime by their name.&lt;/p&gt;
&lt;div class=&quot;language-cs highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Horizontal&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fire&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetButton&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Fire1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The input system works, but there are at least two problems with it:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;String handling is error prone. It might happen that one accidentally writes &lt;code class=&quot;highlighter-rouge&quot;&gt;&quot;Fire 1&quot;&lt;/code&gt; instead of &lt;code class=&quot;highlighter-rouge&quot;&gt;&quot;Fire1&quot;&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Gamepads are not standardized. The right thumbstick of a PS3 controller uses axis 3 and 5, while a XBox360 Controller uses axis 3 and 4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CarbonInput defines a new Input System, which will try to recognize the used controller in order to use the correct mapping. You don’t have to define any axis, CarbonInput is doing that for you and you can access the correct buttons directly:&lt;/p&gt;
&lt;div class=&quot;language-cs highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// X axis of right thumbstick, automatically mapped to the correct Unity axis&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GamePad&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CAxis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// A-Button on XBox360 controller, Cross on PS3 controller&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jump&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GamePad&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetButton&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CButton&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;touchinput&quot;&gt;TouchInput&lt;/h2&gt;
&lt;p&gt;CarbonInput comes with an own touch input system. On systems like mobile devices, you often don’t have a gamepad connected, therefor you have to use touch controls. You can use thumbsticks as well as normal buttons. Both are available in different styles, like a dark and a light style. Instead of using a generic button without a label, you could also use the predefined A, B, X and Y buttons. Of course you could also use your own images.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/assetstore/touchinput.png&quot; alt=&quot;Touch Input example&quot; class=&quot;center-image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;CarbonInput will handle any TouchInput the same way as any normal gamepad, so you don’t have to change your code. Just drop a Thumbstick or Button prefab into your scene and you’re done.&lt;/p&gt;

&lt;h2 id=&quot;assetstore&quot;&gt;AssetStore&lt;/h2&gt;
&lt;p&gt;Get it now from the Unity3d AssetStore: &lt;a href=&quot;https://www.assetstore.unity3d.com/#!/content/56980&quot;&gt;Unified Input Manager&lt;/a&gt;&lt;br /&gt;
Leave a comment if you have any questions.&lt;/p&gt;

</description>
				<pubDate>Sat, 19 Mar 2016 15:47:15 +0000</pubDate>
				<link>/2016/03/published-unified-input-manager.html</link>
				<guid isPermaLink="true">/2016/03/published-unified-input-manager.html</guid>
			</item>
		
	</channel>
</rss>
