<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Electronics on Voltaicforge</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/categories/electronics/</link>
        <description>Recent content in Electronics on Voltaicforge</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-au</language><atom:link href="https://6e2dbc8c.voltaicforge.pages.dev/categories/electronics/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Multiroom audio with the Raspberry PI</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/</link>
        <pubDate>Sun, 24 Jul 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/raspi_squeezebox_player_and_app.jpg" alt="Featured image of post Multiroom audio with the Raspberry PI" /&gt;&lt;h2 id=&#34;multiroom-audio-with-the-raspi&#34;&gt;Multiroom Audio with the Raspi&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;ve wanted some sort of audio system for years, a set of speakers in multiple rooms you could setup to be controlled via an app that would be able to play my music collection, and radio. In the past I&amp;rsquo;ve experimented with just having iTunes on a laptop with speakers solely for it, putting speakers on my server and some other options. None have ever hit the &amp;rsquo;neat and tidy&amp;rsquo; aspect.&lt;/p&gt;
&lt;p&gt;Recently I started playing around with the RasPI squeezebox solution &lt;a class=&#34;link&#34; href=&#34;https://sites.google.com/site/picoreplayer/home&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;piCorePlayer&lt;/a&gt; which was a big step in the right direction I was looking for. Surely I could find a cheap set of speakers that would look neat, but have enough space to squeeze (pun intended) a RasPi inside of?&lt;/p&gt;
&lt;p&gt;Off to AliExpress I went and found a cheap(ish) little Bluetooth speaker set. It actually had a decent set of features, pity I would not be using most of them.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/raspi_squeezebox_player_and_app.jpg&#34;
  width=&#34;2048&#34;
  height=&#34;1356&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/raspi_squeezebox_player_and_app_hube4a66662bcddb4d91469558e7b814b2_580690_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/raspi_squeezebox_player_and_app_hube4a66662bcddb4d91469558e7b814b2_580690_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Raspi Squeezebox player&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Above is the finished player (which looks the same as how it comes out of the box). I managed to fit a RasPI 1 inside of it, wired up to the power and aux input jack. The PI connects wirelessly to my wireless network by a Wifi dongle and runs off the Logitec Media Server software. So via an app or internal website I can play music or radio and media server will kick off the RasPI to play, pause, volume, etc.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s truly a poor man&amp;rsquo;s &lt;a class=&#34;link&#34; href=&#34;http://www.sonos.com&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Sonos&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;hacking-the-speaker&#34;&gt;Hacking the speaker&lt;/h2&gt;
&lt;p&gt;The speaker is a cheap Bluetooth-capable speaker off AliExpress. It&amp;rsquo;s got more functionality than I wanted but was the only one I liked the look of that could potentially fit a RasPI. I got it Friday night and quickly tore it down.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/cheap_speaker_teardown.jpg&#34;
  width=&#34;1400&#34;
  height=&#34;927&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/cheap_speaker_teardown_hud3687a987ae7dd1134ec32b42f1be207_602483_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/cheap_speaker_teardown_hud3687a987ae7dd1134ec32b42f1be207_602483_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Teardown of a cheap chinese bluetooth speaker&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;I found that it indeed did have enough room to hide a RasPI. But only just, and only after the RasPI has undergone some radical weight reduction. I setup a wifi dongle I had lying around to run on the RasPi and verified it worked before proceeding - I already had Logitec Media Player on a virtual machine running on my server.&lt;/p&gt;
&lt;p&gt;I then played around and inspected the circuitry to find where I could hijack power from the speaker power. It had a power input which was just a standard micro USB-B connector, so it would be running +5V which I could just tap the RasPI into. I cut one end of the USB to Micro USB-B connector that came with it and soldered it to GND and the closest point I could tap +5V. I suspect it was a regulator to drop to +3V or so - the lithium battery included only had 3.7V in it so one would suspect the logic to be +3V. I tried pulling direct from the battery charge points but it only gave out 4.7V, which the RasPI flat out refused to boot on.&lt;/p&gt;
&lt;p&gt;I did accidently blow a resistor to GND during probing for voltage (which a bodge wire quickly fixed, shorting the plugs housing to another GND point on the board).&lt;/p&gt;
&lt;p&gt;Then it was on to the drastic reduction - the RasPi would have to havethe RCA plug, line-out, Ethernet and the USB plugs stripped. I either cut or desoldered these as what was easiest (cut off all but the Ethernet and USB, which required adding fresh solder and then sucking it out). The solder on the RasPI melts a LOT hotter than usual, so adding fresh solder was the trick.&lt;/p&gt;
&lt;p&gt;After the rapid weight loss, I had to find a way to get the USB wifi adaptor back on it. I threw any concept of the USB spec out the window and directly connected the USB pins to the WIFI dongle with a ribbon cable.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modifying_wifi_dongle_direct_wire.jpg&#34;
  width=&#34;2048&#34;
  height=&#34;1356&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modifying_wifi_dongle_direct_wire_hu436fc7f5860488c84225a8e1d69dd5ea_474623_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modifying_wifi_dongle_direct_wire_hu436fc7f5860488c84225a8e1d69dd5ea_474623_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Hacking Usb Wifi direct to RasPI with ribbon cable&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;After everything, it looked a little worse for wear but it worked fine. Then I started probing around to figure out how to connect the Pi&amp;rsquo;s line out direct to the speaker system.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_raspi_with_wifi_dongle.jpg&#34;
  width=&#34;2048&#34;
  height=&#34;1356&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_raspi_with_wifi_dongle_hu4aab6950eddcf6ad17623702554431fd_536698_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_raspi_with_wifi_dongle_hu4aab6950eddcf6ad17623702554431fd_536698_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Wifi Dongle hacked onto RasPi&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;I bodged wires from the aux input jack of the speaker system to the pi - guessing the left and right channel would be the pins connected to the capacitors I could see on the board. The centre pin turned out, as I suspected, to be ground.&lt;/p&gt;
