<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[heeed.net]]></title><description><![CDATA[heeed.net]]></description><link>https://heeed.net/</link><image><url>https://heeed.net/favicon.png</url><title>heeed.net</title><link>https://heeed.net/</link></image><generator>Ghost 5.19</generator><lastBuildDate>Sat, 07 Feb 2026 22:58:54 GMT</lastBuildDate><atom:link href="https://heeed.net/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Sharing a Meta Quest Screen]]></title><description><![CDATA[How to use a Raspberry Pi to screen cast the output of a Meta Quest 2 Headset.....
]]></description><link>https://heeed.net/sharing-a-meta-quest-screen/</link><guid isPermaLink="false">64342eb757a79a03776a0a1d</guid><category><![CDATA[raspberrypi]]></category><category><![CDATA[virtualreality]]></category><category><![CDATA[maker]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Mon, 10 Apr 2023 16:41:37 GMT</pubDate><media:content url="https://heeed.net/content/images/2023/04/PXL_20221020_160711356.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://heeed.net/content/images/2023/04/PXL_20221020_160711356.jpg" alt="Sharing a Meta Quest Screen"><p>Recently I have been involved with a research project into how Virtual Reality devices, namely the Meta Quest 2, can be used to assess how well users perform within a ward based environment.</p><p>The user is presented with a virtual world and are assessed on how well they deal...or not deal...with various issues presented within the environment.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://heeed.net/content/images/2023/04/image-2.png" class="kg-image" alt="Sharing a Meta Quest Screen" loading="lazy" width="496" height="468"><figcaption>Early prototype of the Ward.</figcaption></figure><p>The project has regularly been demonstrated to stakeholders and other research groups and until recently this was achieved using existing equipment along with third party software <a href="https://sidequestvr.com/">SideQuest</a> mirror what the user can see onto an external monitor. However shifting priorities meant that this equipment became temporarily unavailable.<br><br>Whilst SideQuest was suitable within our lab environment it would not be suitable for general use outside of the lab environment. It could potentially run on staff laptops and learner computers but this would mean another layer of administration being added to what was needed as it would then become another package that would need to be managed by our support unit and be outside of our control. <br><br>This presented a good opportunity to find a solution to the problem that could remain in house and be span up as needed...but also be one we could control.</p><p>At a basic level the Quest 2 headset can be thought of as an android phone with a fancy built in screen. Having used a tool called <a href="https://github.com/Genymobile/scrcpy">scrcpy</a> in the past to repurpose old Android devices as cameras I wondered if this could be a potential solution.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://heeed.net/content/images/2023/04/image-3.png" class="kg-image" alt="Sharing a Meta Quest Screen" loading="lazy" width="645" height="596" srcset="https://heeed.net/content/images/size/w600/2023/04/image-3.png 600w, https://heeed.net/content/images/2023/04/image-3.png 645w"><figcaption>Taran (@Taran3D) explaining how to measure the patients pulse</figcaption></figure><p><a href="https://github.com/Genymobile/scrcpy">Scrcpy&apos;s</a> repository shows that the tool is cross-platform and supports Windows. However it would be unlikely that we could get this installed on our staff laptops due to policy restrictions. &#xA0;What we did have though was one or two Raspberry Pi kicking around.</p><figure class="kg-card kg-image-card"><img src="https://heeed.net/content/images/2023/04/image.png" class="kg-image" alt="Sharing a Meta Quest Screen" loading="lazy" width="1207" height="909" srcset="https://heeed.net/content/images/size/w600/2023/04/image.png 600w, https://heeed.net/content/images/size/w1000/2023/04/image.png 1000w, https://heeed.net/content/images/2023/04/image.png 1207w" sizes="(min-width: 720px) 720px"></figure><p>According to the repository <a href="https://github.com/Genymobile/scrcpy">scrcpy</a> is currently at version 2.0 but the version available in Pi&apos;s repository was 1.17 so there was a requirement to compile the latest version. A set of instructions was found <a href="https://gist.github.com/RubenNL/e259f145371d2c16a3932fa39aa9a775">here</a> and updated to use the version 2.0 of the scrcpy-server as shown below:</p><!--kg-card-begin: markdown--><pre><code class="language-bash">sudo apt -y install git wget meson libavformat-dev libsdl2-dev adb

git clone https://github.com/Genymobile/scrcpy.git
cd scrcpy

wget https://github.com/Genymobile/scrcpy/releases/download/v2.0/scrcpy-server-v2.0

meson x --buildtype release --strip -Db_lto=true -Dprebuilt_server=scrcpy-server-v2.0ninja -Cx

