In the 1970s an uncle of mine spent t-h-o-u-s-a-n-d-s of dollars on audio equipment. High end speakers, valve amplifiers, turntables, tape decks, etc., etc.
I was in awe, and the sound was so amazing as to be akin to a religious experience. He was so into it that he paid for an audio engineer to come in and "ping" his lounge room so that the speakers could be precisely placed in the exact spots to eliminate any dead zones.
Of course his wife shifted them that afternoon due to her interior design concerns. They are not married anymore - coincidence?
Fast forward to 2024 and his nephew (that's me!) has just bought a TDA7297 based amplifier from AliExpress coming in at the princely sum of AU$2.57. Embarrassing - and even more so because it doesn't seem to work.
Or does it?
Also, a colleague at work handed over some ear pod thingies that weren't going the distance in terms of charging - I have no idea what to do to help, and there is now video evidence of that fact!
This is not electronics but a weird combination of coding and mathematics! Young children look away now.
Some time ago I thought it might be useful to look for patterns in primes because, well, it's like a mountain to climb! If it's there then you gotta do it.
Also there has been a LOT of work done in this field before.
So during a lull in my holidays (?), and after attending a math conference recently, I decided to start a coding journey that examines the position of primes in geometric patterns for both squares and hexagons.
Here's the square version:
from math import sqrt
from turtle import *
xrow = 10
ycol = 11
count = 2
squaresize = 4
tracer(False)
speed("fastest")
pendown()
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
returnFalsereturnTruedef makesq():
forward(squaresize)
right(90)
forward(squaresize)
right(90)
forward(squaresize)
right(90)
forward(squaresize)
right(90)
forward(squaresize)
returndef turn():
right(90)
forward(squaresize)
return
fillcolor("red")
begin_fill()
makesq() # 1 is not prime
end_fill()
fillcolor("blue")
while(count < 25000):
for laying in range(1,xrow):
if(isPrime(count)):
begin_fill()
makesq()
end_fill()
count = count + 1
turn()
for laying in range(1,ycol):
if(isPrime(count)):
begin_fill()
makesq()
end_fill()
count = count + 1
turn()
xrow=xrow+1
ycol=ycol+1
update()
And here is the more interesting hexagon version.
from math import sqrt
from turtle import *
import os
from turtle import Screen, Turtle
height = 900
width = 900
screen = Screen()
screen.setup(width, height)
short = 1global count
count = 1
hexsize = 10
turnarray = [4,3,3,3,3,2,3]
#tracer(False)
speed("fastest")
pendown()
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
returnFalsereturnTruedef makehex(sides):
for making in range(0,sides):
forward(hexsize)
right(60)
return
fillcolor("red")
begin_fill()
makehex(6) # 1 is not prime
end_fill()
makehex(2) # 1 is not prime
left(120)
count = count + 1
fillcolor("blue")
def turn():
global count
if(isPrime(count)):
begin_fill()
makehex(6)
end_fill()
makehex(3)
left(120)
count = count + 1returndef straight(numhex):
global count
for length in range(0,numhex):
if(isPrime(count)):
begin_fill()
makehex(6)
end_fill()
makehex(2)
left(120)
count = count + 1returnwhile(count < 9):
if(isPrime(count)):
begin_fill()
makehex(6)
end_fill()
makehex(turnarray[count-2])
left(120)
count = count + 1for layer in range(1,65):
for sides in range(0,4):
turn()
straight(layer)
turn()
straight(layer+1)
turn()
straight(layer)
update()
Now I'm keen to "fold" the shapes and have a look at the 3D possibilities - anyone with me?
The next phase of the NiMH replacement project is to test if a Super Capacitor can power a PFS154 through the night - pumping out candley goodness via it's three PWM channels.
Since the last video and blog I have continued to work on the code - a subscriber picked up a SNAFU from the last video, and as well I am not yet convinced that the PFS154 is sleeping.