&lt;p&gt;I tested it as it was and it worked. The speakers had some bad line noise (as you&amp;rsquo;d expect from a cheap set) so I turned them right down and the Pi right up. Once I had done that, it was great!&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi.jpg&#34;
  width=&#34;2048&#34;
  height=&#34;1356&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi_hu1b62f07a41763532af6d9b0ebe2907aa_706979_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi_hu1b62f07a41763532af6d9b0ebe2907aa_706979_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Modified bluetooth speaker to raspi running picoreplayer (squeezebox player)&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Afterwards, it was merely a case of fitting the PI into the housing and it fit like it was designed to be there. Some hot glue and a zip tie, and it was time for reassembly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi_installed.jpg&#34;
  width=&#34;2048&#34;
  height=&#34;1356&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi_installed_hued4603b32ab019604d12121b63b357c6_716735_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/07/raspi-muiltiroom-audio/modified_speakers_with_raspi_installed_hued4603b32ab019604d12121b63b357c6_716735_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Fitting a RasPi into a cheap set of bluetooth speakers&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Once reassembled, it looked like it was new out of the box. All it required was a home to be found for it and for it to be plugged in with any old wall plug &amp;amp; USB Micro B cable. Once it&amp;rsquo;s powered up, the PI boots up into piCorePlayer, connects to the Wifi, and is ready to receive music or radio streams! Just running the Andriod app &lt;a class=&#34;link&#34; href=&#34;https://play.google.com/store/apps/details?id=com.angrygoat.android.squeezectrl&amp;amp;hl=en&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Squeeze Ctrl&lt;/a&gt; allows me to control the Logitec Medis Server, which finds the RasPi and considered it an output device. A tap of the app and we have music control.&lt;/p&gt;
&lt;p&gt;All I need to do is order a few more and I have a Sonos-like experience, for a fraction of the price.&lt;/p&gt;
</description>
        </item>
        <item>
        <title>Multiplexing Seven Segment with AVR</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/</link>
        <pubDate>Sun, 29 May 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/multiplex_sevensegment_avr_teaser.jpg" alt="Featured image of post Multiplexing Seven Segment with AVR" /&gt;&lt;h2 id=&#34;multiplexing-a-dual-seven-segment-display&#34;&gt;Multiplexing a dual seven segment display&lt;/h2&gt;
