Ciro Santilli OurBigBook.com $£ Sponsor €¥ 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
electronics.bigb
= Electronics
{wiki}

= Electronic
{synonym}

= Alternating and direct current
{parent=Electronics}

= Alternating current
{parent=Alternating and direct current}
{title2=AC}
{wiki}

= Alternating current source
{parent=Alternating current}
{tag=Electronic component}

= AC source
{c}
{synonym}
{title2}

= Hippolyte Pixii
{c}
{parent=Alternating current source}
{wiki}

= Hippolyte Pixiis alternator
{c}
{parent=Hippolyte Pixii}
{title2=1832}

Operated by a hand crank.

\Image[https://upload.wikimedia.org/wikipedia/commons/5/56/Wechselstromerzeuger.jpg]

= Inverter
{parent=Alternating current source}
{title2=DC to AC}
{wiki}

= Direct current
{parent=Alternating and direct current}
{title2=DC}
{wiki}

= DC current
{synonym}

= DC voltage
{c}
{synonym}

= Direct current source
{parent=Direct current}
{tag=Electronic component}

= DC source
{c}
{synonym}
{title2}

= 5v vs 3.3V
{parent=Direct current source}

* https://electronics.stackexchange.com/questions/186353/which-is-better-5v-or-3-3v-as-the-supply-voltage#:~:text=3.3V%20has%20a%20lower,ICs%20still%20target%205V%20systems.
* https://forum.arduino.cc/t/5v-vs-3-3v-really-whats-the-difference/648063

= AC adapter
{parent=Direct current source}
{title2=AC to DC}
{wiki}

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Wall-Wart-AC-Adapter.jpg/1024px-Wall-Wart-AC-Adapter.jpg]

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Notebook-Computer-AC-Adapter.jpg/1024px-Notebook-Computer-AC-Adapter.jpg]

= Coaxial power connector
{parent=AC adapter}
{wiki}

= Polarity symbols
{parent=AC adapter}
{wiki}

Positive center is way more popular: https://gearspace.com/board/electronic-music-instruments-and-electronic-music-production/1222518-center-negative-vs-center-positive-power-supply.html

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Polarity_marking_center_positive.svg/425px-Polarity_marking_center_positive.svg.png]

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/Polarity_marking_center_negative.svg/425px-Polarity_marking_center_negative.svg.png]

= Rectifier
{parent=AC adapter}
{wiki}

= Diode bridge
{parent=rectifier}

= Biasing
{parent=Electronics}
{wiki}

= Bias current
{synonym}

= Bias voltage
{synonym}

= Circuit diagram
{parent=Electronics}
{wiki}

= ASCII art circuit diagram
{c}
{parent=Circuit diagram}
{tag=ASCII art}

* https://github.com/Blokkendoos/AACircuit
* https://hackaday.com/2021/04/29/ascii-schematic-diagrams/
* https://www.qsl.net/yo5ofh/hobby%20circuits/ascii.htm

= Ciro's ASCII art circuit diagram notation
{c}
{parent=ASCII art circuit diagram}

This notation is designed to be relatively easy to write. This is achieved by not drawing ultra complex ASCII art boxes of every component. It would be slightly more readable if we did that, but prioritizing the writer here.

Two wires are only joined if `+` is given. E.g. the following two wires are not joined:
``
  |
--|--
  |
``
but the following are:
``
  |
--+--
  |
``

Simple symmetric components:
* `-`, `+` and `|`: wire
* `AC`: <AC source>. Parameters:
  * `Hz`: frequency
  * `V`: peak voltage
  e.g.:
  ``
  AC_1Hz_2V
  ``
  If only one side is given, the other is assumed to be at a ground `G`.
* `C`: <capacitor>
* `G`: ground. Often used together with `DC`, e.g.:
  ``
  DC_10---R_10---G
  ``
  means applying a voltage of 10 V across a 10 Ohm <resistor>, which would lead to a current of 1 A
* `L`: <inductor>
* `MICROPHONE`. As a multi-letter symmetric component, you can connect the two wires anywhere, e.g.
  ```
  ---MICROPHONE---
  ```
  or:
  ```
  |
  MICROPHONE
      |
  ```
* `SPEAKER`
* `R`: <resistor>
* `SQUID`: <SQUID device>
* `X`: <Josephson junction>

Asymmetric components have multiple letters indicating different ports. The capital letter indicates the device, and lower case letters the ports. The wires then go into the ports:
* `D`: <diode>
  * `a`: anode (where electrons can come in from)
  * `c`: cathode
  Sample usage in a circuit:
  ``
  --aDc--
  ``
  Can also be used vertically like aany other circuit:
  ``
  |
  a
  D
  c
  |
  ``
  We can also change the port order, the device is still the same due to capital `D`:
  ``
  --cDa--

   |
  Dac--

   |
  Dca--

     |
  --caD
  ``
* `DC` <DC source>. Ports:
  * `p`: positive
  * `n`: negative
  E.g. a 10 V source with a 10 Ohm resistor would be:
  ``
  +---pDC_10_n---+
  |              |
  +----R_10------+
  ``
  If only one side is given, the other is assumed to be at a the ground `G`. We can also omit `p` and `m` in that case and assume that `p` is the one used, e.g. the above would be equivalent to:
  ``
  DC_10---R_10---G
  ``
  If the voltage is not given, it is assumed to be a <potentiometer>.
* `T`: <transistor>. The ports are `sgTd`:
  * `s`: source
  * `g`: gate
  * `d`: gate
  Sample usage in a circuit:
  ``
  ---+
     |
  --sgTd--
  ``
  All the following are also equivalent:
  ``
     |
     g
  --sTd--

      |
  --Tsgd--
     |
  ``