sudo ninja -Cx install
</code></pre>
<!--kg-card-end: markdown--><p>This builds two packages, both of which need to be placed into /usr/bin</p><p>Once ready this was, optimistically, tested on an Pi Zero with the expected results of the Zero becoming overloaded and very laggy. </p><p>It was then tested with a 3B+ and whilst still laggy it was usable but showing the contents of each eye lens in a separate window. After a bit of searching a solution was found <a href="https://stackoverflow.com/a/73202796">here</a>:</p><p><code>scrcpy --crop 1730:974:1934:450 --max-fps 15</code></p><p>With the --max-fps set to 15 performance became a lot better in use although there can be a slight delay of a second or two between what the user is seeing and what is displayed.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://heeed.net/content/images/2023/04/image-1.png" class="kg-image" alt="Sharing a Meta Quest Screen" loading="lazy" width="444" height="416"><figcaption>Raspberry Pi (just below the monitor on the left) screen casting from the Quest2</figcaption></figure><p>Also, as the ADB tools are installed, it&apos;s possible to <a href="https://developer.oculus.com/documentation/native/android/ts-adb/">install a APK directly from the Pi</a> onto the headset providing that developer mode is enabled. The headset will also need to be connected to a ADB server...try doing it with scrcpy running.</p><p><code>adb install -r &lt;path to .apk&gt;</code></p><p>Info about the Project:</p><p><a href="https://www.ncfe.org.uk/help-shape-the-future-of-learning-and-assessment/aif-pilots/calderdale-college/"><a href="https://www.ncfe.org.uk/help-shape-the-future-of-learning-and-assessment/aif-pilots/calderdale-college/">https://www.ncfe.org.uk/help-shape-the-future-of-learning-and-assessment/aif-pilots/calderdale-college/</a></a></p><p><a href="https://www.calderdale.ac.uk/calderdale-college-first-to-deliver-virtual-reality-social-care-curriculum/"><a href="https://www.calderdale.ac.uk/calderdale-college-first-to-deliver-virtual-reality-social-care-curriculum/">https://www.calderdale.ac.uk/calderdale-college-first-to-deliver-virtual-reality-social-care-curriculum/</a></a></p><p><a href="https://twitter.com/CalderdaleCol/status/1600134106297139200"><a href="https://twitter.com/CalderdaleCol/status/1600134106297139200">https://twitter.com/CalderdaleCol/status/1600134106297139200</a></a></p><p><a href="https://twitter.com/CalderdaleCol/status/1643272446345203713/photo/3"><a href="https://twitter.com/CalderdaleCol/status/1643272446345203713/photo/3">https://twitter.com/CalderdaleCol/status/1643272446345203713/photo/3</a></a></p>]]></content:encoded></item><item><title><![CDATA[A new FreeCad book appears....]]></title><description><![CDATA[Earlier I posted about FreeCad and how Jo Hincliffe (@concreted0g) had started a series of howto guides on using the package. These guides have been thrown together in to a book ]]></description><link>https://heeed.net/freecadbook/</link><guid isPermaLink="false">634ae3f85a2d1903e179671f</guid><category><![CDATA[maker]]></category><category><![CDATA[workshops]]></category><category><![CDATA[Getting Started]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Sat, 15 Oct 2022 17:03:06 GMT</pubDate><media:content url="https://heeed.net/content/images/2022/10/FreeCAD_Cover_Web.png" medium="image"/><content:encoded><![CDATA[<img src="https://heeed.net/content/images/2022/10/FreeCAD_Cover_Web.png" alt="A new FreeCad book appears...."><p>Earlier I posted about FreeCad and how Jo Hincliffe (<a href="https://twitter.com/concreted0g">@c0ncreted0g</a>) had started a series of how-to guides on using the package.<br><br>These guides have been thrown together and published by Hackspace Magazine!<br></p><figure class="kg-card kg-image-card"><img src="https://heeed.net/content/images/2022/10/image.png" class="kg-image" alt="A new FreeCad book appears...." loading="lazy" width="1800" height="1183" srcset="https://heeed.net/content/images/size/w600/2022/10/image.png 600w, https://heeed.net/content/images/size/w1000/2022/10/image.png 1000w, https://heeed.net/content/images/size/w1600/2022/10/image.png 1600w, https://heeed.net/content/images/2022/10/image.png 1800w" sizes="(min-width: 720px) 720px"></figure><p><br>Grab yourself a copy for free <a href="https://hackspace.raspberrypi.com/books/freecad">here</a><br><br></p>]]></content:encoded></item><item><title><![CDATA[PiWars and Small Robots at Calderdale College]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p><img src="https://heeed.net/content/images/2021/08/happy.jpeg" alt="happy" loading="lazy"></p>
<p>Before the end of the summer term in 2020 an introductory microcontroller session was ran using tinkercad to simulate basic electronics with a micro:bit. As this sparked an interest in the students I decided to enter a college team into to 2021 PiWars competition.</p>
<p>As we had two groups</p>]]></description><link>https://heeed.net/piwars2021/</link><guid isPermaLink="false">634adfeb5a2d1903e17966b3</guid><category><![CDATA[piwars]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Tue, 31 Aug 2021 23:17:07 GMT</pubDate><media:content url="https://heeed.net/content/images/2022/10/flag.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2022/10/flag.jpg" alt="PiWars and Small Robots at Calderdale College"><p><img src="https://heeed.net/content/images/2021/08/happy.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>Before the end of the summer term in 2020 an introductory microcontroller session was ran using tinkercad to simulate basic electronics with a micro:bit. As this sparked an interest in the students I decided to enter a college team into to 2021 PiWars competition.</p>
<p>As we had two groups within the 2nd year group, the initial idea was to build two robots and have each group battle for the right to represent the college at PiWars and also to put into practice the skills they were learning on the course.</p>
<p>As the students were, generally, inexperienced in hardware building and having to fit the project work in around normal coursework each group would start with identical base hardware to allow them to concentrate on the software aspects and any adaptations required for the challenge.</p>
<p>After being accepted for the competition we were faced, unfortunately, with another period of covid lockdown causing disruption to teaching and the project was temporarily suspended although the search for a suitable hardware base for the robots continued.</p>
<p>Back in <a href="https://hackspace.raspberrypi.org/issues/32">issue 32</a> of Hackspace Magazine a robot design was featured in the magazine. This design, name MTV Bot, created by Jo Hinchcliffe (<a href="https://twitter.com/concreted0g">@concreted0g</a>)  and with the rough price guide of around &#xA3;25 for some parts and some 3D printing it looked like it would be ideal for the project.</p>
<p><img src="https://heeed.net/content/images/2021/08/bot.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>The first bot was built during October. The chassis came as a kit requiring some assembly. First thing was to solder the power wires to the motors before mounting them to the chassis. As it was not actually specified in the original article, it was was found that 16AWG wire was both pliable enough to route through the holes in the body and, more importantly, the correct diameter size to fit snugly into the terminals on the L298N motor controller.</p>
<p><img src="https://heeed.net/content/images/2021/08/power1.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>Once all this was done fitting the tracks to the motor drive wheel and spindles was next. This is best done with a sense of humour as it is a bit of a fiddly job and it was found that the tracks, on our chassis kits, were 2 or three links too long. Shorting the tracks requires driving out a track pin or two and then reconnecting at the correct length. This is explained in detail within Jo&apos;s article.</p>
<p><img src="https://heeed.net/content/images/2021/08/finaldrive.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>The bottom printed body part was then mounted onto the chassis using the M4 bars and nuts. Once secured the top layer was mounted onto the bars using nuts to form a support and the L298N mount was connected. Using spring washers helped here as they stopped the nuts from vibrating loose when the bot was in use.</p>
<p><img src="https://heeed.net/content/images/2021/08/built1.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>At this point the bot was ready for testing. After a visual and multimeter check on the wiring for any shorts a Raspberry Pi was connected up. At this point the Pi was powered from a separate USB battery whilst the motor controller was supplied direct from the LiPO battery. Each motor was tested for function both as a pair and independently.</p>
<p>Eventually our 1st year group took up the mantle from the 2nd year groups and started to experiment with the bot. One thing that was quickly realised was that the extra battery for the Pi was starting to interfere with robot operations. Removing this extra battery and powering the Pi from the same supply as the motors would be a better overall solution and also that it would probably be a good idea to be able to isolate the motors.</p>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Robot Party!<a href="https://twitter.com/hashtag/piwars?src=hash&amp;ref_src=twsrc%5Etfw">#piwars</a> <a href="https://t.co/B8tsekefqD">pic.twitter.com/B8tsekefqD</a></p>&#x2014; heeed (@heeedt) <a href="https://twitter.com/heeedt/status/1398560767461498882?ref_src=twsrc%5Etfw">May 29, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> 
<p>A potential solution to this was found on Dr Footleg&apos;s (<a href="https://twitter.com/drfootleg">@drfootleg</a>) Mars Rover robot design. Here he had powered the entire system from a single LiPo battery with this <a href="http://adventures-with-pi.blogspot.com/2019/02/pi-wars-robot-electrical-design.html">design</a>. The supply from the LiPo was split into two paths, one to supply the motor controller and the other to power the electronics via a UBEC module to drop the supplied voltage to a 5v supply. After testing to check everything still worked a switch was fitted on the wire connecting the LiPo to the motor supply input on the L298N.</p>
<p><img src="https://heeed.net/content/images/2021/08/switch.jpeg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>After these modifications had been successfully implemented, further development was handed over to the students to solve the PiWars challenges. One of the first tasks they figured out quickly was to bring the bot under control via a console style controller.</p>
<p><img src="https://heeed.net/content/images/2021/08/flag.jpg" alt="PiWars and Small Robots at Calderdale College" loading="lazy"></p>
<p>Ultimately the team came 5th out of a beginners class containing 15 teams and also came first in &apos;Up the garden path&apos; challenge by controlling the bot by with voice control.</p>
<iframe width="1280" height="720" src="https://www.youtube.com/embed/VszDVbu6QUk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit radio bluetooth bridge]]></title><description><![CDATA[We all know that the micro:bit is unable to use bluetooth or radio functionality at the same time. 