&lt;p&gt;Following on from driving a seven segment with an ATTiny2313a last &lt;a class=&#34;link&#34; href=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/&#34; &gt;post&lt;/a&gt; I swapped out the single seven segment for a dual seven segment that I bought from AliExpress. This one was a dual display with a similar set of 10-pin inputs like the last, single one. The pins from A-G+DP are different to the last, but more tellingly instead of two anode pins for the single display, there is now an anode pin for each segment. Power one pin with some of the LEDs pulling to ground and one lights up, power the other and the other one lights up. And if you power both, you get both sides displaying the same thing.&lt;/p&gt;
&lt;p&gt;I found a post at (&lt;a class=&#34;link&#34; href=&#34;http://codeandlife.com/2012/02/24/7-segment-multiplexing-with-uln2003-pnp-transistors/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;codeandlife.com&lt;/a&gt;) that helped me out with the timers &amp;amp; interrupts, which again I&amp;rsquo;ve found harder to find relevant code for:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/F5261bh_pinout.png&#34;
  width=&#34;639&#34;
  height=&#34;292&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/F5261bh_pinout_hu0df951933de623a5a1b0397c38808473_16128_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/F5261bh_pinout_hu0df951933de623a5a1b0397c38808473_16128_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Dual sevent segment dual display pinout&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;218&#34;
    data-flex-basis=&#34;525px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Here we need to multiplex. What is that? Well, multiplexing is described as:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Telecommunications. of, relating to, or using equipment permitting the simultaneous transmission of two or more trains of signals or messages over a single channel.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this case, to drive one seven segment we have already used 7 pins + power. If we added another stand alone display, that would become 14. What about building a clock with 4 digits, do we go and get an MCU with 28 or more pins?&lt;/p&gt;
&lt;p&gt;Nope. What we do is setup an array of seven segments (two in this proof-of-concept case) which share a common set of lines to drive each LED. But we split the input lines (in this case anode) to the LEDS so we can drive them independent of each other. This enables us to set the AVR pins to sink current to enable one number, and turn the first part of the display on. After a brief delay, we turn that segment off, change the AVR pins for the second number, and turn on the second part of the display.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve measured this rig at between 5-15mA, depending on what is lit up (with a number 8 being the most)&lt;/p&gt;
&lt;blockquote class=&#34;book-hint warning&#34;&gt;
  &lt;b&gt;Warning:&lt;/b&gt; Keep in mind as well that an ATTiny2313a is rated to 20mA sourcing of current. Exceed that and you might burn it out!
&lt;/blockquote&gt;

&lt;p&gt;If we do this very fast (I measured the frequency at around 250mhz) the human eye blends together images and we see both sides lit up simultaneously. This is extremely common and you may be surprised to find where this occurs. If you have a DSLR, try taking very short exposures of LED displays!&lt;/p&gt;
&lt;h2 id=&#34;wiring-up-the-breadboard&#34;&gt;Wiring up the breadboard&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/multiplex_sevensegment_avr.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/multiplex_sevensegment_avr_hu9567584493ea639d53483572da38b97a_364426_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/multiplex_sevensegment_avr_hu9567584493ea639d53483572da38b97a_364426_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Multiplexing a dual seven segment display with a ATTiny2313a&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;So I rewired the breadboard up similar to last time, but taking into account the different pins. Also, instead of +5 going to one of the anode pins of the seven segment I wired one anode of the seven segment to PD4 and the other to PD5 of the ATTiny2313 - this time the AVR will drive the anodes.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;avr-pin&lt;/th&gt;
&lt;th&gt;letter&lt;/th&gt;
&lt;th&gt;led-pin&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PB7&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;pin 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB6&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;pin 9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB5&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;pin 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB4&lt;/td&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;pin 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB3&lt;/td&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;pin 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB2&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;pin 6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB1&lt;/td&gt;
&lt;td&gt;G&lt;/td&gt;
&lt;td&gt;pin 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&#34;schematic&#34;&gt;Schematic&lt;/h2&gt;
&lt;blockquote class=&#34;book-hint info&#34;&gt;
  &lt;b&gt;Info:&lt;/b&gt; I couldn&amp;rsquo;t find a common-anode dual seven segment display on octopart - this is a quad display but imagine its only a dual display.
&lt;/blockquote&gt;

&lt;blockquote class=&#34;book-hint warning&#34;&gt;
  &lt;b&gt;Warning:&lt;/b&gt; The pinouts on this dont match above, again because the part isn&amp;rsquo;t present. If you follow this, check your part datasheet.
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/schematic_seven_segment_multiplex.png&#34;
  width=&#34;1208&#34;
  height=&#34;796&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/schematic_seven_segment_multiplex_hu09faf03f7f0f098e1fb33e686bf45482_93690_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-multiplex-seven-segment/schematic_seven_segment_multiplex_hu09faf03f7f0f098e1fb33e686bf45482_93690_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Schematic for muiltplexing two seven segment displays with a ATTiny2313a&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;151&#34;
    data-flex-basis=&#34;364px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;AVR_Multiplex_Seven_Segment.PDF&#34; &gt;PDF Schematic Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://circuitmaker.com/Projects/0B2CC870-16DB-4604-87C3-4571C2FBB3D5&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;View on CircuitMaker&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;code&#34;&gt;Code&lt;/h2&gt;
&lt;p&gt;With the below code, the display counts from 0-99. Brightness is fine, but can be a problem with more displays. AVR is running interal clock with clockdiv/8 fuse set.&lt;/p&gt;
&lt;p&gt;Here we use a timer to increment a counter each second. A second timer runs the multiplexing, with ~500 interrupts per second. Thats almost it!&lt;/p&gt;
&lt;blockquote class=&#34;book-hint info&#34;&gt;
  &lt;b&gt;Info:&lt;/b&gt; I have started using bit flipping defines for legible code and easy of use. Might annoy the purists!
&lt;/blockquote&gt;

&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt;/*
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * PoorMansSevenSegment.cpp
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * A bodge program to run a seven segment without a BCD - 7 segment display decoder
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * Created: 15/05/2016 6:50:30 PM
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * Author : Nat
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define F_CPU 1000000UL &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//CPU speed, set clockdiv/8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;avr/interrupt.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Defines for  easy bit flipping
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_set(...)        bit_set_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_set_(x,y)        x |= 1&amp;lt;&amp;lt;y            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// set a bit
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_clear(...)        bit_clear_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_clear_(x,y)        x &amp;amp;= ~(1&amp;lt;&amp;lt;y)            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// clear a bit
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_test(...)        bit_test_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_test_(x,y)        (!!(x &amp;amp; (1&amp;lt;&amp;lt;y)))        &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// test a bit
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt;/*** following macros related to the PORTx - register only !    ***/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt;/***                                ***/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_dir_outp(...)    bit_dir_outp_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_dir_outp_(x,y)    *(&amp;amp;x-1) |= 1&amp;lt;&amp;lt;y            &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// access DDRx of PORTx !
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_dir_inp(...)    bit_dir_inp_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_dir_inp_(x,y)    *(&amp;amp;x-1) &amp;amp;= ~(1&amp;lt;&amp;lt;y)        &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// access DDRx of PORTx !
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_test_in(...)    bit_test_in_(__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define    bit_test_in_(x,y)    (!!(*(&amp;amp;x-2) &amp;amp; (1&amp;lt;&amp;lt;y)))        &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// access PINx of PORTx !
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// pin defines
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define PORT_LED PORTB
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define DDR_LED DDRB
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define PORT_PWR PORTD
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define DDR_PWR DDRD
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// define Seven segment output ports for Vcc to Seven Segment
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#define LED0    PORTD, 4
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define LED1    PORTD, 5
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;//binary representations of binary required to light seven segment 0-9
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;unsigned&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pins&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;mb&#34;&gt;0b11111100&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b01100000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11011010&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;mb&#34;&gt;0b11110010&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b01100110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b10110110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b10111110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11100000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11111110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11100110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;volatile&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i_timer_seconds&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;volatile&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i_active_display&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;seven_write&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i_digit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// write to entire LED port - invert due to the fact that in a common anode display LOW = on.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;// to use in a common cathode display, remove inversion.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;PORT_LED&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=~&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pins&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_digit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;ISR&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TIMER1_COMPA_vect&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// increment timer count
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;i_timer_seconds&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;ISR&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TIMER0_OVF_vect&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;PORT_PWR&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;~&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_active_display&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;// turn off LED
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;        &lt;span class=&#34;c1&#34;&gt;//toggle active display
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;i_active_display&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;^=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_active_display&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;seven_write&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_timer_seconds&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		&lt;span class=&#34;n&#34;&gt;seven_write&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_timer_seconds&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;/&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;PORT_PWR&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i_active_display&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;// turn on LED
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;//disable interupts
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;cli&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;//Data Direction Register, set all bits high
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;DDR_LED&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mh&#34;&gt;0xFF&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;                &lt;span class=&#34;c1&#34;&gt;// enable entire LED port as output
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// set led common anode wires to outputs (PD4/5)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;bit_dir_outp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LED0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;bit_dir_outp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LED1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// init timer 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;TIMSK&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;TOIE0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;// timer 0 overflow interupt
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;TCCR1B&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;WGM12&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;// config for CTC mode
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;TIMSK&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;OCIE1A&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;  &lt;span class=&#34;c1&#34;&gt;// CTC interupt
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;OCR1A&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;15625&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;             &lt;span class=&#34;c1&#34;&gt;// prescaler
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;sei&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;TCCR0B&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;CS01&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//timer 0 at clk/8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;n&#34;&gt;TCCR1B&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;CS11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;CS10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//timer 1 at clk/64
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;while&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
        </item>
        <item>
        <title>Poor man&#39;s seven segment LED display with AVR</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/</link>
        <pubDate>Sun, 15 May 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/seven_segment_teaser.jpg" alt="Featured image of post Poor man&#39;s seven segment LED display with AVR" /&gt;&lt;h2 id=&#34;driving-a-seven-segment-display-with-no-bcd-to-seven-segment-chip&#34;&gt;Driving a seven segment display with no BCD to seven segment chip&lt;/h2&gt;
&lt;p&gt;I have gotten a batch of cheap seven segments from DealExtreme, and it was high time I put them through their paces.&lt;/p&gt;
&lt;p&gt;However, I have no BCD to seven segment chips. No matter, I can bodge it up just using 7 pins. So I ran through some code to just drive each segment with a pin from an ATTiny2313a.&lt;/p&gt;
&lt;p&gt;I found from the data-sheet for the 7-seg LED that it was a common anode. So that means I had to drive LOW to sink current to light LEDs - and keep HIGH to keep segments off.&lt;/p&gt;
&lt;p&gt;Starting off by working out the seven segment display and working out in a table which logic levels for each led; to drive the segments for numbers 0-9. I&amp;rsquo;m sure it was searchable online, but where&amp;rsquo;s the fun in that?&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/poormans_seven_segment_writeup.jpg&#34;
  width=&#34;795&#34;
  height=&#34;1200&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/poormans_seven_segment_writeup_hub93b819d2670c4d60beff054f8df3c25_195200_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/poormans_seven_segment_writeup_hub93b819d2670c4d60beff054f8df3c25_195200_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Working out which led&amp;rsquo;s to drive for each number&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;66&#34;
    data-flex-basis=&#34;159px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Using my new target board to hook up the 2313a to a breadboard - with 330Ω from each LED. I saw from the datasheet for the LED seven segment that it had common anode on pins 3 &amp;amp; 8. Using the pinout below I was able to breadboard connections. It was a simple case of matching up PB0-PB7 to match up with the led segments from the datasheet, via the letters.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/led_datasheet.png&#34;
  width=&#34;335&#34;
  height=&#34;260&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/led_datasheet_hue7f50d361d67c20f732309dd83c160c6_11119_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/led_datasheet_hue7f50d361d67c20f732309dd83c160c6_11119_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;6161BS seven segment wiring from data-sheet&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;128&#34;
    data-flex-basis=&#34;309px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;I hooked up PB0 through PB7 to the seven segment display, using the pinouts above to correlate to the pinouts I drew out. I did get tripped up on the direction here - thinking that PB0 was the highest bit in the register! Of course, it isn&amp;rsquo;t!&lt;/p&gt;
&lt;p&gt;So I ended up with:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;avr-pin&lt;/th&gt;
&lt;th&gt;letter&lt;/th&gt;
&lt;th&gt;led-pin&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PB7&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;pin 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB6&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;pin 6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB5&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;pin 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB4&lt;/td&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;pin 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB3&lt;/td&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;pin 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB2&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;pin 9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PB1&lt;/td&gt;
&lt;td&gt;G&lt;/td&gt;
&lt;td&gt;pin 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;td&gt;&amp;mdash;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote class=&#34;book-hint info&#34;&gt;
  &lt;b&gt;Info:&lt;/b&gt; Pin 0 is not connected! When I added the binary to the code I added a trailing 0 to the binary to bump it up to 8-bit.
&lt;/blockquote&gt;

&lt;h2 id=&#34;schematic&#34;&gt;Schematic&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/schematic_poormans_seven_segment.png&#34;
  width=&#34;855&#34;
  height=&#34;645&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/schematic_poormans_seven_segment_hubc3862dac8b35084a2eb907574a7df76_62161_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/schematic_poormans_seven_segment_hubc3862dac8b35084a2eb907574a7df76_62161_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Schematic for ATTiny2313a Seven Segment display&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;132&#34;
    data-flex-basis=&#34;318px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;PoorMans_Seven_Segment.pdf&#34; &gt;PDF Schematic Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://circuitmaker.com/Projects/77BEF137-9137-430F-81A3-6B6F78F57DEB&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;View on CircuitMaker&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;code&#34;&gt;Code&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt;/*
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * PoorMansSevenSegment.cpp
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * A bodge program to run a seven segment without a BCD - 7 segment display decoder
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * Created: 15/05/2016 6:50:30 PM
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * Author : Nat
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#define F_CPU 8000000UL &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;//CPU speed, remove clockdiv/8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;avr/io.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;util/delay.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;//binary representations of binary required to light seven segment 0-9
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;pins&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;mb&#34;&gt;0b11111100&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b01100000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11011010&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;mb&#34;&gt;0b11110010&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b01100110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b10110110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b10111110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11100000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11111110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mb&#34;&gt;0b11100110&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;count&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;DDRB&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;255&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//Data Direction Register, set all bits high
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;while&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;c1&#34;&gt;//change output of entire portb register to above hex (inverted, as its common anode and LED on requires sinking current.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;            &lt;span class=&#34;n&#34;&gt;PORTB&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=~&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pins&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;count&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;_delay_ms&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;end-result&#34;&gt;End result&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/seven_segment_poorman.jpg&#34;
  width=&#34;795&#34;
  height=&#34;1200&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/seven_segment_poorman_hu018b86b423c8ee8d819f5d88e50bd969_403130_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/poormans-seven-segment/seven_segment_poorman_hu018b86b423c8ee8d819f5d88e50bd969_403130_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Seven segment display, poorman style&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;66&#34;
    data-flex-basis=&#34;159px&#34;
  
&gt;
&lt;/p&gt;
</description>
        </item>
        <item>
        <title>Error with device 0x000102 whilst programming AVR</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/</link>
        <pubDate>Sat, 14 May 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/device_0x000102_avr_reset_short_teaser.png" alt="Featured image of post Error with device 0x000102 whilst programming AVR" /&gt;&lt;h2 id=&#34;device-is-read-correctly-the-first-time-but-fails-to-be-read-on-subsequent-reads&#34;&gt;Device is read correctly the first time but fails to be read on subsequent reads&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;m building an AVR target board for a few different flavours of AVR to make my life easier.&lt;/p&gt;
&lt;p&gt;I had some &lt;em&gt;real fun&lt;/em&gt; trying to read the data-sheet pins back to front whilst soldering down the sockets, and had to have more than one go at getting the ATMega328P socket wired up correctly.&lt;/p&gt;
&lt;p&gt;I was using Atmel Studio 7 to read the device ID of various AVR chips I had on my board. When suddenly it would work on the initial read after power up - but subsequent reads would fail with the device ID being returned reading &lt;code&gt;0x000102&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/device_0x000102_avr_reset_short.png&#34;
  width=&#34;805&#34;
  height=&#34;374&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/device_0x000102_avr_reset_short_hu525d38fc0e7772734b6a0ff259679fce_26308_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/avr-device-00102/device_0x000102_avr_reset_short_hu525d38fc0e7772734b6a0ff259679fce_26308_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Picture of Atmel Studio 7 returning devide 0x000102 after a reset line short to ground&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;215&#34;
    data-flex-basis=&#34;516px&#34;
  
&gt;
&lt;/p&gt;
&lt;h2 id=&#34;reset-line-short-to-ground-stopping-reset-line-returning-to-high-post-programming&#34;&gt;Reset line short to ground stopping reset line returning to high post-programming&lt;/h2&gt;
&lt;p&gt;I had introduced a short on the reset line to ground when fixing my wiring. This was causing the reset pin to be low regardless of what the programmer did.&lt;/p&gt;
&lt;p&gt;This makes sense - the initial read works OK as the reset line is LOW. But the AVR chip never leaves programming mode until reset returns to HIGH. This is the reason we add pullups to the reset line.&lt;/p&gt;
&lt;p&gt;With the reset pullup being forced LOW all the time, the AVR never leaves programming mode, and a second programming attempt fails as the AVR is not reset back to the start of its programming phase.&lt;/p&gt;
</description>
        </item>
        <item>
        <title>First AVR LED blinky</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/</link>
        <pubDate>Thu, 05 May 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_attiny_2313a_first_blinky.jpg" alt="Featured image of post First AVR LED blinky" /&gt;&lt;h2 id=&#34;testing-out-new-avr-gear&#34;&gt;Testing out new AVR Gear&lt;/h2&gt;
&lt;p&gt;Well, I’ve received the new programmers I ordered. Amongst them was the &lt;a class=&#34;link&#34; href=&#34;http://www.atmel.com/tools/atatmel-ice.aspx&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Atmel ICE&lt;/a&gt;, which I have chosen to be the first thing I would test.&lt;/p&gt;
&lt;p&gt;I’ve been meaning to get fully into MCU development, but I have to say that the Arduino craze didn’t really grab me. A sketch? Shield? Buy pre-assembled gear and push it together, copy and paste code?&lt;/p&gt;
&lt;p&gt;Pass. I prefer to code, learning and assembling circuitry myself and learning code from examples.&lt;/p&gt;
&lt;p&gt;I’m actually struggling a bit to find decent tutorials for MCU programming (I can’t be looking in the right places). However, it wasn’t too hard to figure out the pinout of the Atmel-ICE and compare to the pinout of the ATtiny 2313A using the data-sheets. I build a miniature shield that plugged in over the top of the MCU and had a neat little 6-pin plugin header (I may cover it in another post).&lt;/p&gt;
&lt;blockquote class=&#34;book-hint info&#34;&gt;
  &lt;b&gt;Info:&lt;/b&gt; The Atmel-ICE data-sheet nicely doesn’t include the direction of the tab in the user guide. The pinout on the user guide doesn’t include the tab on the 6-pin connector. I have added it to the data-sheet image below - the tabbed connector is on the side of MISO, SCK and RESET (for SPI programming)
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_ice_SPI_pinout_clarified.png&#34;
  width=&#34;206&#34;
  height=&#34;100&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_ice_SPI_pinout_clarified_hue9c08831f19e3c45bc457bd14b623727_3651_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_ice_SPI_pinout_clarified_hue9c08831f19e3c45bc457bd14b623727_3651_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Pinout of Ateml-ICE SPI 6 pin wire clarified with tab connector&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;206&#34;
    data-flex-basis=&#34;494px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;So after plugging in the programmer I confirmed all was well in Atmel Studio 7. &lt;code&gt;Tools -&amp;gt; Device programming&lt;/code&gt; gets you to the device programming screen, and selecting &lt;code&gt;Atmel-ICE&lt;/code&gt; tool and your chosen device (in my case I had the ATTiny 2313A, so I selected &lt;code&gt;ATtiny2313a&lt;/code&gt; from the device selection). The interface is &lt;code&gt;ISP&lt;/code&gt; and you can click Apply.&lt;/p&gt;
&lt;p&gt;Once this has been selected, you should be able to click on Read for the device signature. If it reads an address and target voltage, you have succeeded.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_studio_check_device_id.png&#34;
  width=&#34;763&#34;
  height=&#34;231&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_studio_check_device_id_hu3165ed16cc1b0970999c2b5db3e5a8fd_13264_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/atmel_studio_check_device_id_hu3165ed16cc1b0970999c2b5db3e5a8fd_13264_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Atmel Studio 7 Device programming screen confirming Device signature for ATtiny2313a&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;330&#34;
    data-flex-basis=&#34;792px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;I proceeded to load up a blinky led program to confirm all was well, and well, all was well.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_attiny_2313a_first_blinky.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_attiny_2313a_first_blinky_hu49ba83949d675dc6df701e038fdae511_287207_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_attiny_2313a_first_blinky_hu49ba83949d675dc6df701e038fdae511_287207_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;ATtiny 2313A dual-led blinking circuit&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Out of curiosity, I was interested to know the maximum frequency this would have out of the box on the output pins with no &lt;code&gt;_delay_ms()&lt;/code&gt;, with its default 1Mhz clock cycle (8Mhz internal oscillator with the CKDIV8 fuse clocking it down to 1MHz)&lt;/p&gt;
&lt;p&gt;Whilst I did leave it with two I/O operations per cycle, I did come up with a frequency of 103khz.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_stock_max_freq_103khz.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_stock_max_freq_103khz_huc755c4aec7c2ca909a660ba5465e9920_316907_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/first-avr-blinky/avr_stock_max_freq_103khz_huc755c4aec7c2ca909a660ba5465e9920_316907_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;DS1054z showing 103khz for AVR blinking circuit&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
</description>
        </item>
        <item>
        <title>Nexus 6P Pocket Dial woes</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/</link>
        <pubDate>Tue, 03 May 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/nexus-6p-bend.png" alt="Featured image of post Nexus 6P Pocket Dial woes" /&gt;&lt;h2 id=&#34;nexus-6p-keeps-pocket-dialing&#34;&gt;Nexus 6P keeps pocket dialing&lt;/h2&gt;
&lt;p&gt;I love my Nexus 6P. It’s a fantastic android phone and easily the best phone I’ve ever owned (despite the almost excellent experience with my Samsung Galaxy S4). The Nexus 6P is perfect for someone who wants a non-bloated OS/ROM but also still excellent hardware.&lt;/p&gt;
&lt;p&gt;Also, the phone is encouraging me to be social. Like, calling my friends from my pocket whilst there at work. Sorry, Crossy.&lt;/p&gt;
&lt;p&gt;I’ve been scratching my head and finally found out the root settings that were causing the pocket dialing.&lt;/p&gt;
&lt;h2 id=&#34;fixing-pocket-dialing&#34;&gt;Fixing pocket dialing&lt;/h2&gt;
&lt;p&gt;Finally figured out the pocket dialing settings that were causing me the woes. Many people complain about ambient display waking up the phone in your pocket, and then from there the phone getting random touches from your leg and thus pocket dialing.&lt;/p&gt;
&lt;p&gt;In my case, that wasn’t actually the whole story. My issue was actually the &lt;code&gt;Tap to wake&lt;/code&gt; being set to on. This setting wakes the device if it detects a double-tap on the screen whilst it’s off. So yeah, pocket dial city - I don’t remember my S4 being this touchy-feely on the screen.&lt;/p&gt;
&lt;p&gt;Ensure both are off and you should be fine.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/6P_settings_display_dbltap_ambient.png&#34;
  width=&#34;1440&#34;
  height=&#34;2560&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/6P_settings_display_dbltap_ambient_hu5e5dd59c099fd0dc1f6caed10ac7526e_136730_480x0_resize_catmullrom_3.png 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/05/6p-pocketdial-woes/6P_settings_display_dbltap_ambient_hu5e5dd59c099fd0dc1f6caed10ac7526e_136730_1024x0_resize_catmullrom_3.png 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Image of Nexus 6P settings that should be disabled to stop pocket dialing&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;56&#34;
    data-flex-basis=&#34;135px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Unfortunately, Ambient Display has been pretty poor on Andriod so far. It should be quite good - but I’ve found it difficult to use effectively. It is quite difficult to move it enough if it’s just sitting on your desk to activate ambient. I&amp;rsquo;t seemed to display every time you didn’t care about it - and none of the times it did.&lt;/p&gt;
&lt;p&gt;Time (and patches) will tell if this feature is built into anything as good as Moto Display.&lt;/p&gt;
</description>
        </item>
        <item>
        <title>W.E.P 853d clone soldering station</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/</link>
        <pubDate>Mon, 25 Apr 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_overview.jpg" alt="Featured image of post W.E.P 853d clone soldering station" /&gt;&lt;h2 id=&#34;time-for-an-upgrade-from-cheap-solder-pen-to-cheap-solder-station&#34;&gt;Time for an upgrade, from cheap solder pen to cheap solder station.&lt;/h2&gt;
&lt;p&gt;After living with an old non-temperature controlled soldering iron for years I decided it was time to upgrade. I had been using a Goot PX232 for a long time, and before that some Jaycar $15 iron that was only just passable as a soldering iron.&lt;/p&gt;
&lt;p&gt;Now, despite the fact I &lt;em&gt;should&lt;/em&gt; be getting a decent brand, I decided to try a cheap eBay clone. I found a &amp;lsquo;W.E.P 853D Soldering Station/Hot Air Gun/DC Power supply&amp;rsquo; on eBay, within Australia. Few days later I have it in my grubby hands.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been perfectly happy with the operation. I&amp;rsquo;ve had it now for a few months with no issues.&lt;/p&gt;
&lt;p&gt;The soldering iron has tips that fit over the cartridge, it heats up quite nicely. It comes with a large variety of tips (conical, chisel, wedge) and sizes. The iron holder is pretty lousy and the tip will hit the rear of the case and lean against it. I&amp;rsquo;ve continued to use my old iron holder due to this. Its such a relief to be using decent bits now after struggling along with conical for so long.&lt;/p&gt;
&lt;p&gt;The iron heats up to 300° C within 47 seconds, so on that side it&amp;rsquo;s not so great, unfortunately.&lt;/p&gt;
&lt;p&gt;The hot-air gun comes with a few tips to have wider/smaller airflow.&lt;/p&gt;
&lt;p&gt;The power supply I only used a little, but it was accurate to its displayed measurements. I haven&amp;rsquo;t had much experience at measuring power supply ripple so will skip that for now, but I can&amp;rsquo;t say I&amp;rsquo;ve noticed or seen much ripple on my oscilloscope.&lt;/p&gt;
&lt;h2 id=&#34;teardown&#34;&gt;Teardown&lt;/h2&gt;
&lt;p&gt;Finally, that&amp;rsquo;s out of the way. I had to have a look see inside - would it be complete cheap Shenzhen market garbage? Or would it be somewhat passable. More importantly, was it a Yihua station with a different name like I suspected?&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_overview.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_overview_hu45b04c46da18a4228ede64e15a5bcfcf_214574_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_overview_hu45b04c46da18a4228ede64e15a5bcfcf_214574_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;WEP 853D soldering station view from front&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;Presentation was quite nice. My preference is the black and gold to the gaudy blue and yellow others have. Buttons have a nice tactile feel to them and knobs are firmly stuck on and feel OK considering. LCD is clear and bright.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_power.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_power_hu69ccab16872f1199e8d1590778e9be78_313121_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_power_hu69ccab16872f1199e8d1590778e9be78_313121_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;WEP 853D soldering station transformer internal section&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;I won&amp;rsquo;t profess to be any good at a teardown, but the transformer seemed OK, earthed down to chassis with decent connectors. Power transistor is well secured (housed on the rear of the chassis). I know people have concerns about cheap Chinese equipment such as this being a fire hazard - but I didn&amp;rsquo;t see anything that concerned me. I&amp;rsquo;ve seen worse build quality from gear built in better countries and companies that was worse.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_mid.jpg&#34;
  width=&#34;795&#34;
  height=&#34;1200&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_mid_hu0ef121f7a3cbafd5768a0ae06b3d1117_362611_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_mid_hu0ef121f7a3cbafd5768a0ae06b3d1117_362611_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;WEP 853D soldering station mid-section PCB&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;66&#34;
    data-flex-basis=&#34;159px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;PCB in the middle of the board hosts some TRIACS, bridge rectifier, MMOC3041 optocouplers, and various passives. Caps are no name (&lt;a class=&#34;link&#34; href=&#34;http://www.jiaweicheng.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Jwco&lt;/a&gt;) garbage, but at least the TRIACS have heat sinks. A single LM723 voltage regular sits on the board. Soldering seemed perfectly fine, looks wave soldered (or at least reflowed)&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_frontpanel.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;795&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_frontpanel_hub5b04cbd893a806c6515110cc59471ae_370829_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/wep-853d-clone-soldering-station/wep_853d_frontpanel_hub5b04cbd893a806c6515110cc59471ae_370829_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;WEP 853D soldering station mid-section PCB&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;150&#34;
    data-flex-basis=&#34;362px&#34;
  
&gt;
&lt;/p&gt;
&lt;p&gt;The control panel has two S3F94C4EZZ MCU&amp;rsquo;s and two LED display drivers (TM1620 &amp;amp; TM1628). Can&amp;rsquo;t determine the manufacture for the MCU&amp;rsquo;s, I get either a Samsung or Zilog part - I&amp;rsquo;ll leave you to guess which I think is the more likely manufacturer. Not much else happening there, soldering continues to look fine. I can&amp;rsquo;t see any post-production fixes or anything untoward dodgy - if I had been given the photos to look at without knowing where it came from it would look visually OK to me.&lt;/p&gt;
&lt;p&gt;Wait a minute here - the control PCB has a silk-screen designator of &amp;lsquo;YH852DV5A&amp;rsquo;. Clearly the same control board as the Yihua model. After some googling I found an &lt;a class=&#34;link&#34; href=&#34;http://www.eevblog.com/forum/reviews/new-toy-yihua-853dplus-rework-station/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;EEVBlog post&lt;/a&gt; regarding the Yihua which showed a photo with an identical control board, but what to me looked like a significantly worse power board.&lt;/p&gt;
&lt;p&gt;Meanwhile, whilst I wait to see if Shenzhen lets me down again I will continue to enjoy my nifty little soldering station.&lt;/p&gt;
</description>
        </item>
        <item>
        <title>LCD Haul</title>
        <link>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/</link>
        <pubDate>Fri, 22 Apr 2016 00:00:00 +0000</pubDate>
        
        <guid>https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/</guid>
        <description>&lt;img src="https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/Working_salvaged_lcd_hd44780_teaser.jpg" alt="Featured image of post LCD Haul" /&gt;&lt;h2 id=&#34;workplace-preps-to-throw-out-300-phone-units&#34;&gt;Workplace preps to throw out 300+ phone units&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ve upgraded our phone system for the entire business at work. When I piled the old Ericsson desk phone into the box they had set up to return the old phones the thought hit me - there’s a lot of speakers in the 300 odd phones that are being thrown out. Wait, forget that - I bet this LCD is generic.&lt;/p&gt;
&lt;p&gt;So I took a few home and tore them down - and what do you know, but the LCD is a HD44780 based. I politely informed the IT dept they no longer needed an external contractor the throw them out, I would take them, thank you.&lt;/p&gt;
&lt;p&gt;I wanted to ensure I could get it working before grabbing them all. While I am yet to receive the MCU programming kits I’ve ordered, so I found an old Arduino Mega I had lying around from the 3D printer build. Whilst this should have been a simple check, Murphy, of course, got me - the ribbon cable pin pitch width was just too small for me to solder on my own ribbon cable to break out onto a breadboard. I had a few goes but the two sizes of ribbon cable I had on hand were the right width and bending the pins to neatly marry up with the solder pads just wasn’t working for me.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/box_of_old_phones.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;1604&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/box_of_old_phones_hua3e6dcff578a1910a1742cbe9c1b2f77_196617_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/box_of_old_phones_hua3e6dcff578a1910a1742cbe9c1b2f77_196617_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;A cardboard box containing old phones with LCD screens&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;74&#34;
    data-flex-basis=&#34;179px&#34;
  
&gt;
&lt;/p&gt;
&lt;h2 id=&#34;getting-a-salvaged-10-pin-hd447800-lcd-working&#34;&gt;Getting a salvaged 10 pin HD447800 LCD working&lt;/h2&gt;
&lt;p&gt;My solution to break it out was to slice up the individual wires from one of the actual ribbon cables from the phone and solder it to a 12 pin header. The challenge here was that most HD4480’s are 16-pin - and this puppy had a 12 pin input. I did notice that 2 pins weren’t apparently connected by a quick scan of the PCB, and assuming it was actually a 10 pin LCD some googling revealed the following pinout.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/Working_salvaged_lcd_hd44780.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;1600&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/Working_salvaged_lcd_hd44780_hu3c5a1bead15a5cbaabe1db327abf4b3e_304344_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/Working_salvaged_lcd_hd44780_hu3c5a1bead15a5cbaabe1db327abf4b3e_304344_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;A working LCD wired to a breadboard displaying characters&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;75&#34;
    data-flex-basis=&#34;180px&#34;
  
&gt;
&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1: Gnd
2: VCC (5v)
3: Contrast (10k pot)
4: RS
5: R/W
6: E
7: DB4
8: DB5
9: DB6
10: DB7
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And the header of the Arduino Liquidcrystal library includes where to connect the pins of the Arduino to the LCD.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;From there it’s easy enough to connect the dots. So no backlight, but a perfectly working 2x20 LCD.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/LCD_HD44780_breakoiut_cable_mod.jpg&#34;
  width=&#34;1200&#34;
  height=&#34;1600&#34;
  srcset=&#34;https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/LCD_HD44780_breakoiut_cable_mod_hu3c5a1bead15a5cbaabe1db327abf4b3e_279012_480x0_resize_q75_catmullrom.jpg 480w, https://6e2dbc8c.voltaicforge.pages.dev/p/2016/04/lcd-haul/LCD_HD44780_breakoiut_cable_mod_hu3c5a1bead15a5cbaabe1db327abf4b3e_279012_1024x0_resize_q75_catmullrom.jpg 1024w&#34;
  loading=&#34;lazy&#34;
  
    alt=&#34;Quick mod to breakout small ribbon cable into breadboard for LCD HD44780&#34;
  
  
    class=&#34;gallery-image&#34; 
    data-flex-grow=&#34;75&#34;
    data-flex-basis=&#34;180px&#34;
  
&gt;
&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
