<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Badger2040 &amp; Badger2040W | Go Education Project</title><link>https://goeducation.net/docs/badger2040/</link><atom:link href="https://goeducation.net/docs/badger2040/index.xml" rel="self" type="application/rss+xml"/><description>Badger2040 &amp; Badger2040W</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>en-us</language><image><url>https://goeducation.net/media/logo.svg</url><title>Badger2040 &amp; Badger2040W</title><link>https://goeducation.net/docs/badger2040/</link></image><item><title>Step-by-step Tutorial</title><link>https://goeducation.net/docs/badger2040/tutorial/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://goeducation.net/docs/badger2040/tutorial/</guid><description>&lt;h2 id="what-you-need"&gt;What you need&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;- Pimoroni Badger2040 or Pimoroni Badger2040W
- Personal computer with Go 1.22 and TinyGo 0.32 installed, and a serial port.
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="hardware-differences"&gt;Hardware differences&lt;/h2&gt;
&lt;p&gt;Badger2040 &amp;amp; Badger2040W are a bit different. The &lt;strong&gt;W&lt;/strong&gt; in Badger2040&lt;strong&gt;W&lt;/strong&gt; is because it has &lt;strong&gt;w&lt;/strong&gt;ifi capabilities. Another difference is that Badger2040 has an USB-C connection, while Badger2040W has a micro-USB.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For the badger2040 you&amp;rsquo;ll need to use &lt;code&gt;--target=badger2040&lt;/code&gt; or &lt;code&gt;-target badger2040&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;For the badger2040W you&amp;rsquo;ll need to use &lt;code&gt;--target=badger2040-w&lt;/code&gt; or &lt;code&gt;-target badger2040-w&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;*Note: If you are participating in the &lt;em&gt;GopherCon US TinyGo HackSession&lt;/em&gt; you probably be using the &lt;strong&gt;badger2040w&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Front side&lt;/p&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="Hardware front"
srcset="https://goeducation.net/docs/badger2040/tutorial/comparision1_hu_11152839c5bd6118.webp 320w, https://goeducation.net/docs/badger2040/tutorial/comparision1_hu_8e9d02a7047d263.webp 480w, https://goeducation.net/docs/badger2040/tutorial/comparision1_hu_385e9a53536f797f.webp 600w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://goeducation.net/docs/badger2040/tutorial/comparision1_hu_11152839c5bd6118.webp"
width="600"
height="267"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Back side&lt;/p&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="Hardware back"
srcset="https://goeducation.net/docs/badger2040/tutorial/comparision2_hu_355cb7fa780bc3d8.webp 320w, https://goeducation.net/docs/badger2040/tutorial/comparision2_hu_4d6411087b110666.webp 480w, https://goeducation.net/docs/badger2040/tutorial/comparision2_hu_3349d9789d655824.webp 600w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://goeducation.net/docs/badger2040/tutorial/comparision2_hu_355cb7fa780bc3d8.webp"
width="600"
height="267"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h2 id="installation"&gt;Installation&lt;/h2&gt;
&lt;h3 id="go"&gt;Go&lt;/h3&gt;
&lt;p&gt;If somehow you have not installed Go on your computer already, you can download it here:&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;Now you are ready to install TinyGo.&lt;/p&gt;
&lt;h3 id="tinygo"&gt;TinyGo&lt;/h3&gt;
&lt;p&gt;Follow the instructions here for your operating system:&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;h2 id="connecting-the-badger2040-to-your-computer"&gt;Connecting the Badger2040 to your computer&lt;/h2&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;&lt;img src="welcome.jpg" alt="welcome to Badger2040" loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;Plug the Badger2040 into your computer using a USB cable while pressing the white BOOTSEL button on the Raspberry Pi Pico. It should appear as a USB mass storage device.&lt;/p&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;&lt;img src="usb.png" alt="usb" loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h2 id="quick-setup"&gt;Quick setup&lt;/h2&gt;
&lt;p&gt;You can follow the instructions at the
webpage to quickly get it working with an image and name of your choice.&lt;/p&gt;
&lt;h2 id="running-the-code"&gt;Running the code&lt;/h2&gt;
&lt;p&gt;The TinyGo programs will run directly on the Badger2040&amp;rsquo;s microcontroller. The procedure is basically:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Edit your TinyGo program.&lt;/li&gt;
&lt;li&gt;Compile and flash it to your Badger2040.&lt;/li&gt;
&lt;li&gt;The program executes from the Badger2040. You can disconnect the Badger2040 from your computer (plug it into a battery, if it isn&amp;rsquo;t already), the program executes directly on the microcontroller.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s get started!&lt;/p&gt;
&lt;h2 id="code"&gt;Code&lt;/h2&gt;
&lt;h3 id="step0go---built-in-led"&gt;step0.go - Built-in LED&lt;/h3&gt;
&lt;p&gt;This tests that you can compile and flash your Badger2040 with TinyGo code, by blinking the built-in LED (it&amp;rsquo;s on the back).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once the Badger2040 is flashed correctly, the built-in LED (on the back) should start to turn on and off once per second. Now everything is setup correctly and you are ready to continue.&lt;/p&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;&lt;img src="step0.gif" alt="step 0" loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h3 id="step1go---built-in-led-a-button"&gt;step1.go - Built-in LED, A Button&lt;/h3&gt;
&lt;p&gt;Run the code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When you press the A button, the built-in LED on the back should turn on.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Challenge:&lt;/em&gt;
See if you can modify
so that the LED turns on if
the &lt;em&gt;B&lt;/em&gt; button is pressed instead of the &lt;em&gt;A&lt;/em&gt; button.&lt;/p&gt;
&lt;h3 id="step2go---display"&gt;step2.go - Display&lt;/h3&gt;
&lt;p&gt;Run the code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step2/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The message &amp;ldquo;Hello Gophers!&amp;rdquo; should appear on the display.&lt;/p&gt;
&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="step4"
srcset="https://goeducation.net/docs/badger2040/tutorial/step2_hu_980f571207358f8e.webp 320w, https://goeducation.net/docs/badger2040/tutorial/step2_hu_b6769bde46645aac.webp 480w, https://goeducation.net/docs/badger2040/tutorial/step2_hu_145faf54d93df8cf.webp 700w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://goeducation.net/docs/badger2040/tutorial/step2_hu_980f571207358f8e.webp"
width="700"
height="432"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h3 id="step3go---display-buttons"&gt;step3.go - Display, Buttons&lt;/h3&gt;
&lt;p&gt;Run the code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step3/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;
&lt;figure &gt;
&lt;div class="flex justify-center "&gt;
&lt;div class="w-full" &gt;
&lt;img alt="step5"
srcset="https://goeducation.net/docs/badger2040/tutorial/step3_hu_3f4183ce2b1c6d9.webp 320w, https://goeducation.net/docs/badger2040/tutorial/step3_hu_953ec3b6245dee94.webp 480w, https://goeducation.net/docs/badger2040/tutorial/step3_hu_29ca1bfaf48350ac.webp 700w"
sizes="(max-width: 480px) 100vw, (max-width: 768px) 90vw, (max-width: 1024px) 80vw, 760px"
src="https://goeducation.net/docs/badger2040/tutorial/step3_hu_3f4183ce2b1c6d9.webp"
width="700"
height="426"
loading="lazy" data-zoomable /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;The display will show some blue circle that represent that buttons on the board.
When a button is pressed a ring will be shown around its corresponding circle.&lt;/p&gt;
&lt;h3 id="step4go---buttons-usb-midi-interface"&gt;step4.go - Buttons, USB midi interface&lt;/h3&gt;
&lt;p&gt;Run the code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step4
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Go to any online midi player with USB capabilities, like
. Make sure the Badger2040 MIDI is enabled (this website works better in Chrome, other browsers might not detect the Badger2040 as a MIDI device). It should identify itself as &lt;em&gt;&amp;ldquo;Badger Drum&amp;rdquo;&lt;/em&gt;.
Press the buttons and create your melody.&lt;/p&gt;
&lt;h3 id="step5go---buttons-usb-hid-interface"&gt;step5.go - Buttons, USB HID interface&lt;/h3&gt;
&lt;p&gt;Run the code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tinygo flash -target badger2040-w ./tutorial/basics/step5
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your Badger2040, connected to a computer, will act as a mouse now. Pressing the A&amp;amp;C buttons will move the cursor horizontally, while up&amp;amp;down arrows vertically. B button will perform a left click.&lt;/p&gt;
&lt;p&gt;Good job in completing the basic tutorials. Now can check out the examples!&lt;/p&gt;
&lt;h2 id="next-steps--ideas"&gt;Next steps &amp;amp; ideas&lt;/h2&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add new effects and animations to the badge code, like Multipass from &lt;em&gt;The fifth element&lt;/em&gt; movie.&lt;/li&gt;
&lt;li&gt;Create your own Rubber Duck attack (examples/rubber-duck).&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="not-powering-up-with-battery-connected"&gt;Not powering up with battery connected&lt;/h1&gt;
&lt;p&gt;While powered by battery, the badger need &lt;em&gt;&lt;em&gt;one click&lt;/em&gt;&lt;/em&gt; on any button to get out of low power mode and start running the code.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Official repository:
&lt;/p&gt;</description></item></channel></rss>