However...what would happen if we gave the sending micro:bit an extra external bluetooth interface?]]></description><link>https://heeed.net/micro-bit-radio-bluetooth-bridge/</link><guid isPermaLink="false">634adfeb5a2d1903e17966b4</guid><category><![CDATA[bluetooth]]></category><category><![CDATA[maker]]></category><category><![CDATA[microbit]]></category><category><![CDATA[robots]]></category><category><![CDATA[piwars]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Sat, 23 Jan 2021 23:49:57 GMT</pubDate><content:encoded><![CDATA[<h1></h1><p>Whilst watching a presentation by <a href="martinohanlon">Martin O&#x2019;Hanlon</a> &#xA0;at the <a href="https://piwars.org/2021-vc/">PiWars Conference</a> earlier today about creating a bluetooth based controller for a robot using <a href="https://bluedot.readthedocs.io/en/latest/">BlueDot 2.0</a> I was reminded of an idea I had last year.</p><p>Basically the idea was about remote controlling a device that was connected to a micro:bit which in turn was accepted remote commands from another micro:bit over a radio link.</p><p>Yes..I know using micro:bit radio as remote control system has been covered in great depth but could it be adapted to allow any device to connect to the micro:bit over bluetooth and then remote control the remote micro:bit</p><p>Confused yet?...I was at first :)</p><h2 id="the-idea">The idea</h2><p>We all know that the micro:bit is unable to use bluetooth or radio functionality at the same time. However...what would happen if we gave the sending micro:bit an extra external bluetooth interface?</p><p>Could we then use this external interface with the micro:bit to form a bridge allowing devices to connect and send commands via the sending micro:bit&apos;s radio link to another micro:bit (or collection of micro:bits) in the same radio group?</p><p>If we could then this opens up all sorts of possibilities for mischief. Imagine being able to control a fleet of micro:bit robots from one application running on your laptop.</p><p>The HC-05 bluetooth module was chosen to see if the idea had any merit. It was chosen due to being sat unused in the parts bin...it&apos;s entirely possible that other similar spec&apos;d devices will also be fine to use.</p><p>The circuit below was adapted from a similar a circuit which used an <a href="https://create.arduino.cc/projecthub/electropeak/getting-started-with-hc-05-bluetooth-module-arduino-e0ca81">arduino</a> instead of a micro:bit:</p><figure class="kg-card kg-image-card"><img src="https://heeed.net/content/images/2021/01/microbit_bridge.png" class="kg-image" alt loading="lazy" width="1349" height="768" srcset="https://heeed.net/content/images/size/w600/2021/01/microbit_bridge.png 600w, https://heeed.net/content/images/size/w1000/2021/01/microbit_bridge.png 1000w, https://heeed.net/content/images/2021/01/microbit_bridge.png 1349w" sizes="(min-width: 720px) 720px"></figure><!--kg-card-begin: markdown--><p>The code for the sender micro:bit is shown below:</p>
<pre><code class="language-javascript">
function sendOrder () {
    basic.showString(order)
    serial.writeLine(&quot;Got: &quot; + order)
    if (order == &quot;lef&quot;) {
        basic.showIcon(IconNames.Happy)
        radio.sendString(&quot;left&quot;)
    } else if (order == &quot;righ&quot;) {
        basic.showIcon(IconNames.Sad)
        radio.sendString(&quot;right&quot;)
    }
    basic.clearScreen()
}
input.onButtonPressed(Button.A, function () {
    serial.writeLine(&quot;left&quot;)
    radio.sendString(&quot;left&quot;)
})
input.onButtonPressed(Button.B, function () {
    serial.writeLine(&quot;right&quot;)
    radio.sendString(&quot;right&quot;)
})
serial.onDataReceived(serial.delimiters(Delimiters.NewLine), function () {
    basic.showIcon(IconNames.Yes)
    order = serial.readLine()
    order = order.substr(0, order.length - 1)
    sendOrder()
})
let order = &quot;&quot;
radio.setGroup(1)
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate9600
)
basic.pause(100)
serial.writeLine(&quot;mb connected :)&quot;)