* `I`: <electric current> source. Ports:
  * `s`: electron source
  * `d`: electron destination
* `V`: <Voltmeter>. Ports:
  * `p`: positive
  * `n`: negative
  If we don't need to specify explicit positive and negative sides, we can just use:
  ```
  ---V---
  ```
  without any ports. This is notably often the case for AC circuits.

  Optionaly, we can also add the sides as in:

Numbers characterizing components are put just next to each component with an underscore. When there is only one parameter, standard units are assumed, e.g.:
``
+-----+
|     |
C_1p  R_2k
|     |
+-----+
``
means:
* a capacitor with 1 pico Faraday
* a resistor with 2 k Ohms
Micro is denoted as `u`.

Wires can just freely come in and out of specs of a component, they are then just connected to the component, e.g.:
``
DC_10---R_10---G
``
means applying a voltage of 10 V across a 10 Ohm <resistor>, which would lead to a current of 1 A

If a component has more than two parameters, units are used to distinguish them when possible, e.g.:
``
AC_1kV_2MHz
``
means an <AC source> with:
* 1 kV <voltage>
* 1 MHz frequency

= Electronic component
{parent=Electronics}
{wiki}

\Video[https://www.youtube.com/watch?v=byKyJ0b04Lo]
{title=Open Circuits book interview by <CuriousMarc> (2022)}

= Current source
{parent=Electronic component}
{wiki}

= Current-voltage characteristic
{parent=Electronic component}
{wiki}

= I-V curve
{c}
{synonym}
{title2}

= Amplifier
{parent=Electronic component}
{wiki}

= Amplification
{synonym}

Main implementations: the same as <electronic switches>: <vacuum tubes> in the past, and <transistors> in the second half of the 20th century.

\Video[https://www.youtube.com/watch?v=4ObzEft2R_g]
{title=How to make an LM386 audio amplifier circuit by Afrotechmods (2017)}
{description=Builds the circuit on a <breadboard> from minimal components, including one discrete <transistor>. Then plays music from phone through headset cables into a <speaker>.}

= Capacitor
{parent=Electronic component}
{wiki}

The fundamental intuition about capacitors is that they never let <electrons> through.

They can only absorb <electrons> up to a certain point, but then the pushback becomes too strong, and current stops.

Therefore, they cannot conduct <direct current> long term.

For <alternating current> however, things are different, because in alternating current, <electrons> are just jiggling back and forward a little bit around a center point. So you can send alternating current power across a capacitor.

The key equation that relates <Voltage> to <electric current> in the <capacitor> is:
$$
I(t) = C \dv{V(t)}{t}
$$
So if a voltage <Heavyside step function> is applied what happens is:
* the capacitor fills up instantly with an infinite current
* the current then stops instantly
More realistically, one may consider the behaviour or the <series RC circuit> to see what happens without infinities when a capacitor is involved as in the <step response of the series RC circuit>.

\Image[https://upload.wikimedia.org/wikipedia/commons/7/73/IEEE_315_Fundamental_Items_Symbols_%2832%29.svg]

\Video[https://www.youtube.com/watch?v=4PkcOeZCE0g]
{title=Finding Capacitance with an Oscilloscope by Jacob Watts (2020)}
{description=Good experiment.}

= RC circuit
{parent=Capacitor}
{tag=Electronic circuit}

= Series RC circuit
{parent=RC circuit}

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/RC_Series_Filter_%28with_V%26I_Labels%29.svg/250px-RC_Series_Filter_%28with_V%26I_Labels%29.svg.png]

= Step response of the series RC circuit
{parent=Series RC circuit}

This is what happens when you apply a step <voltage> to a <series RC circuit>: TODO $I(t)$ graph.

= Capacitance
{parent=Capacitor}
{wiki}

= Diode
{parent=Electronic component}
{wiki}

Ideally can be thought of as a one-way ticket gate that only lets electrons go in one direction with zero resistance! Real devices do have imperfections however, so there is some resistance.

First they were made out of <vacuum tubes>, but later <semiconductor diodes> were invented and became much more widespread.

= Semiconductor diode
{parent=Diode}
{{wiki=Diode#Semiconductor_diodes}}

\Image[https://upload.wikimedia.org/wikipedia/commons/2/2a/Diode_current_wiki.png]
{title=<I-V curve> of a diode}
{description=This image shows well how the diode is only an approximation of the ideal one way device. Notably, there is this $V_d$ non-ideal voltage drop across the device, which can be modelled as constant. It is however an exponential in fact.}

\Video[https://www.youtube.com/watch?v=Fwj_d3uO5g8]
{title=Diodes Explained by The Engineering Mindset (2020)}
{description=
Good video:
* https://youtu.be/Fwj_d3uO5g8?t=153 how it works
* https://youtu.be/Fwj_d3uO5g8?t=514 applications:
  * protection against accidental battery inversion
  * <rectifiers>, notably mentions a <diode bridge>
}

= Electrical connector
{parent=Electronic component}
{wiki}

= Breakout board
{parent=Electrical connector}
{wiki}

= General-purpose input/output
{parent=Electrical connector}
{wiki}

= GPIO
{c}
{synonym}
{title2}

= Pulse width modulation
{parent=General-purpose input output}

GPIO generally only supports discrete outputs.

But for some types of hardware, like LEDs and some motors, the system has some inertia, and if you switch on and off fast enough, you get a result similar to having an intermediate voltage.

So with pulse width modulation we can fake <analog> output from digital output in a good enough manner.

= Jump wire
{parent=Electrical connector}
{wiki}

Notably used to connect:
* <pin headers>
* <breadboard> holes

You can buy large sets of them in combitation of male/male, male/female, female/female. Male/male is perhaps the most important

\Video[https://www.youtube.com/watch?v=o53uveSmJR0]
{title=Making Jumper Wires by PCBurn! (2018)}

= Pin header
{parent=Electrical connector}
{wiki}

These often come pre-soldered on <devboards>, e.g. and allow for easy access to <GPIO> pins. E.g. they're present on the <Raspberry Pi 2>.

Why would someone ever sell a devboard without them pre-soldered!

\Image[https://upload.wikimedia.org/wikipedia/commons/b/bf/6_Pin_Header.jpg]
{title=6x1 pin header}

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Raspberry_Pi_2_Model_B_v1.1_underside_new_%28bg_cut_out%29.jpg/640px-Raspberry_Pi_2_Model_B_v1.1_underside_new_%28bg_cut_out%29.jpg]
{title=Underside of a <Raspberry Pi 2>}
{description=At the top of this image we can clearly see how the usually pre-soldered <pin header> connectors go through the <PCB> and are soldered on both sides.}

= Jumper
{disambiguate=computing}
{parent=Pin header}
{wiki}

Allows you to connect two adjacent pins of a <pin header>. Sometimes used as a hardware configuration interface!

\Image[https://upload.wikimedia.org/wikipedia/commons/b/b0/Jumper_on_motherboard.jpg]

= Electronic oscillator
{parent=Electronic component}
{wiki}

= Oscillator
{synonym}

Something where <DC voltage> comes in, and a periodic voltage comes out.

\Video[https://www.youtube.com/watch?v=eYVOdlK15Og]
{title=Oscillators: <RC oscillator>[RC], <LC oscillator>[LC], <crystal oscillator>[Crystal] by GreatScott! (2015)}
{description=
Good video. Contains actual <breadboard> experiments on <oscilloscope> and circuit diagrams
* https://youtu.be/eYVOdlK15Og?t=66 <RC oscillator> on <breadboard>. Produces <rectangular wave>. Mentions popular <integrated circuit> that does it: <555 timer IC>.
* https://youtu.be/eYVOdlK15Og?t=175 <LC oscillators> allows for higher frequencies. Produces <sinusoidal> output on <MHz> range. Uses an amplifier to feed back into input and maintain same voltage. Hard to make reliably on breadboard.
* https://youtu.be/eYVOdlK15Og?t=315 <crystal oscillator>. Mentions it acts like an <LC oscillators>. Shows and equivalent model. Wish he had talked more about them. You need support components around it: similarly to the LC case, the amplifier is generally not packaged in.
}

= Relaxation oscillator
{parent=Electronic oscillator}
{wiki}

= RC oscillator
{c}
{parent=Relaxation oscillator}

First watch: <video Oscillators: RC, LC, Crystal by GreatScott! (2015)>

= 555 timer IC
{parent=RC oscillator}
{wiki}

= LC oscillator
{c}
{parent=Relaxation oscillator}

Oscillator made of an <LC circuit>.

First watch: <video Oscillators: RC, LC, Crystal by GreatScott! (2015)>

= Crystal oscillator
{parent=Electronic oscillator}
{wiki}

First watch: <video Oscillators: RC, LC, Crystal by GreatScott! (2015)>

= Light-emitting diode
{parent=Electronic component}
{tag=Light source}
{wiki}

= LED
{c}
{synonym}
{title2}

= Inductor
{parent=Electronic component}
{wiki}

It resists to change in <electric current>. Well seen at: <video LC circuit by Eugene Khutoryansky (2016)>.

= Electromagnetic coil
{parent=Inductor}
{wiki}

= Multiplexer
{parent=Electronic component}
{wiki}

= Resistor
{parent=Electronic component}
{wiki}

= Potentiometer
{parent=Resistor}
{wiki}

= Electrical resistance
{parent=Resistor}
{wiki=Electrical_resistance_and_conductance}

= Ohm
{c}
{parent=Electrical resistance}
{wiki}

= Transformer
{parent=Electronic component}
{wiki}

= Electronic switch
{parent=Electronic component}
{wiki}

= Vacuum tube
{parent=Electronic switch}
{wiki}

= Transistor
{parent=Electronic switch}
{wiki}

A <solid-state> <electronic switch> and <amplifier>.

Although transistors were revolutionary, it is fun to note that they were just "way cheaper and more reliable and smaller" versions of exactly the main functions that a <vacuum tube> could achieve
* <amplifier>
* <electronic switch>

= Point-contact transistor
{parent=Transistor}
{title2=BJT}
{title2=1947}
{wiki}

The first working one in 1947 by <John Bardeen> and <walter Brattain> in <Bell Labs Murray Hill>.

People had already <patented> a lot of stuff before without being able to make them work. Nonsense.

As the name suggests, this is not very sturdy, and was quickly replaced by <bipolar junction transistor>.

= Bipolar junction transistor
{parent=Transistor}
{title2=BJT}
{title2=1948}
{wiki}

By <William Shockley> in 1948 also at <Bell Labs Murray Hill>.

As of 2020, not used anymore in <logic gates>, but still used in <amplifiers>.

\Image[https://upload.wikimedia.org/wikipedia/commons/6/6b/NPN_BJT_%28Planar%29_Cross-section.svg]

= Field-effect transistor
{parent=Transistor}
{title2=FET}
{wiki}

\Image[https://upload.wikimedia.org/wikipedia/commons/4/44/FET_cross_section.svg]

= MOSFET
{c}
{parent=Field-effect transistor}
{title2=1959}
{wiki}

\Image[https://upload.wikimedia.org/wikipedia/commons/4/44/FET_cross_section.svg]

= CMOS
{c}
{parent=MOSFET}
{wiki}

= Voltage transformer
{parent=Electronic component}
{wiki}

= Electronic lab equipment
{parent=Electronics}
{wiki}

\Video[https://www.youtube.com/watch?v=l7OOnv8_m0c]
{title=A Perfect Electronics Bench? by <Keysight> (2021)}

= Arbitrary waveform generator
{parent=Electronic lab equipment}
{wiki}

= Electron multiplier
{parent=Electronic lab equipment}
{wiki}

= Power supply
{parent=Electronic lab equipment}
{wiki}

= Electronic test equipment
{parent=Electronic lab equipment}
{wiki}

= Oscilloscope
{parent=Electronic test equipment}
{wiki}

\Video[https://www.youtube.com/watch?v=yQKuHJELEOs]
{title=FNIRSI 1014D review by Kerry Wong (2022)}
{description=One of the cheapest oscilloscopes available at the time.}

= Digital storage oscilloscope
{parent=Oscilloscope}
{wiki}

= PC-based oscilloscope
{parent=Oscilloscope}
{wiki}

= Cheap oscilloscope
{parent=Oscilloscope}
{wiki}

* https://www.reddit.com/r/ECE/comments/jqfv4f/what_is_the_cheapest_oscilloscope_available_and/

\Video[https://www.youtube.com/watch?v=x19kwG-wJRI]
{title=DIY Oscilloscope Kit (20\$) VS Regular DS Oscilloscope (400\$) by Great Scott (2016)}

\Video[https://www.youtube.com/watch?v=8ts5J09Y7Gc]
{title=Hantek 6022BE Review by Adrian's Digital Basement (2022)}

= Open source oscilloscope
{parent=Oscilloscope}
{tag=Open source hardware}
{wiki}

= Haascope
{c}
{parent=Open source oscilloscope}
{title2=2017}

https://www.crowdsupply.com/andy-haas/haasoscope

By Andy Haas, an experimental <particle physics> professor: https://as.nyu.edu/content/nyu-as/as/faculty/andy-haas.html What an awesome dude!

\Video[https://www.youtube.com/watch?v=tDUg0Q3wInE]
{title=Haasoscope prototype, 2 4-channel boards}

= ScopeFun
{c}
{parent=Open source oscilloscope}
{title2=2020}

* https://www.scopefun.com/

899 USD as of 2022, takes a year to ship as they gather up a lot of orders before producing.

Sounds so cool, especially the multi functionality. Shame so expensive.

= ThunderScope
{c}
{parent=Open source oscilloscope}
{title2=2021}

* https://github.com/EEVengers/ThunderScope
* https://www.crowdsupply.com/eevengers/thunderscope

\Video[https://www.youtube.com/watch?v=TIc-xa1BUYk]
{title=ThunderScope presentation for Hackaday Prize (2021)}

= Electronics vendor
{parent=Electronics}
{tag=Company}

= Hewlett-Packard
{c}
{parent=Electronics vendor}
{title2=1939-2015}
{wiki}

= HP
{c}
{synonym}
{title2}

They do seem to have been very innovative, and have had a very good work culture. They also had a huge impact on the <Silicon Valley> startup scene.

Some products they are known for:
* oscilloscopes
* <Atomic clocks>, notably highly portable ones, see e.g. <video Inside the HP 5061A Cesium Clock by CuriousMarc (2020)>
* pocket calculator

\Video[https://www.youtube.com/watch?v=ppqC0tNghSk]
{title=The decline of <HP> by Company Man (2022)}

\Video[https://www.youtube.com/watch?v=Iqv6DhtLay4]
{title=HP Origins promotional documentary by <HP> (2006)}
{description=A bit too star eyed, but gives some good ideas.}

= HP spinoff
{c}
{parent=Hewlett-Packard}

= Agilent Technologies
{c}
{parent=HP spinoff}
{title2=1999}
{wiki}

In a way, Agilent represents the most grassroots electronics parts of <HP> from before they became overly invested in laptops and fell.

They spun out the electronics part as <Keysight> in 2014, becoming life science only.

= Keysight
{c}
{parent=Agilent Technologies}
{tag=Electronics vendor}
{title2=2014}
{wiki}

= Agilent Technologies oscilloscope
{c}
{parent=Agilent Technologies}

= Hewlett Packard Enterprise
{c}
{parent=HP spinoff}
{title2=HPE}
{title2=2017}
{wiki}

= Philips
{c}
{parent=Electronics vendor}
{wiki}

= Rohde & Schwarz
{c}
{parent=Electronics vendor}
{wiki}

= STAR Cryoelectronics
{c}
{parent=Electronics vendor}

https://starcryo.com/

= Mr. SQUID
{c}
{parent=STAR Cryoelectronics}
{tag=SQUID device}

https://starcryo.com/mr-squid/

This is the cutest product name ever.

\Q[Since 1992, Mr. SQUID has been the standard educational demonstration system for undergraduate physics lab courses.]

Used e.g. at <video Superconducting Quantum Interference Devices by UNSW Physics (2020)}>

Their manual: https://www.phys.ksu.edu/personal/cocke/classes/phys506/squidman.pdf

<YBCO> device, runs on <liquid nitrogen>.

= Electronic circuit
{parent=Electronics}
{wiki}

= Circuit board
{parent=Electronic circuit}

= Breadboard
{parent=Circuit board}
{wiki}

This is how <electronic circuits> are normally prototyped!

Once you validate them like this, the next step is usually to move on to <printed circuit boards> for more reliable production setups.

Breadboards are a thing of beauty and wonder.

\Image[https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Wooden_Breadboard_Circuits.jpg/1024px-Wooden_Breadboard_Circuits.jpg]
{title=<Point-to-point constructions> on woden boards}
{description=Predecessors to <breadboards> from where the name came. A thing of beauty, so vintage. You could actually write stuff on those with a pencil!}

\Video[https://www.youtube.com/watch?v=SI8DGyl0K8E]
{title=Breadboards - Trash or Treasure? by <Keysight> (2020)}

= Printed circuit board
{parent=Circuit board}
{wiki}

= PCB
{c}
{synonym}
{title2}

= Microprocessor development board
{parent=Printed circuit board}
{tag=Computer form factor}
{wiki}

= Devboard
{synonym}
{title2}

= Arduino
{c}
{parent=Microprocessor development board}
{wiki}

= Micro Bit
{c}
{parent=Microprocessor development board}
{title2=2016}
{title2=BBC Micro Bit}
{wiki}

<Zephyr> support: https://docs.zephyrproject.org/2.7.0/boards/arm/bbc_microbit/doc/index.html

<Bluetooth> support: not enough <RAM> for it, though in principle its chip/<transceiver> could support it! https://microbit-micropython.readthedocs.io/en/v1.0.1/ble.html

Supported editors: https://microbit.org/code/

MicroPython web editor and compiler: https://python.microbit.org/v/2

Everything in this section is tested on the <Micro Bit v1> from <ciro-santilli-s-hardware/Micro Bit v1> unless otherwise noted.

Bibliography:
* https://github.com/carlosperate/awesome-microbit

\Image[https://upload.wikimedia.org/wikipedia/en/thumb/a/a3/Micro-bit_v1_%26_v2.JPG/1024px-Micro-bit_v1_%26_v2.JPG]

= Micro Bit simulator
{parent=Micro Bit}

= Micro Bit Python editor
{parent=Micro Bit simulator}

https://python.microbit.org/v/3/reference

= MakeCode Miro Bit
{parent=Micro Bit simulator}

https://makecode.microbit.org

Microbit simulator using some <Microsoft> framework.

TODO the Python code from there does not seem to run on the microbit via `uflash`, because it is not <MicroPython>.

https://support.microbit.org/support/solutions/articles/19000111744-makecode-python-and-micropython explains.

https://forum.makecode.com/t/help-understanding-local-build-options/6130 asks how to compile locally and suggests it is possible. Seems to require <Yotta (build system)>, so presumably compiles?

Presumably this is because Microsoft ported their MakeCode thing to the MicroBit, and the Micro Bit foundation accepted them.

E.g. there toggling a LED:
``
led.toggle(0, 0)
``
but the code that works locally is a completely differently named API `set_pixel`:
``
microbit.display.set_pixel(0, 0, )
``
Microsoft going all in on adopt extend extinguish from an early age!

= Micro Bit getting started
{parent=Micro Bit}

When plugged into <Ubuntu 22.04> via the <USB Micro-B> the <Micro Bit> mounts as:
``
/media/$USER/MICROBIT/
``
e.g.:
``
/media/ciro/MICROBIT/
``
for username `ciro`.

Loading the program is done by simply copying a `.hex` binary into the image e.g. with:
``
cp ~/Downloads/microbit_program.hex /media/$USER/MICROBIT/
``
The file name does not matter, only the `.hex` extension.

The back power light flashes while upload is happening.

Flashing takes about 10-15 seconds for the 1.8 MB scroll display hello world from https://microbit-micropython.readthedocs.io/en/v1.0.1/tutorials/hello.html[]:
``
from microbit import *
display.scroll("Hello, World!")
``
and the program starts executing immediately after flash ends.

You can restart the program by clicking the reset button near the USB. When you push down the program dies, and it restarts as soon as you release the button.

= Compile MicroPython code for Micro Bit locally
{parent=Micro Bit}

* https://stackoverflow.com/questions/73425359/is-it-possible-to-compile-microbit-python-code-locally
* https://stackoverflow.com/questions/52691853/generating-micropython-python-code-hex-file-from-commandline

To use a prebuilt firmware, you can just use `uflash`, tested on <Ubuntu 22.04>:
``
git clone https://github.com/bbcmicrobit/micropython
cd micropython
git checkout 7fc33d13b31a915cbe90dc5d515c6337b5fa1660
uflash examples/led_dance.py
``
What that does is:
* convert the <MicroPython> code to bytecode
* join it up with a prebuilt firmware that ships with uflash which contains the MicroPython interpreter
* flashes that

To build your own firmware see:

Got it working: <Compile MicroPython code for Micro Bit locally on Ubuntu 22.04 with your own firmware>

= Compile MicroPython code for Micro Bit locally on Ubuntu 22.04 with your own firmware
{parent=Compile MicroPython code for Micro Bit locally}

TODO didn't manage from source <Ubuntu 22.04>, their setup bitrotted way too fast... it's shameful even. Until I gave up and went for the magic <Docker> of + https://github.com/bbcmicrobit/micropython[], and it bloody worked:
``
git clone https://github.com/bbcmicrobit/micropython
cd micropython
git checkout 7fc33d13b31a915cbe90dc5d515c6337b5fa1660
docker pull ghcr.io/carlosperate/microbit-toolchain:latest
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest yt target bbc-microbit-classic-gcc-nosd@https://github.com/lancaster-university/yotta-target-bbc-microbit-classic-gcc-nosd
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest make all

# Build one.
tools/makecombinedhex.py build/firmware.hex examples/counter.py -o build/counter.hex
cp build/counter.hex "/media/$USER/MICROBIT/"

# Build all.
for f in examples/*; do b="$(basename "$f")"; echo $b; tools/makecombinedhex.py build/firmware.hex "$f" -o "build/${b%.py}.hex"; done
``

The pre-Docker attempts:
``
sudo add-apt-repository -y ppa:team-gcc-arm-embedded
sudo apt update
sudo apt install gcc-arm-embedded
sudo apt install cmake ninja-build srecord libssl-dev

# Rust required for some Yotta component, OMG.
sudo snap install rustup
rustup default 1.64.0

python3 -m pip install yotta
``

The line:
``
sudo add-apt-repository -y ppa:team-gcc-arm-embedded
``
warns:
``
E: The repository 'https://ppa.launchpadcontent.net/team-gcc-arm-embedded/ppa/ubuntu jammy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
``
and then the update/`sudo apt-get install gcc-arm-embedded` fails, bibliography:
* https://askubuntu.com/questions/732985/force-update-from-unsigned-repository
* https://askubuntu.com/questions/1243252/how-to-install-arm-none-eabi-gdb-on-ubuntu-20-04-lts-focal-fossa

Attempting to install <Yotta (build system)>:
``
sudo -H pip3 install yotta
``
or:
``
python3 -m pip install --user yotta
``
was failing with:
``
Exception: Version mismatch: this is the 'cffi' package version 1.15.1, located in '/tmp/pip-build-env-dinhie_9/overlay/local/lib/python3.10/dist-packages/cffi/api.py'.  When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/usr/lib/python3/dist-packages/_cffi_backend.cpython-310-x86_64-linux-gnu.so'.  The two versions should be equal; check your installation.
``
Running:
``
python3 -m pip install --user cffi==1.15.1
``
did not help. Bibliography:
* https://stackoverflow.com/questions/58552666/exception-version-mismatch-this-is-the-cffi-package-version-1-13-1
* https://github.com/ARMmbed/yotta/issues/289
* https://github.com/pyocd/pyOCD/issues/163
* http://docs.yottabuild.org/#installing-on-linux

From a clean <virtualenv>, it appears to move further, and then fails at:
``
Building wheel for cmsis-pack-manager (pyproject.toml) ... error
error: [Errno 2] No such file or directory: 'cargo'
``
So we install <Rust (programming language)> and try again, OMG:
``
sudo snap install rustup
rustup default stable
``
which at the time of writing was `rustc 1.64.0`, and then OMG, it worked!! We have the `yt` command.

However, it is still broken, e.g.:
``
git clone https://github.com/lancaster-university/microbit-samples
cd microbit-samples
git checkout 285f9acfb54fce2381339164b6fe5c1a7ebd39d5
cp source/examples/invaders/* source
yt clean
yt build
``
blows up:
``
annot import name 'soft_unicode' from 'markupsafe'
``
bibliography:
* https://github.com/aws/aws-sam-cli/issues/3661
* https://stackoverflow.com/questions/72191560/importerror-cannot-import-name-soft-unicode-from-markupsafe

= Program the Micro Bit in C
{c}
{parent=Micro Bit}
{tag=C (language)}

https://stackoverflow.com/questions/73877965/how-to-compile-c-c-code-into-a-hex-file-for-the-bbc-microbit

Official support is abysmal, very focused on <MicroPython> and their graphical UI.

The setup impossible to achieve as it requires setting up the <Yotta (build system)>, just like the impossible to setup <Compile MicroPython code for Micro Bit locally on Ubuntu 22.04 with your own firmware> setup.

So we just use https://github.com/lancaster-university/microbit-samples + https://github.com/carlosperate/docker-microbit-toolchain[]:
``
docker pull ghcr.io/carlosperate/microbit-toolchain:latest
git clone https://github.com/lancaster-university/microbit-samples
cd microbit-samples
git checkout 285f9acfb54fce2381339164b6fe5c1a7ebd39d5

# Select a sample, builds one at a time. The default one is the hello world.
cp source/examples/hello-world/* source

# Build and flash.
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest yotta build
cp build/bbc-microbit-classic-gcc/source/microbit-samples-combined.hex "/media/$USER/MICROBIT/"
``
.hex file size for the hello world was 447 kB, much better than the <MicroPython> hello world downloaded from the website which was about 1.8 MB!

If you try it again for a second time from a clean tree, it fails with:
``
warning: github rate limit for anonymous requests exceeded: you must log in
``
presumably because after Yotta died it started using GitHub as a registry... sad. When will people learn. Apparently we were at 5000 API calls per hour. But if you don't clean the tree, you will be just fine.

= Yotta
{c}
{disambiguate=Build system}
{parent=Micro Bit}

Dead:
* https://yottabuild.org/
* https://github.com/ARMmbed/yotta

= Micro Bit version
{c}
{parent=Micro Bit}

Identification: https://kitronik.co.uk/blogs/resources/explore-micro-bit-v1-microbit-v2-differences The easiest thing is perhaps the GPIO notches.

= Micro Bit v1
{c}
{parent=Micro Bit version}

= nRF51 series
{c}
{parent=Micro Bit}
{wiki}

= Micro Bit example
{c}
{parent=Micro Bit}

* \a[microbit/micropython/uart.py]: the Micro BIt comes with a <UART> simulator via the USB connection, it is very convenient: https://support.microbit.org/support/solutions/articles/19000022103-outputing-serial-data-from-the-micro-bit-to-a-computer To output data to the computer simply use Python `print`. To receive you can e.g. use <GNU screen>:
  ``
  screen /dev/ttyACM0 115200
  ``
  It appears to be very unreliable however, some times it shows up, sometimes it doesn't.

= Micro Bit GPIO
{c}
{parent=Micro Bit}

Pinout overview: https://makecode.microbit.org/device/pins Basically 0, 1, and 2 are the truly generic ones. They can also serve as <ADCs>.

Micropython documentation: https://microbit-micropython.readthedocs.io/en/latest/pin.html

= It is hard to do something useful with a devboard
{parent=Microprocessor development board}
{tag=Essays by Ciro Santilli}

In the 2010's/2020's, many people got excited about getting children in to <electronics> with cheap <devboards>, notably with <Raspberry Pi> and <Arduino>.

While there is some potential in that, <Ciro Santilli> always felt that this is very difficult to do, while also keeping his sacred principle of <backward design> in mind.

The reason for this is that "everyone" already has much more powerful computers at hand: their laptops/desktops and even <mobile phones> as of the 2020s. Except perhaps if you are thing specifically about poor countries.

Therefore, the advantage using such devboards for doing something that could useful must come from either:
* their low cost. This would be an important consideration if you were to mass produce your product, but that is not going to be the case for learners, at least initially.
* their portability, and closely linked their ability to act as sensors
* their ability to act as <actuators>, which is often missing from regular computers
* them having <hardware accelerators> that are not normally present in regular computers, e.g. <FPGAs> or <AI accelerators>. And then the demo project must demonstrate that the project is able to do something significantly faster/cheaper on the devboard than on a desktop computer.

= Devboard battery power
{parent=Microprocessor development board}
{wiki}

Many devborads require a 5V power supply.

This is common on wall transformers and <USB>, but not in <batteries>.

For battery power you need a <transformer>.

\Video[https://www.youtube.com/watch?v=lPyDtuzYE5s]
{title=Raspberry Pi Battery Power by ExplainingComputers (2021)}

= Point-to-point construction
{parent=Circuit board}
{wiki}

= Solder
{parent=Circuit board}
{wiki}

= Digital and analog electronics
{parent=Electronic circuit}

= Analog-to-digital converter
{parent=Digital and analog electronics}
{wiki}

Many/most <microcontroller> boards have <analog-to-digital converters> built into them, it is very convenient. E.g. it is the case for the <Raspberry Pi Pico>.

= ADC
{c}
{synonym}
{title2}

= Open source analog-to-digital converter
{parent=Analog-to-digital converter}
{tag=Open source hardware}

\Video[https://www.youtube.com/watch?v=D28uSzCs7-k]
{title=Open Source 8.5 Digit Voltmeter from <CERN> by <Marco Reps> (2021)}

= Digital-to-analog converter
{parent=Digital and analog electronics}
{wiki}

= DAC
{c}
{synonym}
{title2}

= Digital electronics
{parent=Digital and analog electronics}
{wiki}

= Digital
{synonym}

= Digital electronic circuit
{parent=Digital electronics}

= Frequency divider
{parent=Digital electronic circuit}
{wiki}

= Analog electronics
{parent=Digital and analog electronics}
{wiki}

= Analog
{synonym}

= LC circuit
{c}
{parent=Electronic circuit}
{wiki}

When <Ciro Santilli> was studying electronics at the <University of São Paulo>, the courses, which were heavily inspired from the <USA> 50's were obsessed by this one! Thinking about it, it is kind of a cool thing though.

That https://en.wikipedia.org/w/index.php?title=LC_circuit&oldid=1085148789[Wikipedia page] is the epitome of <it is not possible to teach natural sciences on Wikipedia>[Wikipedia failure to explain things in a way that is of any interest to any learner]. <video Tutorial on LC resonant circuits by w2aew (2012)}> is the opposite.

\Video[https://www.youtube.com/watch?v=hqhV50852jA]
{title=Tutorial on LC resonant circuits by w2aew (2012)}
{description=
* https://youtu.be/hqhV50852jA?t=239 <series LC circuit> on a <breadboard> driven by an <AC source>. Shows behaviour on <oscilloscope> as source frequency is modified. We clearly see voltage going to zero at resonance. This is why thie circuit can be seen as a <filter (signal processing)>.
* https://youtu.be/hqhV50852jA?t=489 shows the <parallel LC circuit>. We clearly see current reaching a maximum on resonance.
}

\Video[https://www.youtube.com/watch?v=XSUiCeCHAvw]
{title=LC circuit dampened oscillations on an oscilloscope by Queuerious Guy (2014)}
{description=Finally a video that shows the oscillations without a driving <AC source>. The dude just move wires around on his <breadboard> manually, first charging the <capacitor> and then closing the LC circuit, and is able to see damped oscillations on the <oscilloscope>.}

\Video[https://www.youtube.com/watch?v=W31CCN_ZF34]
{title=Introduction to LC Oscillators by <USAF> (1974)}
{description=
* https://youtu.be/W31CCN_ZF34?t=740 mentions that <LC circuit> formation is the root cause for <audio feedback> with a quick demo. Not very scientific, but cool.
}

\Video[https://www.youtube.com/watch?v=Mq-PF1vo9QA]
{title=<LC circuit> by <Eugene Khutoryansky> (2016)}
{description=Exactly what you would expect from an <Eugene Khutoryansky> video. The key insight is that the <inductor> resists to changes in current. So when current is zero, it slows down the current. And when current is high, it tries to keep it going, which recharges the other side of the <capacitor>.}

= An LC circuit is analogous to a spring-mass system
{parent=LC circuit}
{tag=spring-mass system}

Both are <harmonic oscillators>.

In the <LC circuit>:
* the current current may be seen as the velocity and containing the <kinetic energy>
* the charge stored in the capacitor as the <potential energy>

You can kickstart motion in either of those systems in two ways:
* charge the capacitor, i.e. pull the string, and then let it go, i.e. close the circuit. This is the simpler one to realise. Shown concretely at: <video LC circuit dampened oscillations on an oscilloscope by Queuerious Guy (2014)}>
* give speed to the mass, i.e. make a current pass through the inductor

= Series LC circuit
{parent=LC circuit}

= Parallel LC circuit
{parent=LC circuit}

= Audio feedback
{c}
{parent=LC circuit}
{wiki}

= RLC circuit
{c}
{parent=LC circuit}
{wiki}

= Soldering
{synonym}

= Heartbeat
{parent=Electronics}
{disambiguate=Computing}
{wiki}

= Semiconductor package
{parent=Electronics}
{wiki}

= Dual in-line package
{parent=Semiconductor package}
{wiki}

= Electrical engineer
{parent=Electronics}

= Electrical engineering
{title2}
{synonym}

= Electronics bibliography
{parent=Electronics}

= Electronics YouTube channel
{parent=Electronics bibliography}

= CuriousMarc
{c}
{parent=Electronics YouTube channel}

https://www.youtube.com/channel/UC3bosUr3WlKYm4sBaLs-Adw

Mostly on vintage electronics. Lots of focus on <microwave>, which he has worked a lot with.

Has been going wild with restoration and reverse engineering of the Apollo moon mission.

\Video[https://www.youtube.com/watch?v=qwocVH3_1Eo]
{title=Inside the WILD Lab of CuriousMarc by <Keysight> Labs (2022)}
{description=
* https://youtu.be/qwocVH3_1Eo?t=841 the <IBM System 360> is insane!
}

= Marc Verdiell
{c}
{parent=CuriousMarc}
{tag=École Polytechnique alumnus}
{tag=Human}
{title2=CuriousMarc}
{title2=Jean-Marc Verdiell}

<Marc Verdiell> is a <human> <electrical engineer> best known for being the creator and host of the <CuriousMarc> YouTube channel.

Marc made \$58.4 from the sale of LightLogic, an <optoelectronics> company he founded, to <Intel> in 2001:
* https://www.courthousenews.com/inventor-barred-from-proceeds-of-intel-buyout/[]. His full name is actualy Jean-Marc Verdiell.
* https://mergr.com/intel-acquires-lightlogic

\Image[https://web.archive.org/web/20230423183349if_/https://lh3.googleusercontent.com/3D9u7fe3v94I-Y8jbrCCTdVHJIOIwum1xFWoxeFcJvA1KfX9YwvHzaXINyrNKJGQ_I5tBMsFnpw2kKX6kAPqd_r2yYB7a85QriBq5-hkf1mN2SYh%3Dw1280]
{title=Marc Verdiell at the <Computer History Museum>}
{description=Location inferred from Marc's videos', but likely, he often frequents the place, and it looks a bit like that.}
{source=https://www.curiousmarc.com/about}

\Video[https://www.youtube.com/watch?v=tJ2-kkhghD4]
{title=Profile of <Marc Verdiell> by Gizmodo (2018)}
{description=
https://youtu.be/tJ2-kkhghD4?t=74 gives his house's location https://en.wikipedia.org/wiki/Atherton,_California[Atherton, California], part of <Silicon Valley>. https://youtu.be/tJ2-kkhghD4?t=279 shows his amazing garden a bit more.

A quick look on <Google Maps> show that that area is full of some incredible mansions. They managed to keep the entire place green, every house has a pool. Wikipedia comments https://web.archive.org/web/20220906010554/https://www.forbes.com/home-improvement/features/most-expensive-zip-codes-us/[]:
\Q[Atherton is known for its wealth; in 1990 and 2019, Atherton was ranked as having the highest per capita income among U.S. towns with a population between 2,500 and 9,999, and it is regularly ranked as the most expensive ZIP Code in the United States \[(94027)\]. The town has very restricting zoning, only permitting one single-family home per acre and no sidewalks. The inhabitants have strongly opposed proposals to permit more housing construction].
and Forbes confirms it for 2022: https://web.archive.org/web/20220906010554/https://www.forbes.com/home-improvement/features/most-expensive-zip-codes-us/[], by far on top.

https://youtu.be/ZgAreiFXhJk?t=253 lists some famous people who live there. It's like a micro heaven.

And a person who makes <open educational content> like Marc, truly deserves it.
}

\Video[https://www.youtube.com/watch?t=580&v=HKsjwT53yXw]
{title=Soyuz Clock Part 4: How accurate is it? by <CuriousMarc> (2020)}
{description=
The timestamp https://youtu.be/HKsjwT53yXw?t=580 mentions that his wife is called "Laurie", and that she escaped the <Soviet Union>, and two of her brothers went to jail in the escape process.
}

= Marco Reps
{c}
{parent=Electronics YouTube channel}

https://www.youtube.com/c/MarcoReps

This mostly faceless German dude is awesome!