Silicon ChipMax’s Cool Beans - April 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: DIY Solder ReFLow Oven with PID Control by Phil Prosser
  11. Project: Programmable Thermal Regulator by Tim Blythman and Nicholas Vinen
  12. Project: Frequency Reference Signal Distributor by Charles Kosina
  13. Feature: KickStart by Mike Tooley
  14. Feature: Max’s Cool Beans by Max the Magnificent
  15. Feature: Max’s Cool Beans cunning coding tips and tricks by Max the Magnificent
  16. Feature: AUDIO OUT by Jake Rothman
  17. Feature: Circuit Surgery by Ian Bell
  18. Feature: Make it with Micromite by Phil Boyce
  19. PCB Order Form
  20. Advertising Index

This is only a preview of the April 2021 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • Techno Talk (September 2020)
  • Techno Talk (September 2020)
  • Techno Talk (October 2020)
  • Techno Talk (October 2020)
  • (November 2020)
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
  • Techno Talk (June 2025)
Max’s Cool Beans By Max the Magnificent Flashing LEDs and drooling engineers – Part 14 A ssuming you’ve been following my recent columns (and, if not, why not?), you will recall my abject failure thus far to make good on my promise to implement a version of Conway’s Game of Life (GOL) (https://bit.ly/pe-jan21-cgol) on my 12×12 ping-pong ball array (https://bit.ly/3jMM62J). Well, it’s almost time to don our party hats and blow our party horns (https://bit. ly/2MFwwJL) with gusto, abandon, and – I’m sure it goes without saying (but I’ll say it anyway) – aplomb, because that’s what we are poised to do (… in my next column), but first let’s consider... The Big Bang The term ‘multiverse’ (a.k.a. ‘meta-universe’) refers to a hypothetical group of multiple universes. Together, these universes are postulated to comprise everything that exists: the entirety of space, time, matter, energy, information, and the physical laws and constants that describe them. By comparison, the term ‘Big Bang’ refers to a part of a cosmological model of the observable part of our own particular universe from the earliest known periods through to its subsequent large-scale evolution. When I was a young lad and I first heard about the Big Bang, which kicked off our portion of the multiverse around 9:00am on a Wednesday morning about 13.8 billion years ago – give or take – I visualised it as a giant explosion with everything radiating out from a central location. Later, I discovered that all of the galaxies are moving away from each other, apart from the ones that aren’t, of course. By this I mean that some galaxies are close enough to each other that their local proximity and gravitational attraction (as described by Sir Isaac Newton in his law of gravitation) or distortion of the spacetime continuum (as revealed by Albert Einstein with his theory of general relativity) is sufficient to draw them together. For example, our own galaxy – the Milky Way – is scheduled to collide with our nearest neighbour – the Andromeda galaxy – about four billion years from now. Be that as it may, when I was first exposed to all of this, my newfound knowledge caused me to visualise all of the galaxies as being dots marked on the surface of a balloon on the basis that, as a balloon is inflated, all of the dots will move apart from each other. Still later, I was introduced to a different analogy – one that involved a three-dimensional (3D) volume as opposed to a two-dimensional (2D) surface – that of a ball of bread dough with raisins mixed throughout. When the dough is baked in an oven, it will grow in size and – as a result – all of the raisins will move apart from each other. G alaxy E dge of the universe (a) K eep on trucking Start (b) B ouncing off the edge Fig.1. The edge of the universe (eeek!) 46 R ocket F light path (c) Curved spacetime Still and all, this left me with the impression that there was a ‘centre’ to the Big Bang. That is, if we could determine where all of the galaxies were moving away from, we could backtrack and locate where everything originated. Sad to relate, this appears not to be the case, because those researchers and scientists with size-16 brains (the ones with ‘go-faster’ stripes painted on the sides) say, ‘The galaxies are not moving through space, they are moving with space, because space itself is also expanding, which means the universe has no centre and everything is moving away from everything else.’ I don’t know about you, but I have a sneaking suspicion they are making some of this stuff up as they go along. Don’t fall off the edge! This is where things start to get confusing because, much like Pooh, I am a bear of little brain. If the universe is expanding, what is it expanding into? Is there an ‘edge’ to the universe and, if so, what lies beyond? Can you imagine what it would be like to live on a planet orbiting a star that inhabits a galaxy at the very edge of the universe? Would this mean that if you were to look one way (ie, toward the centre of the Big Bang), you’d see a cornucopia of galaxies, but if you were to look the other way, all you’d see is a whole lot of nothing? If so, what sort of nothing would that be? Even if it’s empty ‘nothing,’ that’s still ‘something,’ isn’t it? These are the types of questions that keep me awake at night. Thank goodness for the Dried Frog Pills (https://bit.ly/3nRr6IH), is all I can say. Assuming for the purpose of discussion that there is, in fact, an edge to the universe. What would happen if you were born there and you decided to build a spaceship – I’d like mine to be reasonably-sized, well equipped with bathrooms, and sleek without being pretentious; perhaps a craft reminiscent of the Millennium Falcon – and you headed out into the great beyond? Three main possibilities spring to mind. The first is that you just keep on trucking, ‘Bravely going behind the beyond, behind which no man (or woman) has bravely gone behind, beyond, before,’ as Captain James T. Kirk might have said in dulcet tones (Fig.1a). The second is that you somehow ‘bounce off’ the edge of the universe and head back towards the light (Fig.1b). The third is that the spacetime continuum is ‘curved’ in such a way that you eventually find yourself back where you started, which – assuming we could walk on water – we might visualise as being a tortuously time-consuming 3D hyperspatial version of taking a stroll around the Earth (Fig.1c). As an aside, there’s an old brainteaser that just popped into (what I laughingly call what’s left of) my mind. In my previous Cool Beans (PE, March 2020) I posed the question, ‘How long is a piece of string?’ (the answer, of course, is: ‘Twice as long as from the middle to one end’). Well, imagine the edge of the universe as being like a spherical shell that we could stand on, with ‘down’ being towards the centre. Next, suppose we have a long piece of string called A that we wrap all the way around the circumference of this shell. Finally, suppose we have a humongous collection of one-meter-tall posts that we plant vertically all around the circumference, after which we wrap a second piece of string called B around the top of the Practical Electronics | April | 2021 posts (Fig.2). (Also assume we are using an infinite number of posts such that G alaxy string B also follows a truly 1 m P ost circular path.) String A The diameter of the obString B servable universe (the part we can see) is approximately 93 billion light years (the distance light travels in one Fig.2. A knotty problem. year in a vacuum), while the unobservable universe (the part we can’t see) stretches beyond that. Just for giggles and grins, let’s suppose our ‘shell’ is 100 billion light years in diameter. Also, as a bonus, I’ll save you some time by telling you that one light year equates to approximately 9,500,000,000,000,000 (ie, 9.5×1015) meters. So, how much longer will string B be than string A? (You can find answer at the end of this column.) Keep on trucking it reaches the edge of the universe (one of the sides of our array). At this point, we will extinguish the spaceship pixel and simply pretend it’s heading out into the great beyond (Fig.3a). Otherwise, if we were to allow our program to attempt to write to pixels outside of our array, it would end up tramping roughshod through our processor’s memory map leaving havoc in its wake. Once our spaceship has exited the universe, we will pause for a short time, and then repeat the process, each time selecting a new random colour and a new random direction. The full sketch (program) for our keep-on-trucking scenario is presented in file CB-Apr21-01.txt (it and any other files associated with this article, are available on the April 2021 page of the PE website https://bit.ly/3oouhbl). We won’t go through the entire sketch here, but there are a few things worth noting, such as the fact that we define a new type in the form of a structure we call ShipDataDefinition, where ‘Ship’ refers to our imaginary spaceship (we introduced the concepts of typedef (type definitions), enum (enumerated types), and struct (structures) in Tips and Tricks, PE, December 2020). As you may recall, over the past year we’ve devoted a large number of Cool Beans columns to performing experiments with my 12×12 ping-pong ball array, where each ball is equipped with a tricolour LED in the form of a WS2812 (these devices are also commonly known as ‘NeoPixels’). We think of this bodacious beauty as comprising 12 columns (the X-axis) and 12 rows (the Y-axis), both numbered from 0 to 11, with pixel [X,Y] = [0,0] located in the bottom left-hand corner as we face the array. As an aside, we introduced the concepts of additive, subtractive, primary, secondary and tertiary colours in an earlier column (PE, September 2020). For the purposes of these experiments, in addition to black (all off) and white (all on), we are going to restrict our colour palette to three primary colours (red, green, blue) and their corresponding secondary colours (yellow, cyan, magenta). Also, since we will always be driving our LEDs full on in these trials, we won’t need to worry about applying a gamma correction fiddle factor (PE, January 2021). So, how can we replicate the aforementioned ‘Keep on trucking’ scenario with our array? Well, purely for the sake of argument, let’s assume that the centre of our ping-pong universe is located at pixel [6,5]. What we are going to do is randomly select a colour from our six primary-secondary palette and light up the pixel at the centre of the universe. This is going to be our spaceship. Next, we are going to pick a random direction out of eight possibilities – N, S, E, W, NE, NW, SE, and SW – and we are going to make our spaceship move in that direction until Start typedef struct ShipDataDefinition { int shade; int x; int y; int deltaX; int deltaY; }; On the off chance you were wondering, the reason we use the name shade rather than color is that the latter is already defined and used for some other purpose in the Arduino IDE. Next, we declare a variable called ShipData that’s of type ShipDataDefinition. As part of this declaration, we assign default values to the members of the structure. ShipDataDefinition ShipData = { .shade = COLOR_BLACK, .x = 6, .y = 5, .deltaX = 0, .deltaY = 0 }; Why did we set shade to COLOR_BLACK? Well, when we come to generate the colour for a new spaceship, we are going to keep on generating random values until the new colour is different to the old one, so initialising the old colour to be black F light P ath b1 11 11 11 10 10 10 9 8 8 8 7 7 a2 6 6 6 5 5 5 4 4 4 3 3 3 2 2 2 1 1 1 0 0 R ows (Y ) 9 0 1 2 3 4 5 6 7 Columns (X ) 8 9 10 (a) K eep on trucking. 11 9 a1 0 0 1 2 3 4 5 6 7 8 (b) B ouncing offf the edge. 9 10 11 0 1 2 b2 4 5 6 7 8 9 10 11 (c) Curved spacetime. Fig.3. Travelling in a ping-pong universe. Practical Electronics | April | 2021 47 as part of the variable declaration means that any colour we generate for our very first ship will be acceptable. As we discussed earlier, we are assuming that the centre of our ping-pong universe is located at pixel [6,5], which explains the x = 6 and y = 5 assignments above. We will be assigning new values to deltaX and deltaY later. The reason we set them to 0 as part of the declaration was for completeness and to remind ourselves that they are there. The rest of the program is reasonably self-explanatory; the only other thing of note is when we generate a random direction for our spaceship: do { } tmpX = random(-1,2); tmpY = random(-1,2); while( (tmpX == 0) && (tmpY == 0) ); ShipData.deltaX = tmpX; ShipData.deltaY = tmpY; As discussed in this month’s Tips and Tricks, the Arduino’s random() function returns a pseudo-random integer between the set specified by the minimum and maximum values (which are defined as –1 and +2, respectively, in this example). The trick is that the minimum value is ‘inclusive’ (ie, included in the set) while the maximum value is ‘exclusive’ (ie, excluded from the set), which means that random(-1,2) will return a random value of –1, 0, or +1. What we are going to do is loop around repeatedly, adding these deltaX and deltaY values to our main x and y values, thereby guiding our spaceship on its designated trajectory. We can accept any combination of deltaX = –1 or 0 or +1 and deltaY = –1 or 0 or +1, except the case when they are both 0, because in that case the ship wouldn’t be going anywhere. This explains the test associated with the while(), which means we will keep on generating new random values until we have any combination other than both tmpX and tmpY being 0. As an aside, there’s nothing in our current code to prevent the direction of the new spaceship being the same as that of the previous ship. We could easily extend the test associated with the while() to check for this if we wished. Why don’t you jot down your ideas for such a test now? – I’ll reveal one possibility at the end of this column. In this scenario, our ship will keep on moving until it reaches one of the sides of the array, at which point we will return the pixel to black and pretend the ship is still trucking on its merry way outside of the array. Bouncing off the edge Our next scenario is when the ship bounces of the edge of the universe. The way the bounce works depends on the direction the ship is travelling when it hits the side of the array. For example, if the ship starts off travelling to the right (East), then when it hits the side it will bounce back to the left (West), and it will continue to ricochet back and forth between these two sides. Similarly, if the ship starts off travelling up (North), then when it hits the edge it will bounce back down (South), and it will continue to ricochet between these two sides. A third alternative is when the ship starts off travelling at a 45degree angle, say North-East, in which case its path will be an inclined rectangle (Fig.3b). Looking ahead to our curved spacetime future, what we are going to do in this current scenario is create six spaceships, each with a different colour. The first will start off heading North, the second South, the third East, the fourth West, the fifth North-East, and the sixth South-West. In this case (noting that NUM_SHIPS is defined as being 6), 48 we can declare and initialise our six spaceships as an array as follows: ShipDataDefinition ShipData[NUM_SHIPS] = { // Assignments go here }; If you look at the full program (file CB-Apr21-02.txt), you’ll observe that the deltaX and deltaY fields associated with ships #1 through #6 are assigned appropriate –1, 0, +1 values required to achieve the desired directions: #1 deltaX = 1, deltaY = 0 #2 deltaX = -1, deltaY = 0 #3 deltaX = 0, deltaY = 1 #4 deltaX = 0, deltaY = -1 #5 deltaX = 1, deltaY = 1 #6 deltaX = -1, deltaY = -1 As you’ll see, the work we’ve done in defining things like our ShipData[] array really starts to pay off here because the body of our program that makes the six ships fly around our pingpong ball array is surprisingly compact and easy to understand. One thing you might observe is that each time round the loop, before we calculate and display their new positions, we first set the colour of all the current spaceship locations to black. The reason for this is that our program isn’t very sophisticated, and the ships are unaware of each other’s positions. If we weren’t careful, we might display the new location of ship A on top of the old position of ship B, and then set the old position of ship B to be black. Setting all of the old locations to black first addresses this problem. If we wished to get really clever, our program could keep track of the positions of all of the ships and, if two or more found themselves in the same location, we could set the colour of that pixel to be a merged value of the various ship colours, but things are happening so fast that this really isn’t worth the effort. The key thing to note in this scenario is that, when one of our spaceships hits a side, we will negate the appropriate delta value. For example, if a ship is heading East (deltaX = 1, deltaY = 0), then when it hits the side, we will change deltaX to be -1, which will cause that ship to start heading West. Similarly, if a ship is heading South (deltaX = 0, deltaY = -1), then when it hits the side, we will change deltaY to be +1, which will cause that ship to start heading North. Curved spacetime Finally, we come to consider our curved spacetime scenario. This can be a little difficult to wrap one’s brain around at first, so let’s take things stepby-step. Suppose our spaceship commences heading East. In this case, we can imagine our universe (in the form of our ping-pong array) being curled into a vertical cylinder such that the right-hand side is joined to the left-hand side. What this means is that, when our ship reaches the right-hand side, it will disappear and reappear – still moving East – on the same row at the left-hand side. Want to build your own By comparison, if our ship amazing ping-pong ball array? commences heading South, All the details are in previous we can imagine our universe Cool Beans columns, starting being curled into a horizontal in March 2020. Practical Electronics | April | 2021 N U M _ X Y = 12 M AX _ X Y = (N U M _ X Y – 1) 0 1 2 (P ixel + M 1) % 3 4 N U M _ X Y 5 P 1 = (N U M _ X Y + 1) (“ P lus O ne” ) M 1 = M AX _ X Y (“ M inus O ne” ) 6 P ixel = 6 7 8 9 (P ixel + P 1) % 10 11 N U M _ X Y Fig.4. Single versus multiple drips. cylinder such that the upper side is joined to the lower side. In this case, when our ship reaches the lower side, it will disappear and reappear – still moving South – on the same column at the upper side. When you feel comfortable with this, consider what will happen if our ship commences at location [7,3] heading in a North-East direction (Fig.3c). When it reaches the right-hand edge at location a1, it will reappear one column to the ‘right’ (ie, on the left-hand edge) and one row higher at location a2, still travelling in a North-East direction. One way to think about this is if, just as the ship reaches the right-hand edge at [11,7], we were to split the array into two vertical halves, each six pixels wide. We then move the left-hand half to the right of the right-hand half, if you see what I mean. Similarly, when the ship reaches the upper edge at location b1, it will reappear one row ‘higher’ (ie, on the lower edge) and one column to the right at location b2, still travelling in a North-East direction. One way to think about this is if, just as the ship reaches the upper edge at [3,11], we were to split the array into two horizontal halves each six pixels tall, and then move the upper half to be underneath the lower half. In order to ensure everything works as we desire, let’s once again create six spaceships, each with a different colour, commencing with headings of North, South, East, West, North-East, and South-West, respectively. The first point to note is that we can’t use delta values of –1 and +1 to move left or right, or up or down, respectively, because doing so would cause chaos and confusion when a ship arrived at one of the edges. The solution is to use variations of the modulo operations we discussed in my previous column (PE, March 2021). Purely for the purposes of providing an example, consider a single row of 12 ping-pong balls numbered left-to-right from 0 to 11. Now assume we are looking at pixel 6 (Fig.4). As we know, the modulo operator returns the integer remainder from the division of two integer numbers. The number of pixels we have in a row (or column) is 12 (NUM_XY) numbered from 0 (MIN_XY) to 11 (MAX_XY). As we see in the figure, we define P1 (‘Plus One’) to be (NUM_XY + 1) = 13, while M1 (‘Minus One’) is defined as being MAX_XY = 11. So, if we are looking at Pixel = 6, the pixel to the right will be (Pixel + P1) % NUM_XY, which equates to (6 + 13) % 12 = 19 % 12 = 7. Similarly, the pixel to the left will be (Pixel + M1) % NUM_XY, which equates to (6 + 11) % 12 = 17 % 12 = 5. Try performing the same calculations with starting pixel numbers of 0 and 11, which represent our boundary conditions, and you’ll see that everything works out the way we wish. All I can say is ‘Tra-la!’ (and I mean that most sincerely). Now, this is where things become very interesting because we can quickly and easily tweak our previous code to address this new scenario. If you look at the full sketch (file CB-Apr21-03. txt), you will see that we start by modifying the deltaX and deltaY values in our ShipData[] declaration as follows: #1 deltaX = P1, deltaY = 0 #2 deltaX = M1, deltaY = 0 #3 deltaX = 0, deltaY = P1 #4 deltaX = 0, deltaY = M1 #5 deltaX = P1, deltaY = P1 #6 deltaX = M1, deltaY = M1 The really cool stuff becomes obvious when we come to moving our ships. As you’ll see, we no longer have to perform tests to detect any boundary conditions because our spacetime is curved and the ships don’t even see the edges of the universe. If you are interested, I just created a video showing everything we’ve discussed here in glorious technicolor action – just visit: https://bit.ly/3dLdHAB. Conway’s Game of Life I know, I know… At the end of my previous column, I said that we would implement Conway’s Game of Life (GOL) in this column ‘or my name’s not Max the Magnificent!’ Well, I was right, because my name isn’t Max the Magnificent – that’s just what people call me (in my dreams). The thing is, we are going to run into the same ‘Edge of the Universe’ problems with the GOL and – now that we know how to address those issues – we are quivering in anticipation ready to rock and roll. Until next time, have a good one! The solution to our while() conundrum In our keep-on-trucking scenario, the test associated with our while() statement was ((tmpX == 0) && (tmpY == 0)), which says we will keep on generating new random values for tmpX and tmpY until we have any combination other than both of them being 0. Now, suppose we wish to enhance this test such that we also keep on generating new random values for tmpX and tmpY until at least one of them differs from their previous values, which are currently stored in deltaX and deltaY, respectively. We could achieve this part of the test using: ((tmpX == deltaX) && (tmpY == deltaY)) The way to think about this is that we wish to keep on generating new random values so long as either of these sub-tests returns true; that is, if the first test returns true OR the second test returns true. One way to achieve this would be to use: while( ((tmpX == 0) && (tmpY == 0)) || ((tmpX == deltaX) && (tmpY == deltaY)) ); The solution to our knotty problem I have a bit of a confession to make. The reason I was waffling on about the diameters of the observable and unobservable universes and the number of meters in a light year was to throw you off the scent. In reality, the difference in the lengths of strings A and B will be the same, irrespective of the diameter of the universe. How can this be? Well, the circumference of a circle is given by 2 r. Let’s say that the radius of our shell is (x) meters, which means the length of string A will be 2 x meters. Since we are using 1m posts, this means, the radius of the circle defined by string B will be (x + 1) metres. In turn, this means the length of string B will be 2 (x + 1) metres, which equals 2 x + 2 . Since the length of string A was 2 x metres, this means that the differCool bean Max Maxfield (Hawaiian shirt, on the right) is emperor ence in length of string B will be 2 x + 2 – of all he surveys at CliveMaxfield.com – the go-to site for the 2 x = 2 metres (ie, approximately 6.28m) latest and greatest in technological geekdom. longer. This is true for a 10m-radius ball, Comments or questions? Email Max at: max<at>CliveMaxfield.com the Earth or the entire observable universe! Practical Electronics | April | 2021 49