</code></pre>
<!--kg-card-end: markdown--><p></p><p></p><figure class="kg-card kg-image-card"><img src="https://heeed.net/content/images/2021/01/microbit-screenshot-1.png" class="kg-image" alt loading="lazy" width="2000" height="1081" srcset="https://heeed.net/content/images/size/w600/2021/01/microbit-screenshot-1.png 600w, https://heeed.net/content/images/size/w1000/2021/01/microbit-screenshot-1.png 1000w, https://heeed.net/content/images/size/w1600/2021/01/microbit-screenshot-1.png 1600w, https://heeed.net/content/images/size/w2400/2021/01/microbit-screenshot-1.png 2400w" sizes="(min-width: 720px) 720px"></figure><p>I have not included any code for the receiving micro:bit. Any code you do write just needs to listen on the same radio group and react to any strings being transmitted.<br><br>This will be trivial for experienced micro:bit users but will also be a nice little learning opportunity for those new to micro:bit radio functionality.</p><h2 id="example">Example</h2><p>The video below shows a prototype build controlling a remote micro:bit plugged into a Valenta <a href="https://4tronix.co.uk/blog/?p=2399">robot car</a>. </p><figure class="kg-card kg-embed-card"><iframe width="356" height="200" src="https://www.youtube.com/embed/Xbz9bpIflKg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></figure><p>The sending micro:bit relays commands, via the radio module, from the HC-05 which is connected serially. </p><p>The HC-05, in turn, receives simple strings over bluetooth...in this case from a <a href="https://play.google.com/store/apps/details?id=project.bluetoothterminal">Bluetooth terminal android app</a> (App install at your own risk) running on a an old Fire tablet.</p>]]></content:encoded></item><item><title><![CDATA[FreeCad....]]></title><description><![CDATA[Just  few words about getting started in freecad :)]]></description><link>https://heeed.net/freecad-intro/</link><guid isPermaLink="false">634adfeb5a2d1903e17966b2</guid><category><![CDATA[maker]]></category><category><![CDATA[workshops]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Thu, 16 Jul 2020 19:39:05 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Yes...I know it&apos;s been a while since the last post but I&apos;ve recently started playing around with <a href="https://www.freecadweb.org/">freecad</a></p>
<p><img src="https://heeed.net/content/images/2020/07/freecad.png" alt="freecad" loading="lazy"></p>
<p>Partly to start getting geared up for <a href="https://piwars.org">PiWars</a> and partly to get the ender 2 gainfully employed and not sat there looking forlorn.</p>
<p>It&apos;s certainly a bit of a giggle to get the hang of it but it&apos;s looking worthwhile to learn.</p>
<p>A nice intro to Freecad wrote by Jo Hincliffe (@concreted0g) can be found in issue 25 of Hackspace Magazine...or by clicking <a href="https://magazines-static.raspberrypi.org/issues/full_pdfs/000/000/299/original/HackSpaceMagazine25.pdf">here</a></p>
<p>Another great resource are these video tutorials on this <a href="https://www.youtube.com/watch?v=TLf2KVrtGew">youtube</a> series by Power Playground</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[A summer of Robot building at the library]]></title><description><![CDATA[With the school summer holidays on the horizon, the idea of a robot building workshop was pitched to Kirklees Libraries...this is what resulted]]></description><link>https://heeed.net/a-summer-of-robot-building/</link><guid isPermaLink="false">634adfeb5a2d1903e17966b1</guid><category><![CDATA[robots]]></category><category><![CDATA[arduino]]></category><category><![CDATA[workshops]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Sat, 21 Sep 2019 14:10:56 GMT</pubDate><media:content url="https://heeed.net/content/images/2019/09/robot1.jpeg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2019/09/robot1.jpeg" alt="A summer of Robot building at the library"><p>With the school summer holidays on the horizon, the idea of a robot building workshop was pitched to <a href="https://twitter.com/KirkleesLibrary">Kirklees Libraries</a> who showed interest. A few potential ideas/designs were discussed and the one that seemed to fit all the correct holes was the PounderBot.</p>
<p>The Pounderbot was a design created by a chap that you may (or may not) be aware of called <a href="https://twitter.com/biglesp">@biglesp</a>.<br>
He set himself, as part of his <a href="https://bigl.es/friday-fun-attiny85-10-robot-challenge/">Friday Fun sessions</a>,  a challenge of building a simple robot vehicle for under &#xA3;10 pounds.</p>
<p>His design priced at &#xA3;9.88 was under his &#xA3;10 goal and produced a simple, easy to build robot.</p>
<p><img src="https://heeed.net/content/images/2019/09/lesrobot.jpg" alt="A summer of Robot building at the library" loading="lazy"></p>
<p>Now with a design, and more importantly a shopping lists of parts, planning could begin for the sessions.</p>
<h2 id="buildingatestrig">Building a test rig</h2>
<p>At this point a few substitutions were made to the original parts list and the parts ordered.</p>
<p>These changes were the use of a pre-cut chassis kit and the motor/wheels changed from the micro-gear type motors to the big chunky yellow motors with big yellow wheels.  The parts arrived in due course and a test build commenced.</p>
<p><img src="https://heeed.net/content/images/2019/09/DSCN0384.JPG" alt="A summer of Robot building at the library" loading="lazy"></p>
<h3 id="poweritupforthefirsttime">Power it up for the first time</h3>
<p>Once built the power switch was turned on and.....nothing happened. Power was turned back of and on again with almost the same result but for about 5 seconds the right wheel would spin of it&apos;s own accord.</p>
<p>The other wheel would then spin after a few seconds with the robot sometimes following it&apos;s test program or appearing to reset and start spinning its single wheel again.</p>
<p>This was a bit concerning as the robot would get very dizzy if all it could do was spin in a circle.</p>
<p>Les had already identified this issue and, with the help of Gareth from <a href="https://twitter.com/4tronix_uk">4tronix</a>, had diagnosed and fixed it by adding resistors between the motor controller and motors to reduce the current being used by the motors. This prevented stress on the current supply from the batteries which would cause the digispark attiny85 to reset making the individual motor spin which would cause the current to drop causing the attiny85 to reset....</p>
<p>Checking the robot I realised that I&apos;d forgotten these resistors during the parts order and, as usually is the case, I had none in my component box.</p>
<h3 id="findingthefix">Finding the fix</h3>
<p>Probing around I noticed Pin 3 was high on boot even though the code had set it to low. This was causing the motor to spin with the resulting issues.</p>
<p>Digging further online I discovered the attiny85 has a five second delay when powered on to check if anything is trying to re-flashing the board. As Pin 3 doubles as one of the USB pins this appeared to be cause of the motor issue.</p>
<p>Looking at the Pounderbot design I wondered what would happen if I swapped the IR sensor input on Pin 4 to use Pin 3, then placing the evicted motor controller wire from Pin 3 to Pin 4 and updating the code to make sure the right signals made it to the right pins.</p>
<p>On power up, nothing appeared to happening for the first five seconds but then the robot happily trundled off under it&apos;s own steam. The robot was recaptured and the power recycled with the same result.</p>
<p>It appears that swapping the wires not only removed the requirement for the resistors but also prevented the wheel spinning...no more dizzy robots.</p>
<h2 id="theworkshops">The Workshops</h2>
<p>Now that the robot appeared to be working as intended a simple worksheet was created to allow a step by step build.</p>
<p><img src="https://heeed.net/content/images/2019/09/robot2.jpeg" alt="A summer of Robot building at the library" loading="lazy"></p>
<p>Each workshop catered for ten participants at various libraries in Kirklees. Due to some crossed wires we had some participants as young as eight attend.</p>
<p>During each session each participant got to experience soldering, with many enjoying being trusted with a soldering iron, under supervision and using the various handtools. Everyone left with the same amount of body parts as they came in with...probably due to the safety talk at the beginning being at a level children could understand.</p>
<p>As expected, some robots failed to work properly at the beginning but were quickly fixed. This was down to simple things as wires being placed in the wrong place or screws not tightened fully.</p>
<p><img src="https://heeed.net/content/images/2019/09/robot3.jpeg" alt="A summer of Robot building at the library" loading="lazy"></p>
<p>Hopefully these workshops have inspired future robot engineers :)</p>
<h3 id="furtherinfo">Further info</h3>
<p>The files used for these workshops can be found here: <a href="https://github.com/heeed/Library-Robot">Library Robot</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[PyGame Invaders]]></title><description><![CDATA[It began in a galaxy far far away...actually it didn't really but started here on Earth.]]></description><link>https://heeed.net/pygame-invaders/</link><guid isPermaLink="false">634adfeb5a2d1903e17966b0</guid><category><![CDATA[python]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Tue, 20 Aug 2019 15:23:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>It began in a galaxy far far away...actually it didn&apos;t really but started here on Earth.</p>
<p>One morning an multiple alien ships were suddenly detected over towns and cities worldwide. Whilst the various defence systems world wide were able to handle this first wave, they started to slowly be eradicated by the aliens and a new generation were required to step up but they needed to be trained.</p>
<p>This is where you come onboard and help to create a simple training simulator to defend the planet.</p>
<p>Head to <a href="https://github.com/heeed/pygame-invaders">https://github.com/heeed/pygame-invaders</a> to commence your work!</p>
<p><img src="https://heeed.net/content/images/2019/08/game2.png" alt="game2" loading="lazy"></p>
<hr>
<p>This project is a simple worksheet to introduce basic Python and PyGame Zero game mechanics.</p>
<p>It&apos;s based upon the Pygame Zero Invaders article wrote by Mark Vanstone (<a href="https://twitter.com/mindexplorers">https://twitter.com/mindexplorers</a>) that was published in issue 74 of the MagPi Magazine:<br>
<a href="https://www.raspberrypi.org/magpi/issues/74/">https://www.raspberrypi.org/magpi/issues/74/</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit and the quest for speakers]]></title><description><![CDATA[Modifying poundland speakers to use with the micro:bit ]]></description><link>https://heeed.net/micro-bit-and-speakers/</link><guid isPermaLink="false">634adfeb5a2d1903e17966ac</guid><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Mon, 12 Feb 2018 15:05:27 GMT</pubDate><media:content url="https://heeed.net/content/images/2018/02/IMG_1251-1.JPG" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2018/02/IMG_1251-1.JPG" alt="micro:bit and the quest for speakers"><p>Now we all know that the micro:bit can make noise either with <a href="https://makecode.microbit.org/reference/music">makecode</a> or <a href="http://microbit-micropython.readthedocs.io/en/latest/tutorials/music.html">Python</a> but out of the box its quite a quiet little thing.</p>
<p>Luckily you can use some crocodile clips to <a href="https://www.microbit.co.uk/blocks/lessons/hack-your-headphones/activity">connect a pair of standard headphones</a> or use the <a href="https://www.proto-pic.co.uk/ampbit-class-d-amplifier-for-microbit-with-headphone-jack.html">amp:bit</a> but these keep the awesome the music to the user.</p>
<p>However another way would be to make some speakers for use with the micro:bit...so whilst browsing the local poundland I found some of these:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1241_small-1.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p>After getting them back to the workshop the back of one of the speakers was removed by unscrewing the three retaining screws:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1242.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p>A quick use of the soldering iron and the cable was disconnected from the speaker and removed from the back cover.</p>
<p>A pair of crocodile clips were then snipped in half and the ends stripped:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1246.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p>These cables were then fed through the hole where the original cable had gone through. The hole needed to be enlarged slighty to allow both cables to comfortably fit through:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1248.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p>After the cables were through a quick bit of soldering connected the new cables to the speaker:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1250.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p>and the speaker case was screwed back together:</p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1251.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<p><img src="https://heeed.net/content/images/2018/02/IMG_1252.JPG" alt="micro:bit and the quest for speakers" loading="lazy"></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/akFSOXSsJ_g?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<p>This shows that for the cost of &#xA3;10, some crocodile clips and a bit of time twenty individual speakers can be created to for use in a classroom or CodeClub even.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit and sharing sensors with a Raspberry Pi]]></title><description><![CDATA[Can a Raspberry Pi access the built in sensors present on a micro:bit via i2c?]]></description><link>https://heeed.net/micro-bit-and-sharing-sensors/</link><guid isPermaLink="false">634adfeb5a2d1903e17966ab</guid><category><![CDATA[microbit]]></category><category><![CDATA[raspberrypi]]></category><category><![CDATA[i2c]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Fri, 09 Feb 2018 22:43:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>&quot;Can a Raspberry Pi use the sensors on a micro:bit?&quot;</p>
<p>This was the question that was asked whilst sat in the pub the other evening.</p>
<p>A few evenings later a micro:bit was connected via i2c to a Raspberry Pi and i2cdetect was ran on the Pi:</p>
<pre><code class="language-bash">pi@raspberrypi:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- 0e -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
</code></pre>
<p>This shows that the Accelerometer (0x1D) and Magnetometer (0x0E) on the micro:bit has been detected by the Pi.</p>
<p>A quick bit of Python on the Pi and the device id of the Magnetometer can be read:</p>
<pre><code class="language-python">#!/usr/bin/python3

import smbus
bus = smbus.SMBus(1)    
dev_addr=0x0e
id=bus.read_byte_data(dev_addr,0x07)
print(hex(id))
</code></pre>
<p>which displays 0xC4, the contents of the read only register at 0x07 on the Magnetometer:</p>
<pre><code class="language-bash">pi@raspberrypi:~ $ python3 test.py 
0xc4
</code></pre>
<p>The result showed that the sensors on the micro:bit can be reached and queried successfully.</p>
<hr>
<p>More reading:</p>
<p><a href="http://tech.microbit.org/hardware/#accelerometer">Accelerometer on the micro:bit</a></p>
<p><a href="http://tech.microbit.org/hardware/#magnetometer">Magnetometer on the micro:bit</a></p>
<p><a href="https://www.youtube.com/watch?v=qeJN_80CiMU">What is i2c</a></p>
<p><a href="https://pinout.xyz/pinout/i2c">i2c pinout on the Pi</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit and searching i2c]]></title><description><![CDATA[If your unsure if the i2c device you have connected up is working then it's a good idea to scan the i2c bus and see whats available.]]></description><link>https://heeed.net/microbit-and-searching-i2c/</link><guid isPermaLink="false">634adfeb5a2d1903e17966aa</guid><category><![CDATA[microbit]]></category><category><![CDATA[i2c]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Tue, 30 Jan 2018 14:44:18 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Whilst this is more of a bookmark for myself it may be handy for others who are playing with the i2c bus.</p>
<p>If your unsure if the i2c device you have connected up is working then it&apos;s a good idea to scan the i2c bus and see whats available.</p>
<p>The following code, from our friends at the <a href="https://microbit-playground.co.uk/howto/scan-i2c-bus">microbit playground</a> will scan the address space and display any discovered devices in REPL.</p>
<pre><code class="language-python">
from microbit import *
start = 0x08
end = 0x77
while True:
    display.show(Image.ARROW_W)
    if button_a.was_pressed():
        display.show(Image.MEH)
        print(&quot;Scanning I2C bus...&quot;)
        for i in range(start, end + 1):
            try:
                i2c.read(i, 1)
            except OSError:
                pass
            else:
                print(&quot;Found:  [%s]&quot; % hex(i))
        print(&quot;Scanning complete&quot;)
        print(&quot;Magnetometer [0x0e] Accelerometer [0x1d]&quot;)
    sleep(10)
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit and the blue micropython]]></title><description><![CDATA[Sending a 'Hello World!' message over bluetooth from micropython on a micro:bit via a HC-06 bluetooth module.]]></description><link>https://heeed.net/micro-bit-and-the-blue-micropython/</link><guid isPermaLink="false">634adfeb5a2d1903e17966a9</guid><category><![CDATA[microbit]]></category><category><![CDATA[micropython]]></category><category><![CDATA[bluetooth]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Sun, 12 Nov 2017 23:29:45 GMT</pubDate><media:content url="https://heeed.net/content/images/2017/11/61RwNwc8P9L._SY463_-1.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2017/11/61RwNwc8P9L._SY463_-1.jpg" alt="micro:bit and the blue micropython"><p>One of the more interestng parts of the micro:bit is the bluetooth module. With this its possible to, amongst over things, flash the device and also control external bluetooth devices.</p>
<p>However due to various technical reasons this built-in Bluetooth functionality is not available when using micropython. However its possible to sidestep this issue by using an external module. In this project a &apos;Hello World&apos; message will be sent over the airwaves to a waiting mobile phone.</p>
<h2 id="thehc0xbluetoothmodules">The HC-0x Bluetooth Modules</h2>
<p><img src="https://heeed.net/content/images/2017/11/61RwNwc8P9L._SY463_.jpg" alt="micro:bit and the blue micropython" loading="lazy"></p>
<p>These inexpensive modules are availiable from multiple sources. The main types in use in the maker community appear to be the HC-05 and HC-06 types. Both types are identical apart from the following points:</p>
<ul>
<li>
<p>The HC-05 module can build a connection to other modules. E.g. a Robot being a master and connecting to slave bluetooth module. Or in slave mode to make a wireless bridge to a notebook.</p>
</li>
<li>
<p>The HC-06 module only can be a slave. This makes it only useful for say connecting a notebook as a master to a robot with a slave module e.g. for a wireless serial bridge.<br>
<a href="https://arduino.stackexchange.com/a/6548">1</a></p>
</li>
</ul>
<h2 id="wiringupthedevice">Wiring up the device</h2>
<p>The HC-06 module is quite happy running on 3.3v that is supplied from the the micro:bit and the message data can be sent via Pin 0 to the Rx pin on the HC-06.<br>
<img src="https://heeed.net/content/images/2017/11/microbithc06.jpg" alt="micro:bit and the blue micropython" loading="lazy"></p>
<h2 id="themicropythoncode">The micropython code</h2>
<pre><code>from microbit import *
uart.init(baudrate=9600, bits=8, parity=None, stop=1,tx=pin0)
while True:
 if button_a.was_pressed():
  uart.write(&apos;Hello World!&apos;) #send hello world
 elif button_b.was_pressed():
  uart.write(bytes([0x0A])) #new line
sleep(100)
</code></pre>
<h2 id="readingthebluetoothconnection">Reading the Bluetooth connection</h2>
<p>With the code flashed and the micro:bit happily sending the message via Bluetooth a way of reading this output is required. This was achieved using a Bluetooth serial terminal app from the Google Play store.</p>
<p>Once this app was installed and paired with the module, the &apos;Hello World!&apos; message was displayed when button A on the micro:bit is pressed.</p>
<p><img src="https://heeed.net/content/images/2017/11/Screenshot_20171112-223603.png" alt="micro:bit and the blue micropython" loading="lazy"></p>
<p>Resources:</p>
<p><a href="https://www.amazon.co.uk/DSD-TECH-HC-05-Pass-through-Communication/dp/B01G9KSAF6">Example of HC-06 on Amazon</a></p>
<p><a href="https://play.google.com/store/apps/details?id=project.bluetoothterminal">Bluetooth Serial Monitor on Google Play</a></p>
<p><a href="https://cdn.instructables.com/ORIG/FX1/N43N/IMXQP4WO/FX1N43NIMXQP4WO.pdf">HC-06 Datasheet</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Robot driving in Leeds...]]></title><description><![CDATA[As normal these things start with receiving an email mentioning that there is this really cool event happening and would you like to take part....]]></description><link>https://heeed.net/robot-driving-in-leeds/</link><guid isPermaLink="false">634adfeb5a2d1903e17966a8</guid><category><![CDATA[microbit]]></category><category><![CDATA[pxt]]></category><category><![CDATA[robots]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Fri, 12 May 2017 22:06:22 GMT</pubDate><media:content url="https://heeed.net/content/images/2017/05/IMG_20170311_133944.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2017/05/IMG_20170311_133944.jpg" alt="Robot driving in Leeds..."><p>As normal these things start with receiving an email mentioning that there is this really cool event happening and would you like to take part. The event is question was the <a href="http://leedsinternationalfestival.com/event/make-believe-inventing-the-tech-of-the-future/">Make:Believe</a> event held at Leeds City Museum as part of the Leeds International Festival.</p>
<p>Joining forces with <a href="https://twitter.com/pragmaticphil">Phil M</a> from the micro:bit educational foundation a plan formed to provide some micro:bit activities. Phil rolled out his awesome micro:bit house to wow the crowds and I deployed the fleet of bit:bots and robo:bits:</p>
<p><img src="https://heeed.net/content/images/2017/05/robobits.jpg" alt="Robot driving in Leeds..." loading="lazy"></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/P73bmdvWZCM" frameborder="0" allowfullscreen></iframe>
<p>To keep it simple a plan was hatched to give the young attendees a chance to drive a robot. This took the form of having the micro:bit in the robot controlled remotely by another micro:bit.</p>
<p>The code from <a href="http://www.multiwingspan.co.uk/micro.php?page=pxtbotcontrol">multiwingspans</a> site was tweaked to allow the user to tilt the controller micro:bit in the direction they wanted to move the robot and to stop by pressing the &apos;a&apos; button.</p>
<p>This worked well in general but got confusing for younger attendees which usually resulted in the bit:bot speeding off in a random direction and requiring to be rescued. The main issue seemed to be pressing the &apos;a&apos; button to stop the robot and not being able to tell what direction was being sent from the controller.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/gnT4uqP5KhQ" frameborder="0" allowfullscreen></iframe>
<p>With this in mind, later that evening, the <a href="https://pxt.microbit.org/">PXT</a> editor was started back up and the code modified to make driving the bit:bot a bit easier.</p>
<p>This time tilting the controller will display what direction the robot is to go and pressing &apos;a&apos; will make the robot move in the direction required. To stop the robot, the controlling micro:bit is held flat.</p>
<h3 id="controllercode">Controller code:</h3>
<p><img src="https://heeed.net/content/images/2017/05/microbit-screenshot.png" alt="Robot driving in Leeds..." loading="lazy"></p>
<pre><code>let x = 0
let robotNumber = 0
let y = 0
basic.forever(() =&gt; {
    y = input.acceleration(Dimension.Y)
    x = input.acceleration(Dimension.X)
    if (y &gt; 400) {
        basic.showLeds(`
            # # # . .
            # . . # .
            # # # . .
            # . . # .
            # # # . .
            `)
        if (input.buttonIsPressed(Button.A)) {
            radio.sendString(&quot;S&quot;)
        }
    } else if (y &lt; -200) {
        basic.showLeds(`
            # # # . .
            # . . . .
            # # # . .
            # . . . .
            # . . . .
            `)
        if (input.buttonIsPressed(Button.A)) {
            radio.sendString(&quot;N&quot;)
        }
    } else if (x &gt; 400) {
        basic.showLeds(`
            # # # . .
            # . . # .
            # # # . .
            # . . # .
            # . . . #
            `)
        if (input.buttonIsPressed(Button.A)) {
            radio.sendString(&quot;R&quot;)
        }
    } else if (x &lt; -200) {
        basic.showLeds(`
            # . . . .
            # . . . .
            # . . . .
            # . . . .
            # # # # .
            `)
        if (input.buttonIsPressed(Button.A)) {
            radio.sendString(&quot;L&quot;)
        }
    } else {
        radio.sendString(&quot;STOP&quot;)
        basic.showNumber(robotNumber)
    }
    basic.pause(40)
})
radio.setGroup(10)
robotNumber = 1
basic.showNumber(robotNumber)
</code></pre>
<h3 id="robotcode">Robot Code</h3>
<p><img src="https://heeed.net/content/images/2017/05/microbit-screenshot--1-.png" alt="Robot driving in Leeds..." loading="lazy"></p>
<pre><code>radio.onDataPacketReceived(({receivedString}) =&gt; {
    if (receivedString == &quot;N&quot;) {
        pins.digitalWritePin(DigitalPin.P0, 1)
        pins.digitalWritePin(DigitalPin.P8, 0)
        pins.digitalWritePin(DigitalPin.P1, 1)
        pins.digitalWritePin(DigitalPin.P12, 0)
    } else if (receivedString == &quot;S&quot;) {
        pins.digitalWritePin(DigitalPin.P0, 0)
        pins.digitalWritePin(DigitalPin.P8, 1)
        pins.digitalWritePin(DigitalPin.P1, 0)
        pins.digitalWritePin(DigitalPin.P12, 1)
    } else if (receivedString == &quot;L&quot;) {
        pins.digitalWritePin(DigitalPin.P0, 0)
        pins.digitalWritePin(DigitalPin.P8, 0)
        pins.digitalWritePin(DigitalPin.P1, 1)
        pins.digitalWritePin(DigitalPin.P12, 0)
    } else if (receivedString == &quot;R&quot;) {
        pins.digitalWritePin(DigitalPin.P0, 1)
        pins.digitalWritePin(DigitalPin.P8, 0)
        pins.digitalWritePin(DigitalPin.P1, 0)
        pins.digitalWritePin(DigitalPin.P12, 0)
    } else if (receivedString == &quot;STOP&quot;) {
        pins.digitalWritePin(DigitalPin.P0, 0)
        pins.digitalWritePin(DigitalPin.P8, 0)
        pins.digitalWritePin(DigitalPin.P1, 0)
        pins.digitalWritePin(DigitalPin.P12, 0)
    }
})
radio.setGroup(10)
basic.showNumber(1)
</code></pre>
<h3 id="furtherinfo">Further info:</h3>
<p>Cool micro:bit stuff can be found <a href="http://microbit.org/">here</a><br>
Robots can be found <a href="http://4tronix.co.uk/store/index.php?rt=product/category&amp;path=91">here</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[A few notes on I2C and the Picon Zero....]]></title><description><![CDATA[General introduction to using the 4tronix Picon Zero with the micro:bit using I2C]]></description><link>https://heeed.net/a-few-notes-on-i2c/</link><guid isPermaLink="false">634adfeb5a2d1903e17966a7</guid><category><![CDATA[microbit]]></category><category><![CDATA[raspberrypi]]></category><category><![CDATA[micropython]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Tue, 04 Apr 2017 22:12:17 GMT</pubDate><media:content url="https://heeed.net/content/images/2020/08/bit2pi.jpeg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://heeed.net/content/images/2020/08/bit2pi.jpeg" alt="A few notes on I2C and the Picon Zero...."><p><a href="https://4tronix.co.uk/store/index.php?rt=product/product&amp;product_id=552">Picon Zero</a> is an Intelligent robotics controller for the Raspberry Pi. A built-in processor handles all the direct communication between the parent controller and any attached devices and motors.</p>
<p>Whilst primarily an add on for the Raspberry Pi, due to it using I2C for communications, it is possible to use it with other small board controllers such as the micro:bit.</p>
<p>This guide will show you the basics and give you a foundation from which to develop further skills.</p>
<p>Also, whilst primarily aimed at use with the PiCon Zero, the techniques can also be used with other HATs or devices that are controlled via i2c.</p>
<h2 id="whatsi2c">Whats i2c?</h2>
<p>I2C is a communication protocol that was created in the eighties by Phillips Semiconductors. It&apos;s normally used for short distance communication between peripheral devices and processors.</p>
<p>At a basic level devices communicate over a 2 wire bus. On each bus there will be a master which controls the other slave devices. Every device on the bus, apart from the master, will have a unique address. These addresses allow the master to talk to individual devices and to instruct them to carry out any functions.</p>
<p>A more detailed explanation can be found here: <a href="https://learn.sparkfun.com/tutorials/i2c">https://learn.sparkfun.com/tutorials/i2c</a></p>
<h2 id="connections">Connections</h2>
<p>As the micro:bit edge connector and the HAT standard are physically incompatible, third party expansion boards are required. Examples of which are as follows:</p>
<ul>
<li>
<p><a href="https://www.kitronik.co.uk/5601b-edge-connector-breakout-board-for-bbc-microbit-pre-built.html">Kitronix micro:bit edge breakout</a> connecting to either a <a href="https://shop.pimoroni.com/products/black-hat-hacker">Pimoroni black hat hack3r</a> board or via the HAT mounted on a breadboard.</p>
</li>
<li>
<p><a href="https://4tronix.co.uk/store/index.php?rt=product/product&amp;product_id=592">4tronix bit:2:pi</a></p>
</li>
</ul>
<h2 id="setup">Setup</h2>
<p>Once everything is connected and the micro:bit is connected to your laptop via USB then start <a href="https://codewith.mu/">Mu</a>.</p>
<p>As we will be using REPL, the first thing we will need to do is flash an empty project onto the micro:bit. This will set up an environment that will allow the &apos;real time&apos; entry of code to the micro:bit.</p>
<h2 id="firststeps">First steps...</h2>
<p>The first thing that needs to be done is to find the i2c address of the PiCon Zero. The documentation shows that this address is <code>0x22</code>.</p>
<p>With this we can now talk to the the PiCon Zero and request it to provide its Board and Software revision numbers. This information is kept in register 0, which is a read only register.</p>
<p>For this value to be read we first need to write the address of the register 0, <code>0x00</code> to the Picon Zero. This will instruct the PiCon Zero to read the contents of register 0 and make them ready for reading. The next command is to read the values from the device.</p>
<p>This can be seen when entering the following code:</p>
<pre><code>from microbit import *
i2c.write(0x22,bytearray([0x00]))
output=i2c.read(0x22,2)
print(output)
</code></pre>
<p>This should result in the following being displayed:</p>
<p><code>b&apos;\x02\x08&apos;</code></p>
<p>The display should now look similar to the following:</p>
<pre><code>&gt;&gt;&gt; from microbit import *
&gt;&gt;&gt; i2c.write(0x22,bytearray([0x00]))
&gt;&gt;&gt; output=i2c.read(0x22,2)
&gt;&gt;&gt; print(output)
b&apos;\x02\x08&apos;
</code></pre>
<p>i2c.write() is the method that writes data onto the i2c bus. It takes three arguments: the address of the target device on the bus, the data that is being sent and if you want to repeat.</p>
<p>i2c.read(), in contrast, reads data from the target device. It also takes three arguments: the address of the target device on the bus, the amount of bytes to be read and if you want to repeat.</p>
<p>As can be seen using devices, on an i2c bus is a case of writing commands and, if required, data and reading the responses generated.</p>
<h2 id="exploringtheregisters">Exploring the registers</h2>
<p>The Picon Zero has the following registers availiable:</p>
<table>
<thead>
<tr>
<th>Register</th><th>Name</th><th>Type</th><th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>MotorA_Data</td>
<td>Byte</td>
<td>-100 (full reverse) to +100 (full forward)</td>
</tr>
<tr>
<td>1</td>
<td>MotorB_Data</td>
<td>Byte</td>
<td>-100 (full reverse) to +100 (full forward)</td>
</tr>
<tr>
<td>2</td>
<td>Output0_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>3</td>
<td>Output1_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>4</td>
<td>Output2_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>5</td>
<td>Output3_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>6</td>
<td>Output4_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>7</td>
<td>Output5_Config</td>
<td>Byte</td>
<td>0: On/Off, 1: PWM, 2: Servo, (3: WS2812B)</td>
</tr>
<tr>
<td>8</td>
<td>Output0_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>9</td>
<td>Output1_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>10</td>
<td>Output2_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>11</td>
<td>Output3_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>12</td>
<td>Output4_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>13</td>
<td>Output5_Data</td>
<td>Byte</td>
<td>Data value(s)</td>
</tr>
<tr>
<td>14</td>
<td>Input0_Config</td>
<td>Byte</td>
<td>0: Digital, 1:Analog, 2:DS18B20, 3:DHT11 (NB. 0x80 is  Digital input with pullup)</td>
</tr>
<tr>
<td>15</td>
<td>Input1_Config</td>
<td>Byte</td>
<td>0: Digital, 1:Analog, 2:DS18B20, 3:DHT11 (NB. 0x80 is  Digital input with pullup)</td>
</tr>
<tr>
<td>16</td>
<td>Input2_Config</td>
<td>Byte</td>
<td>0: Digital, 1:Analog, 2:DS18B20, 3:DHT11 (NB. 0x80 is  Digital input with pullup)</td>
</tr>
<tr>
<td>17</td>
<td>Input3_Config</td>
<td>Byte</td>
<td>0: Digital, 1:Analog, 2:DS18B20, 3:DHT11 (NB. 0x80 is  Digital input with pullup)</td>
</tr>
<tr>
<td>18</td>
<td>Set pixel Brightness</td>
<td>Byte</td>
<td>0 - 255. Scaled max brightness (default is 40)</td>
</tr>
<tr>
<td>19</td>
<td>Update Pixels</td>
<td>Byte</td>
<td>dummy value - forces updating of neopixels</td>
</tr>
<tr>
<td>20</td>
<td>Reset</td>
<td>Byte</td>
<td>dummy value - resets all values to initial state</td>
</tr>
</tbody>
</table>
<p>Read Only Registers</p>
<table>
<thead>
<tr>
<th>Register</th>
<th>Name</th>
<th>Type</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Revision</td>
<td>Word</td>
<td>Low Byte: Firmware Build, High Byte: PCB Revision</td>
</tr>
<tr>
<td>1</td>
<td>Input0_Data</td>
<td>Word</td>
<td>0 or 1 for Digital, 0..1023 for Analog</td>
</tr>
<tr>
<td>2</td>
<td>Input1_Data</td>
<td>Word</td>
<td>0 or 1 for Digital, 0..1023 for Analog</td>
</tr>
<tr>
<td>3</td>
<td>Input2_Data</td>
<td>Word</td>
<td>0 or 1 for Digital, 0..1023 for Analog</td>
</tr>
<tr>
<td>4</td>
<td>Input3_Data</td>
<td>Word</td>
<td>0 or 1 for Digital, 0..1023 for Analog</td>
</tr>
</tbody>
</table>
<p>Values for Output Config Registers</p>
<table>
<thead>
<tr>
<th>Mode</th>
<th>Name</th>
<th>Type</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>On/Off</td>
<td>Byte</td>
<td>0 is OFF, 1 is ON</td>
</tr>
<tr>
<td>1</td>
<td>PWM</td>
<td>Byte</td>
<td>0 to 100 percentage of ON time</td>
</tr>
<tr>
<td>2</td>
<td>Servo</td>
<td>Byte</td>
<td>-100 to + 100 Position in degrees</td>
</tr>
<tr>
<td>3</td>
<td>WS2812B</td>
<td>4 Bytes</td>
<td>0:Pixel ID, 1:Red, 2:Green, 3:Blue</td>
</tr>
</tbody>
</table>
<h3 id="movingamotor">Moving a Motor</h3>
<p>As can be seen in the write only registers, motorA is controlled by register 0, address <code>0x00</code> and motorB controlled by register 1, address <code>0x01</code>.<br>
Each motor can take a value between -100, for full reverse, to +100 for full forward.</p>
<p>To make a motor move the required speed is wrote to the relevant register. For example the following code will make motorA move:</p>
<p><code>i2c.write(0x22,bytearray([0x00,80])</code></p>
<p>and to make it stop:</p>
<p><code>i2c.write(0x22,bytearray([0x00,0])</code></p>
<p>To make the opposite motor move substitute <code>0x00</code> for <code>0x01</code></p>
<h3 id="movingaservo">Moving a Servo</h3>
<p>Using a servo is slightly more involved. By default the bank of GVS pins on the board are turned off and will need to be switched to servo mode to use the servo.</p>
<p>Consulting the list of write registers shows that registers 2 through 7 control what mode each row of GVS pins operate under. The registers that follow, 8 through 13, accept the data that, dependent on mode chosen, is sent via the related GVS pin row. With the following example it is assumed that the servo is connected to Output0.</p>
<p>To start with the Output0_Config has the value 2 wrote to it:</p>
<p><code>i2c.write(0x22,bytearray([0x03,2]))</code></p>
<p>This setups Output0 as a servo control. At any point the <code>2</code> can be replaced by <code>0</code> which will turn the output off.</p>
<p>Once the output has been set up, the servo can have values passed to via register 8, Output0_Data, as follows:</p>
<pre><code>i2c.write(0x22,bytearray([0x08,-90]) #servo fully left
i2c.write(0x22,bytearray([0x08,0])   #servo central
i2c.write(0x22,bytearray([0x08,90])  #servo fully right
</code></pre>
<h3 id="readinganinput">Reading an input</h3>
<p>So far only outputs have been looked at. The PiCon Zero can also be used to read values.</p>
<p>As seen before with using the ouput registers, we first need to configure the the relevant input. The write only registers 14 through 17 are responsible for controlling the configuration of each input.</p>
<p>Once configured correctly, read only registers 1 - 4 will hold the data for reading.</p>
<p>An example of this will be as follows:</p>
<pre><code>#Set Input0_Config to Digital
i2c.write(0x22,bytearray([0x14,0]))

#Start a loop

#write the address of the register to read
i2c.write(0x22,bytearray([0x01]))

#read the selected register
i2c.read(0x22,1))

#increment loop
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[micro:bit and fusion (sort of) power...]]></title><description><![CDATA[An introduction to the Seenov micro:bit solar rechargable battery.]]></description><link>https://heeed.net/microbit_solar/</link><guid isPermaLink="false">634adfeb5a2d1903e17966a6</guid><category><![CDATA[microbit]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Wed, 22 Feb 2017 21:50:04 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>An interesting new accessory appeared on my desk recently in the form of a solar power supply for the micro:bit.</p>
<p>The power supply, designed by <a href="http://www.seenov.com/">Seenov</a>, consists of a rechargeable battery with a associated circuit board and solar cell and provides a regulated output of 3.3 volts. Their aim was to provide a environmentally friendly way of powering a micro:bit to reduce the dependency on single use batteries.</p>
<h2 id="sowhatsinthebox">So whats in the box?</h2>
<ul>
<li>1600mAh Lithium Polymer battery</li>
<li>Control circuit with:
<ul>
<li>Battery Voltage Monitor</li>
<li>Solar Voltage Monitor</li>
<li>Solar Current Monitor</li>
<li>USB charging circuit</li>
<li>Charger on/off</li>
</ul>
</li>
<li>Solar Panel</li>
</ul>
<p>The battery is contained in a small case with the controller circuit attached on top. The solar panel attaches via a JST connector to the board.</p>
<p><img src="https://heeed.net/content/images/2017/02/charger.png" alt="alt" loading="lazy"></p>
<h2 id="inuse">In use...</h2>
<p>For ease of use an old DVD case was press-ganged into service. The solar cell was placed between the case and the cover with the battery and circuit being placed inside the case. To keep the solar cell angled a small straw was used to prop the case open.</p>
<p>Placing on the window ledge with the solar panel facing the sun, a LED lit up showing that power was being generated and the battery was being charged. After a few hours charge a micro:bit was connected which ran the &apos;out of the box demonstration code&apos; function as expected.</p>
<p><img src="https://heeed.net/content/images/2017/02/IMG_20170125_103400.jpg" alt="alt" loading="lazy"></p>
<p>For times when the sun is not sufficient for charging, the charger circuit has a micro USB connection to charge from a USB connection.</p>
<p>The controller circuit breakouts the battery voltage and the voltage and current being supplied from the Solar panel. This allows the monitoring of the state of the power supply via the micro:bit.</p>
<p>The original plan was to connect the micro:bit to a <a href="https://www.bosch-sensortec.com/bst/products/all_products/bme280">BME280</a> i2c weather sensor but the one that was in the spares box appeared to have died and would not respond to any commands. Another one has been ordered and, once arrived, will form the basis of a weather monitoring station.<br>
However using a <a href="http://4tronix.co.uk/store/index.php?rt=product/product&amp;product_id=580">micro:bit playground</a> with the traffic lights posed no problems to the battery.</p>
<h2 id="finalthoughts">Final thoughts</h2>
<p>In essence this is no different to running the micro:bit from two &apos;aaa&apos; batteries but with this you can, as long as there is sunlight, power your micro:bit for nothing. It&apos;s going to be interesting to see what ideas will be thought of and where this solar battery will turn up.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Sometimes you just dont have any internet...]]></title><description><![CDATA[How do you install or update packages when internet connectivity is unreliable?]]></description><link>https://heeed.net/sometimes-no-internet/</link><guid isPermaLink="false">634adfeb5a2d1903e17966a5</guid><category><![CDATA[raspberrypi]]></category><category><![CDATA[mu]]></category><category><![CDATA[sysadmin]]></category><dc:creator><![CDATA[heeed]]></dc:creator><pubDate>Tue, 14 Feb 2017 00:31:46 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>A tweet on twitter led me to this <a href="https://github.com/mu-editor/mu/issues/185">discussion</a> on Github.</p>
<p>The short version of it is that how could you install the Mu editor onto a fleet of Raspeberry Pi in a school classroom environment where the network can not or will not allow them to connect to the wider internet.</p>
<p>One option could be to take the Pi&apos;s home to update but this would get out of hand quite quickly.</p>
<p>Another option would be to use one of the powers of APT. Using this power APT can generate a list of urls for the required packages which can then be downloaded elsewhere.</p>
<h2 id="how">How?</h2>
<ul>
<li>Connect the Pi upto a network connection. This could be a phone hotspot...this is to update the package lists and shouldn&apos;t use a lot of data .</li>
<li>Open a terminal and switch to root.</li>
<li>Type  <code>apt-get update</code> and let the the package lists update</li>
<li>Type <code>apt-get --print-uris --yes upgrade | grep ^&apos; | cut -d&apos; -f2 &gt;downloads.list</code> and press enter. This will generate a list of urls for the required packages and dependencies which are wrote into the downloads.list file. <strong>This only needs to be done on the first Raspberry Pi.</strong></li>
<li>Copy downloads.list onto a USB pendrive or similar.</li>
<li>Take pendrive to system that does have internet access.</li>
</ul>
<hr>
* Connect pendrive and find the downloads.list
* If your using a *nix based system then you can simply use:
<p><code>wget --input-file &lt;path to downloads.list&gt;</code><br>
in the terminal to download the relevant .deb files (Windows users will need to find and alternative to wget).</p>
<p>It&apos;s a good idea to run this in its own directory to contain the downloaded files.</p>
<ul>
<li>Once they have downloaded, copy them back onto the pendrive.</li>
</ul>
<hr>
<ul>
<li>Plug the pendrive back into the Pi and copy the downloaded .deb files into the APT archive: <code>cp  &lt;path to downloaded deb files&gt; /var/cache/apt/archives</code></li>
<li>Re-run <code>apt-get upgrade</code> and the Pi should start to update the packages</li>
<li>Once complete, move the pendrive to the next Pi and copy the files into <code>/var/cache/apt/archives</code> followed by running <code>sudo apt-get update &amp;&amp; sudo apt-get upgrade</code> in the terminal.</li>
</ul>
<p>If your after just a single package then swap:</p>
<p><code>apt-get --print-uris --yes upgrade | grep ^&apos; | cut -d&apos; -f2 &gt;downloads.list</code></p>
<p>for</p>
<p><code>apt-get --print-uris --yes &lt;name of package&gt; | grep ^&apos; | cut -d&apos; -f2 &gt;downloads.list</code></p>
<p>and follow the remaining steps.</p>
<h2 id="furtherinformation">Further Information</h2>
<p>If your lucky enough to be in a situation where the Pi are permanently connected over a wired network then consider the use of <a href="https://pinet.org.uk/">PiNet</a> which allows you to centralise user accounts, file storage and and administration of the Pi.</p>
<p>Extract from <code>man apt-get</code>:</p>
<blockquote>
<p>--print-uris:<br>
Instead of fetching the files to install their URIs are printed. Each URI will have the path, the destination file name, the size and the expected MD5 hash. Note that the file name to write to will not always match the file name on the remote site! This also works with the source and update commands. When used with the update command the MD5 and size are not included, and it is up to the user to decompress any compressed files. Configuration Item: APT::Get::Print-URIs.</p>
</blockquote>
<p><a href="http://www.tuxradar.com/answers/517">Tux Radar article</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>