Hey, Ben.
Hey Matt.
How are you doing?
Great.
Great to hear. So I know that one of the things that you do when you're not writing tests is build cool things.
Uh, I try to.
You you've shared with us at work, a video of one of the coolest things I've ever seen, which is a, tell us what you built
An automated candy dispenser.
Why would you build such a thing? What on earth, what's the reason for such a thing.
Yeah, well, so I used to live in a neighborhood in Chicago. I still live in Chicago, but I live in a different neighborhood now, but I used to live in a neighborhood that was absolutely bonkers on Halloween.
Is bonkers a word that you as an American would use, or are you saying it because you've hung around with me too long?
No, I'm saying it, cause I'm looking at you and I'm like, what's the right word here? When I look at Matt Godbolt, I think bonkers. So no it's because we, this, and it was like, full-sized candy bars are like amateur hour in this neighborhood. If that's all you're doing, you're just, you're way behind the curve. Um, so, and we knew this and so like putting a bowl of candy out is not only an unacceptable solution, if you want to go trick or treating with, with your kids, which we did both my wife and I wanted to go trick or treating with our kids. And this is when they were younger and much cuter, but, um, and so, you know, we wanted to go out and so I can't just put a bowl of candy out there. What am I going to do? And I had been looking for an excuse to use one of the many Arduinos that I had just ordered only to have them and just sort of assemble them and, you know, possess them, collect them, like I should put these things to use. Um, and so I built two versions of it. One version was a candy dispenser and this little like LED backlit for some reason, Super Mario themed, um, you know, game, the whole structure of it was like a carnival game. I called it candy or death and it would alternate between two possible outcomes. You hit, there's a giant button at the button and it like plays a song and it alternates between these things, candy or death.
Like the sort of the skill game on a fruit machine, where you kinda have to stop it on the right. Okay.
Yeah. Except it, you know, there was no skill to it. It just, it just almost like a, like a, like a roulette wheel in a way.
Oh, OK so like, tick, tick, tick, tick, tick, tick, tick...tick....
Yeah, exactly like that. And then it would always land on candy and then it would dispense candy.
Boring!
and the idea behind this, right? Yes. More on that later. Uh, but the idea behind this is that it was sort of like dinner and a show because I needed to have a hopper that would hold so much candy and I needed to know, approximately even with the ridiculous traffic, if there was like a line around the block of kids just hitting this button over and over and over again, how long do I have out trick or treating with my kids before I have to go back and refill the candy hopper.
And replenish the hopper, right. Got it.
Exactly. And so it would take a minimum of the first version, I think was like a minimum of like 50 seconds, 55 seconds, somewhere in there too, to go through the whole thing and then eventually dispense the candy. And so, and you know, it wouldn't do it if it wouldn't do it, if it was in the middle of doing it. So you could just sit there and literally just hit the button over and over and over again. And it would have at least like an hour to an hour and 15 minutes worth of candy. So we can go do...
Because one piece of candy per minute. Like even with someone just to hammer into button, a couple of pieces of candy and you just know, well, I can get 120, 150 pieces of candy into the dispenser. I'm good for an hour.
Yeah, yeah, yeah, yeah. And it was, the candy was kind of random and that was sort of like, I think part of the appeal is it almost always I had it, I had it tweaked enough to where it would always give you at least some candy, but sometimes you get a bunch of candy. Sometimes it'd just be a little, and I thought that was just, I didn't want to fix that. That wasn't a bug for me.
That's part of the charm.
Right. Uh, but yeah, and this was the first version was just sort of this backlit, you know, I basically like took some almost like I forget this paper, but like almost like rice paper. And I built like, like a shadow box type thing with an LED in the back. And so it was sort of light up. Um, and that was all controlled by the Arduino. And then the second version was that, plus I replaced the LEDs with a actual TV screen controlled by a raspberry PI that played an animation. And this had like, you know, like, uh, a skeleton hand that would spin around and music that would play, uh,
That's a pretty serious, uh, an installation at that point, rather than like a microcontroller and a couple of LEDs and a server. But we need to talk about how you actually build the thing, because that to me is like the really interesting part, but yeah,
Yeah, yeah, yeah. It was cool. Um, the, so the candy dispenser itself ran on a Arduino and the Arduino had a stepper motor shield that you could put on it. Um, all this is on my, like all the code for this is on my public GitHub, by the way, which is, you know, benrady. So github.com slash benrady and it had this really cool stepper motor that I found and the Arduino shield that went with it.
What is a stepper motor compared to like a regular motor? What is, what is the difference?
Yeah. So it's basically just like a super powerful servo, right? So you can control, uh, with like a regular servo usually, and also with a regular servo. Usually there's like a range of motion that you're limited to. Right. Sometimes they go, okay, just keep going. But...
But a servo's like a thing I can pick what orientation I would like it to be pointing out between. Say like zero and 45 or something.
Yeah. It's like a motor that you can basically just rotate as much or as little as you want and to specific locations right.
The motor know which way it's facing or I guess in your case, it doesn't matter what
In my case. It didn't matter. Basically what I want, the thing that I figured out is I did a lot of testing with different kinds of candy and different.
Testing. You say?
Well, yeah, good point.
Always the testing with you!
I mean, you know, you want things to work, you've got to test them, maybe we'll call it experimentation. But, uh, uh, the, the, so I had, I had this like cereal dispenser that I had found that was like, basically these rubber fan blades and the cereal would sit in the hopper on the top and you'd spin it. And you've maybe seen this in cafeterias or in other places where it's just, they fill a big plastic hopper full of...
Like breakfast bowls, and you can get one or two portions.
Yeah. And so I had one of those and I had hooked that up to not directly. It was through a, uh, um, a little belt pully system, but I had hooked that up to the stepper motor, um, A to get more gearing so that it could, you get a little bit more torque, but also to elevate it up so that it could fall down and still hit the right spot in the window where the candy came out. Um, but, um, but I had hooked that up to the stepper motor and I figured out that you can't, if you just turn it in one direction, it tends to jam. And so what it would do is it would turn a little bit in one direction and then it would back off and turn in the other direction. And then it went back off turning the other direction and would basically alternate back and forth.
Jimmy itself. Like to get out if there was anything that was, stuck, right.
It wouldn't, it was, it was much less likely to jam that way. But then that also depended on the kind of candy. So I tested lots of different kinds of candy and
That's onerous testing.
Oh man, that was, I'd be ordering these five pound bags of candy off of Amazon. And I run it for like two hours and it would jam and be like, well, this is useless. I can't use this candy for anything except for eating it all, which I definitely did at a certain point. I was like, maybe I should just do Tootsie rolls. Cause then I won't eat them.
Yeah. But then neither does anybody else.
Well, yeah, that's true. So eventually I wound up with jolly ranchers, jolly ranchers were a good combination of hard candy, but with a wrapper that was like flexible enough to where it would, you wouldn't get this sort of like, because I tried Starbursts and Starbursts with like lock into position where the square blocks of the Starbursts would just like form a wedge and like, no matter how hard you turned it, it just wouldn't give.
Right. Right. Yeah. I got it. What an interesting thought. Yeah. So like the little, um, uh, tassels and not the plastic wrapper forms like a spring on either side and also a force that tends to well. If you've ever tried to squish them, push it, like twist it in a way. So as they're kind of being squished together, they move around a lot. As opposed to, as you say something like a Starburst where essentially you're playing Tetris, except that the line does not disappear when you've got it completed. It just wedges your machine.
Exactly. Yep. Yep. That's exactly right. So, yeah. So, so after some, some, some experimentation and testing with that, um, you know, I had the stepper motor working, I had the candy that I wanted to use and it was just, you know, sitting down and writing like a little Arduino program to do this. And I love the Arduino IDE. It's super fun.
I was going to say, we should talk about that because if, if people, I mean, obviously there's physically building the stuff's cool and interesting. And we should definitely get back to, and talk a little bit more about how you actually put it together. But the Arduino programming experience is, is pretty exciting. And you should tell us about it. What all does it look like? How does it, how do you do this?
Yeah. I mean, it's so fun to be able to just, you know, you can, the IDE is really easy to use. You just download it, you plug in your Arduino via USB and you can, you know, run your, you can upload your code to the Arduino super fast. So you have a nice feedback cycle and you can just be plugging components into the thing if you've, um, I think the first one I did was one of the earlier models. So I didn't have it on a breadboard. I just had, um, basically just wires running out of the thing. And I actually forget how those connected. If they were like, um, little female connectors that you could put those wires into, but it was, it was really easy to plug stuff into. So you could plug in LEDs, plug in the plugin, like other, like the button, you know, I can control that. And you can with a pretty fast turnaround time experiment with it. Right. Just try things out. Right. And you know,
In what language are you writing all this stuff? Like a scripting language?
It's like a, it's sort of a weird C++ the Arduino language, right. It's like, you know, not nearly as fully featured, but you have certain C++ language elements that are there. Um, and it's, you know, it's, if you've written any programming languages, not hard to figure out. Right.
And presumably this is, we're talking like a page or two of code. We're not talking like giant, giant gobs of it, not multiple files or are you, I mean, I know from my own life, LED blinking.
Yeah. I didn't actually, the most complicated thing that I did with the first version was, uh, you know, the Mario brothers, uh, flagpole, uh, fanfare. That was the sound that it played when it dispensed the candy. And I had basically hand coded that into the program as like frequencies. And I had found a couple of places where it's like, I thought I had the frequencies, right. And I, my wife is very musically inclined. She played piano for years. She played french horn, she's a singer. And I played it for the first time and she was like, nah,
She recoiled in horror, at the cacophony.
That's wrong. You're not. You're off. And I'm like, if you say so, I can't tell the difference. But yeah. So that was, that was honestly, most of the code in that file was taken up by that just playing that fanfare. Um,
And the rest of it was like turn motor on. Delay for 250 milliseconds or whatever.
Turn the motor 180 degrees the other direction, way, two seconds. Got it. Um, you know, flash the lights, you know, for the thing. But that was all that stuff is pretty straight forward.
That's that's awesome. And, and so the feedback cycle is really, really quick when it's like, they're plugged in the USB board into your computer and then presumably, you've got wires dangling out and you've got like a, something constructed nearby with a stepper motor. That's kind at least just turning. So you can see how it's going to fit together. At least while you're developing it. How do you take that, that sort of connected to a PC and then make it run elsewhere. It just seems like, you know, Hey, how do I install my software on it? How do I deploy it?
Right. Right. Well, you screw it to a piece of wood. That's the, that's the main thing that you do
It persists. Does it, once you've, once you've copied the code onto that, that little Arduino, you don't have to flash RAM-y type thing or that's just, it, you kind of deploy it and then you unplug it and then you turn it off and then put it somewhere else and turn it back on again. And off it, that's so cool.
All you gotta do is turn it on. It'll run. So there's, it's, it's really simple. And, um, you know, it's not that hard to write a little while loop to listen for inputs and wait for the state of a button or a pin to go high and then do something. And so, you know, it's, it's a really simple environment to work in. Um, and really rewarding. I think
When something actually physically happens in the real world.
Yeah. Seeing the motor turn.
There's, there's definitely a warm feeling you get from like, I'm controlling something in the real world. I mean,
Feels like magic.
My kids do some like Lego Mindstorm stuff and that's all like drag and drop things, but it's still really cool to move a motor around and kind of go, Oh yeah, that's, that's, that's a real thing that happened because you typed some code in. And, but when you've actually built it yourself, it's gotta be even better.
Yeah. It was super fun.
You've got this, uh, motor that's powering this, cereral dispenser and you've kind of worked out the correct sequence of wiggles and the right candy to put into it and the right sweets to put into it for those listening in, EN-GB it also a bit late to say this now. But like, for those who don't realize quite how big a deal Halloween is over here in the States, um, you know, our international audience, what are they talking about? It's like, no, it really is crazy. You are, you have to leave tons of, we leave like a big bowl outside. We have the exact problem that you do, which is that we come back and within like 30 seconds, the bowl was empty because someone's just empty the whole thing into their bag and the gone on. And then it's like, there's not really Goodwill to your, your, your, uh, the, the neighborhood kids. If you, if, if there isn't something for them. So this is obviously a very real problem in a real world problem that you're solving with this, uh, this, this, uh, approach. But so anyway, yeah, you've, you've built this thing. It's all connected together. Do you put it outside and do people steal it? I mean, that would be my concern in this kind of thing is that someone would go that's cool I'm having it.
That was also my concern. I mean, you know, we live in a fine neighborhood, but if you give teenage kids access to a giant hopper full of candy, they're going to take it right. It's the same problem as the bowl. So we had the fortune of, um, our house having a window directly onto the front porch, right. It's like kind of to the side of the front door. And it was kind of a narrow window. It was only about two feet wide. And it had these child locks built into the window to where the window would only move up so far so that you could open the window and, you know, be safe with kids. They're not going to like little kids. They're not going to like push the window all the way open and fall out. Right. Um, and so I built it into that specific window with those child locks.
Right. So the way it would work is there was a face plate with, with the button and the speaker in it. And then that was on top of a piece of MDF that held like the Arduino and the motor and the assembly for the hopper and all that stuff. And all the power circuit, all the power cables and all, everything was just sort of screwed into that piece of MDF. And so you could set it in the window and then close the window and lock it into place with the child locks. And it would not only hold...
I see. So it was partially closed, but open it anymore after that.
Right. It was the faceplate was the exact height of the gap that was created by the child locks. So you could basically lock the whole thing into place and have it be safe. I mean, you'd have to break the window with a hammer or something in order to,
At that point, right. You've gone from, uh, teenagers just robbing the candy because it's there on display to actually breaking and entering.
You're just breaking into my house at that point, which is sort of outside of the spirit of Halloween.
Yeah. Even over here.
Yeah. Um, so yeah, and then the cool thing is like, pull the shade down behind the window so that I would prevent any light from sort of leaking through. Cause again, it's like, I want it to be dark on the front porch and I want the light from the candy dispenser to be the only thing that you really see right.
Of course. Ghoulish illuminated by the flashing red and green, like candy or death.
Right. Or the screen, you know, in the second version
In the second one. Yeah. So we should, so you, when I mentioned death before you sent, there was a story, is this the right time to tell that story?
So the thing was is that, you know, my, my wife and I, it's not like we had another supply of Halloween candy. Right. So when we came back from dispensing or when we came back from going trick or treating, we would go in our house and I just leave the candy dispenser there. And this was great. Cause you get to hear the reactions from the people. We'd be just sitting in our living room and people would come up and you'd get to hear their reactions. And by far the thing that we heard most often was kids being disappointed that it didn't land on death. Right. They just be like, so they just do it over and over again. And they'd be like chanting death, death, death, death, death, death. And it would land on candy and they would go ahhhhh...fine, I'll have some jolly ranchers. Yeah. Yeah. So I dunno.
So they wanted death. Did you ever, were you ever tempted to, to meet out, you know, like one in a hundred deaths, something like that?
I did have the idea. I did have the idea of having it look like it, like glitched out and then switched to death and then throw like a jump scare picture up on the screen. You know, something that's not too terrifying, but something from like a horror movie that would just, you know, to sort of like pop up on the screen and sh and scare you. And what I wanted to do was put a webcam over the thing. So as soon as it did that, it would take a picture and then post it to a Twitter account. And then I could have the candy or that Twitter account with people going like, you know, AHHHH!
Which would last about five minutes before someone pointed out, you probably shouldn't be doing that without consent and all those boring, but very important things.
Again, Halloween actually, you know, it's funny...
Like all bets are off, right? You waived your rights when you walked up my front steps, disclaimer, at the foot of the stairs.
It wouldn't be the craziest thing that has happened in the neighborhood on Halloween, for sure. But not even by a long shot.
That's pretty macabre things around here. I've seen like bodies on spikes in the front garden. Like this, this is not, that's not cool.
Yeah. But yeah. So, but I never did that. In fact I don't own it anymore. Cause when we sold our house, that was part of the deal for the house.
Oh my gosh.
I sold it with the house because it fits that one window. I'd have to completely build it and we don't even have a window in our new house that it would, that it would.
You don't even have a window? Oh, you don't do that. It wouldn't be, I was going to say you just live in a brick? A brick cube!
It's actually all window I live in a giant class cube. It's like an Apple Store.
I mean, from the webcam, since you've moved, I haven't seen your new house. There may well be, you know, no windows. I can't see any windows. So I assume. It would make sense.
There's no windows here. But no we couldn't have used it.
You sold it with your, your, your, your house because it doesn't fit the new house. Did you leave them with like an owner's manual and like github instructions.
I made them an instructional video, actually.
That's so cool.
Yeah. And actually the, the presentation. So you've seen my presentation that I did, the talk I did on this right?
That's what clued me in to knowing about it. Yeah.
That's I left that, that the reason I did it is because I was selling the house and I was like, Oh, I'm not going to have this anymore. And also the new owners need to know how to use it. So I'm going to do a talk on it and then I'm going to leave them the link to that talk and some video so that they can see some other things.
So is there a YouTube link actually in the closing documents for your house? That would be the legal documentation that says...
Sign the rights of video over to them?
The seller represents that this is how the candy dispenser works.
It's part of the inspector was like this, this candy dispenser is not up to code.
Yeah. Did you show him the tests? Did you write any tests?
Uh, did I write tests? So I, in the Arduino IDE I had a test mode. Right. So if you, um, turn the thing off and turned it on and you held down the button and this made me think when I was making this, it's like surely, surely, surely there are like old-school coin-op video games and vending machines and things where if you turn the thing off and you enter in the right code, in the vending machine, all the, all the candy comes out. Like all the food vending machine comes out that has to exist. And and doing this sort of reinforced that for me of like, if you turned it off and turn it back on, and you held down the buttons, the button was pushed when it started up, it would run a diagnostic. And it was basically just me with a bunch of asserts checking, a couple of the functions that I had written. And then it would go into this like auto dispensing loop that I could use for stress testing. Right. So if I was testing out a new kind of candy, I could just do this and leave it for three hours or two hours or whatever, and come back. And if it a jammed then, okay. That candy was no good.
Do you get feedback if it does jam, is there like a readout from the motor that says, hey there's going to be a fire soon because the motor...
It just struggles.
Oh, okay. Clicking horrible thing.
What would happen is the belt would slip the motor was powerful enough, but the, the teeth on the, on the timing belt would just slip.
So we haven't talked about the second version very much. So that was more complicated than just an Arduino and some lights and a and a while loop it had, um, it had a raspberry PI, did you say and a screen, a TV screen.
Uh, the way I, the way I did this was I hooked up a raspberry PI to the Arduino over the same USB cable that you use to program it. Right. And you can just, you know, talk over that serial connection and send bytes in both directions. Right. Um, yeah. And then on the raspberry PI side, I just, you know, opened up a serial connection to that device and read the bytes that it was sending. And all I really needed was just the signal for when to play the animation. Right. So I don't know what message I sent. It was probably just some like hello, world string or whatever. Um,
Cause of the, the Arduino was, was the driver effectively. It was in control of the whole show here. And it was using the raspberry PI a full Unix operating system on a small arm, many hundreds of megahertz arm chip as essentially a glorified graphics card. On a wire.
Yes. Yes. That's exactly right. That's exactly right. And so when it got the signal, it would play, it would the animation. I actually did it all in Chrome with SVG. So it was like serving up a, the thing running on the raspberry PI was listening to the serial port and serving up a, uh, very, very tiny web app that would play this animation and play the music. Right. Um, and it would just do that in response to getting the signal over the,
So it was a dynamic web page that was showing the content. You used. That is, I mean, if people talk about being a full stack developer... But until you are writing an Arduino like low level, um, stepper, motor driver talking over serial to a web browser and that's a whole product that..then you're not full stack.
I don't want to gatekeep on what full stack is, not at all. You know, like it's, it's, that's just amazing to sort of have a fun project that touches so many different areas of problem solving and computing.
Yeah. And yeah, it's like, it's like the, when you something in your web browser, what happens? When you push the button on this thing? What happens? Well, first the Arduino sees that, the pin has gone high and then it starts playing a song.
Did you use a, I'm going to have to bring up my favorite things to talk about, which is, you know, when you're down at the low levels like this, and you're looking for edge events, like a button being pressed, you mentioned that you had a while loop, but did you use an interrupt? Tell me you used an interrupt and you just went to low power mode.
No...
Oh, you're so disappointing. You missed a golden opportunity.
Can you even do that? On an Arduino?
Yeah, some of the, sort of like pigeon C++ extension type things that have got, allow you to tag stuff as interrupt handlers and set them as interrupt handlers and stuff. So you can do some of that nonsense. But you didn't need to do it, so you didn't. Because it turns out that if you're not, if you're not battery constrained or anything like that, sitting in a tight loop going while read this memory address is not equal to zero, sit in a tight loop.
Works just fine?
It's just fine. Yeah. But no, I just an opportunity to kind of get that end as well as a few, just another rung down. Well, yeah, next time,
If I was running this thing off a battery, that would have been a whole other deal for sure.
A whole other world of considerations. So the obvious next question is what are you going to do in your new house?
Uh, what am I going to do in the new house? I, you know, the thing I built in my new house is I built a golf simulator, because I like to play golf.
Oh, well, this has taken an unexpected turn.
That's, that's almost like a whole show into unto itself. Cause man, once you have simulator data that you can export and analyze, there's a whole other level of nerdery that happens.
Oh my gosh.
Yeah. That's that is definitely a whole other episode.
That's another talk. Okay. All right. But you definitely piqued my interest there. I'd love to hear about what the heck that is, but no, no plans then for any Halloween magical for resurrecting something similar to it is that you've kind of done that. You've got the t-shirts the kids are more grown up now, baby, when you were allowed out of the house, at all, obviously.
Yeah. Right. When, when there isn't a pandemic going? Uh, yeah. They, they can go trick or treating by themselves now honestly, if they want to. And I think they did last year or the year before it was snowing. I remember, but yeah, it's, it's sort of been there, done that.
You've you've, you've got the t-shirt you've had your fun and now you've moved on to more things that actually impact you directly. Like I know how much golf it means to you. So a golf simulator is, is, is more in keeping with stuff that you're interested in rather than just service to the neighborhood kids. Yeah. Cool. Well, I guess, I guess we're talking about that another time and I'm disappointed that you didn't have an actual test framework for this and you just have to hold down a button, but I appreciate...
Tests for the web app that lived on the raspberry PI that had tests. The Arduino code only had the diagnostic mode.
Although in fairness, writing tests for web pages is about as difficult as writing tests for embedded systems. Right. It's still awkward to do it.
Oh no, it's much easier.
Is it?
Oh, it's so much easier.
I, I, we should not go back to testing just yet. At some point, you're going to have to explain to me how to write decent web tests because I, I, I can't, but that's yeah. That's another topic, so
Yeah. Uh, do you want to talk a little bit about your picture frame that you've been working on?
Oh, I guess, I guess we could.
I would like to hear a little bit more about that.
So yeah, I saw a, um, I saw a YouTube video from an acquaintance of mine who had made a kind of a joke present for his mum where he built a picture frame into, uh, with an E ink paper, uh, into, uh, into like a little, uh, photo frame, like a regular photo frame that you'd put a normal photo and gave it to his mom as a present, but unbeknownst to her every day or every couple of days, the picture would change overnight. And he was, he was betting how long it would take her to notice. And unfortunately, I think she realized something was up because it didn't look quite right. And you know, it was, she knows her son. So it was, it was, it was under intense scrutiny, but anyway, it was inspirational to me.
And I thought I've just been lucky enough to be sent a raspberry PI zero, which is a raspberry PI that doesn't run Unix, unlike all the other ones. It's just a chip on a board and a very low power chip at that. And I thought, Hey, why don't I give this a go? And I'm going to try and make it run off a battery because Charles's set up, was on, a Arduino, which I I've also got an Arduino, you know, knocking around somewhere as well. They are great fun that the IDE is just brilliant. Um, like we were saying before. I was just interested in using the raspberry PI, uh, sorry Pico, if I said zero before I meant Pico, I forgot what I said. It's late in the day now, but yeah, raspberry PI Pico is just nothing to it. Just a little board. And so, um, I picked up the same E ink screen and this is a color ink screen.
So it's got seven colors, which is a weird number of colors to have, as you can probably imagine eight would make more sense. And so it's four bits per pixel. Bizarrely, the internals of the screen are very much like a, an actual CRT display. Like it has, you have to set up timings and, uh, how many pixels across it is, how many pixels down is how quickly the vertical refresh happens, but it's clearly not updating 60 times a second or 50 times a second, right. Is just, that seems to be the communication between the RAM on the board and the actual physical screen itself. Like this is a well-established way of addressing each pixel. The best way of doing it is to sort of stream out the colors one after another to some circuitry that can then make sure the right color gets to the right pixel.
That said, though, the way that it works is that you kind of populate this memory and then you kind of say, go, and then it starts doing the kind of Kindle thing. If you know what I mean, if you've got a Kindle, that's got an E Ink display, it kind of flashes on and off and kind of has a real laborious time of it as it's kind of like reset the E ink, uh, except it takes even longer because it's got multiple color cells to do it. And it seems to be, there are just different cells with like colored lenticles over the top of them to give you this the seven different colors and the seven colors like red, green, blue, yellow, browny-orange, uh, that's five. Um, but to be honest, most of them look brownish, right? It's not very good. And so you, and it's 600 by 448.
So it's, it's quite high resolution. So some dithering gets you some way, but all the algorithms I've looked at for dithering, the standard ones, um, Floyd Steinberg era diffusion is the one that I picked. Um, they, they worked really well with luminance from a screen, but they don't seem to work as well with essentially a paper medium, which is essentially subtractive. And I'm trying to wonder if there's some, almost like newspaper style, half toning that used to happen, you know, like on printers versus the kind of thing you do for a screen that I might look at. But anyway, the, the, the code, it runs on the little, um, zero, it talks over SPI, which is a standard serial protocol to the, the display, I've got a little sense, uh, direction sensor on there as well, which tells it can tell whether it's up so that yeah, if you can pick up the picture frame and put it on his side, it'll only show portrait things and he put it back and it'll show, uh, landscape photos.
And so there, I use an interrupt handler. Ha ha! So I can go into low power mode. You see, I get it out in the end, we're talking interrupts, uh, so that it can go into low power mode between essentially what would be asleep for at the moment. I've got it like five minutes, just because I can see it, see it go. Uh, it's been a lot of fun. Um, I plan on putting the whole thing at the moment. It's on my shelf in the other room, but it's like if you to look at it any further than, um, three, any closer than like a couple of feet, you'll notice that behind it is a ton of breadboard and wires and batteries and things. So it's not very good. Um, I'd like to get it to the stage where, um, I can get, uh, like a breadboard, a actual, um, you know, copper track breadboard, old school, not like the pushy pen ones, but, and soldier onto it and get that, um, actually sort of fabbed enough to then get everything into the little clip frame that I've got for it.
Cause the whole thing is only like, um, you know, a half a centimeter thick, which is, I dunno, some 29/64th of an inch or something. I don't know, you Americans and your crazy stuff, but yeah, five mil kind of thick, um, thing, but it's the, it's been an interesting, um, experience the, the raspberry PI SDK, the zero, sorry, I keep saying zero, the Pico SDK is shipped as like a GitHub project that you just git clone and then you'd kind of just cmake it in. And it's all written C and C++ they've done a really good job of documenting it. The, you kind of link the whole operating system such as it is. It's just support libraries into your executable. And because it's, you, you have like a sibling directory with all the code and it builds it as source. So you changed your compiler and it's going to pick up all of the, the, the whole operating system.
And then you just get like a dot, a single image to deploy to the, the app to the device. And the way you deploy is when you turn it on, just like you were describing before, there's one button on the top of the thing. If you hold down that button, when you're, when it's powered on, it goes into like a receive mode and there, it looks like it's a USB thumb drive and you copy a single file onto it. And as soon as you finished copying that single file into it, that's the image it's going to run from then on it just flashes that image. And now it's that. So I've got like a little watch loop. You know, we've talked about the, uh, the watch sort of targets before now, which look for the USB drive to appear. And when it does it copies of the current version, and then, then it waits for it.
And then it gets the serial port debug interface up and just waits on. So I've got a little like REPL style thing where I can just hit build. The only annoying thing is I have to like, press the button. And until I wired in a reset button myself as well, it meant that I actually had to unplug and plug the whole thing back in again, which was a pain in the proverbials. But, um, you can get an actual debug header for it and then actually debug it. But the easiest and best way to connect to the little three pin debug system that it has is to use another raspberry PI zero as like the adapter. Yeah. And these things are $3 99 each it's just silly, so I just ordered 20 of them because
This is exactly like you and your Arduinos on the shelf.
That's why I have half a dozen BBC micro boards sitting on my shelf.
Right, exactly right. Yep. So yeah, These, these cool things are, uh, you used them as the adapter, the debug adapter. And so unfortunately, because everyone has rushed off to buy them, they're out of stock everywhere. So, so I'm waiting for more to come through, which is why I have sort of shelved it for now until I can, I can debug it properly and get my few other bits and pieces through, but it's just great fun. It's great fun to have something. And I'm hoping that it's inspirational for the kids to see that with relatively straightforward code. I mean, again, at the moment, everything that I've done in my code with the exception of the gzip library, which I've kind of got hidden away somewhere else to compress the images and put them on, uh, into the image itself, everything fits into a single screen also. And that includes me, me, me going slightly crazy and wrapping the screen driver that I had written in a nice C++ 17 objects that are all, you know, all the nice things, all the nice trimmings.
So which means it's more than one page of code. It's one file. I said it with one screen. I mean, it's one file. It's about two screens worth of code in as much as the screen is a decent measurement of code, but it's not much, it's just fun. And exactly, as you say, like, Hey, when you, when you are just doing a relatively straightforward single thing, you don't need very much code. Like while I go, Hey, sleep in low power mode for five minutes. Cool. All right. Now send this byte to the SP over the SPI to the display drive, which wakes it back up again from its slumber that I brought it in and now stream 600 times four, four eight divided by two, because there's four bits per pixel colors from, from an array that I just gunzipped. Um, okay. And then sleep again for a bit, you know, give it the magic command to say and go, and now watch it, do it screen changing and I'm going back to sleep again, but it's so cool. It's so cool. If you don't mind a very dull, slightly brown image of anything you wanted to put on it. So my, my original hope was to give this to my wife as a Valentine's present. Oh. And, uh, I failed to deliver it to her in time.
Next year, next Valentine's day.
But I told her about it. And then, so I got almost as many kind of reward point romance reward points for, uh, for the idea of it, than the actual implementation, because I don't know how excited she would be really about a muddy picture of pictures of us.
Well they say that it is the thought that counts.
They do say that it's the thought that counts. And this is also, uh, not the first time that she's had to put up with devices that I've wanted to make, uh, as either gifts for her or for me, because I think for my 30th birthday, I said to her, rather than getting anything, I was going to... her, getting me anything I should say. I was going to buy a bunch of components, build my own MP3 playing system that will, could plug into my amp.
What year was this?
I still have the parts this well, 14, 15 years ago. I got it working. But ultimately I ended up buying like a Squeezebox, which was this commercial offering that did the same thing. You know, this is like Pre Sonos pre, um, that kind of stuff where I, you know, I had a server that was chock full of all my MP3s and I couldn't play it on my nice high hi because there wasn't a way of connecting the two. And so I thought, well, I'll make one.
Do you see, I don't know if you can see this in the webcam, do you see the sort of steel and plastic contraption sitting on the top of my, bookshelf over there.
I have many times wanted to ask you what that is.
That is a computer that I installed into my Honda Civic in around 2002 to play MP3s because you couldn't buy an MP3 player at the time. And so that one is voice controlled. There's a little lapel mic that I wired through the car up to the driver's seat. And there was a push to talk button, and then you would push it. And I, it used the Windows voice to text API to, we should talk sometime about the trials of trying to get a computer to shut down reliably and not overheat in Texas, that's a Windows...
In a car!
In a car, if it's a windows machine. Um, but.
Wow!
But you could push a button and you could say the name of a song album or playlist, and it would play that song album or playlist.
That's amazing.
Oh my gosh.
It's so cool. You, uh, when was that? I mean, obviously this was when you were in Texas. So that was a decade at least.
It was immediately after I graduated school and I'm like, I have money! I can spend this money on whatever I want! I'm going to build a computer into my car. Right. It was, that was my geek project, Oh my god. MP3 players, man.
I mean, if, if we, as if we needed more, uh, reasons to, to, to say that we are similar. We've taken, we would, we took a different fork at the beginning, but we have remarkably consistently done similar things about 15 years ago MP3s. That's cool. Well, there's lots more to talk about there and yeah, I definitely want to hear about your, your golf machine at some point, and maybe we should record something and put it on a, you know, a YouTube for people. When we talk about that, then we can critique your golf swing as well.
Oh boy. Critique golf. That'd be another, that's embarrassing. Yeah. You know, we could do, maybe we should do like a YouTube channel something and do some of these, you know, we're talking about these presentations that we've given, but
We've given before we should probably, we could at least collect them in a playlist. We've got a few things that we talked about. Cool. My friend. Yeah. Well, let's think about that some more when we're not recording for a podcast. So we can actually talk about it.
Yeah, good call.
rather than sort of make ourselves promises that we won't be able to keep. And, um, we've got tons more to talk about. So I guess until next time.
Yeah. Sounds good.
All right, mate, laters.
Later.
