Random Number Generation¶
This is a project I have been working on for a bit. Yes, AI was used a LOT for the hardware stuff (if ever letting Claude tell you how to do hardware wiring, make SURE to select the best available model, it fried a lot at one point giving me bad instructions).
Idea¶
I (think I) saw something about how random number generators on computers, aren't real random, just basically fake randomness (yes this is true btw). I then also (think I) saw that you can easily make a device that gives true randomness, so I wanted to do that (why? because I can, and this is the reason for most of my projects).
Hardware¶
I used an Arduino Uno for this project, along with transistors (I think a 2n3904 and a 2n222a, don't trust me on that), and some other stuff like 12v power (NOT directly to the Arduino, don't do that). After a few attempts Claude was able to give working instructions for it (maybe I'll add them here later). After some testing, it seemed to work, I made some things like a magic 8-ball, and then, kind of left the project for a bit. At this point I was using 2 2n222a transistors, instead of the 2n3904 I now use, because at that time I didn't have it. After replacing and fixing a wire being in the wrong spot (that somehow didn't break it), I got it to work again. This is where it is now, just in a box, plugged into a server computer.
Current Software¶
My software for it has been many things, before this it was just messing around, I modified the python random library (well Claude did) so I could get random numbers simpler. Now, it's used for an API I'm hosting (that you can also try! pls don't hack me.) The Arduino code is so small I can put it here:
yes, that's the entire thing, the computer does most of it.
How to use the API¶
Here's some API instructions (no, the code for the API is not opensource, yet, maybe I will eventually. Though it's not very complex, you could probably make it yourself almost functionally exactly by just using it.)
So, everything with the API will be on the site at https://random.owendeed.com/, but not just that link plain! (will not work.) You need to add stuff to the end depending on what you want.
The API uses a queue system, you register in the queue, and when the device has gotten to making your number, you can use a link to get it. Here's how:
To register for a number: Use this link: https://random.owendeed.com/queue, this will return some json data for you to use, now, there's 2 things that can happen.
- The queue is empty
If the queue is empty and you get in without any waiting, then the queue link will have the json key "ready" be true, and the key "number", will have your number There is also a "status_link" and "id" key, those will be explained later, there is also some note values that you can read for more info if you want.
- The queue already has people infront
If this happens, the key "ready" will be false, and there will be no number, there will still be the "id" and "status_link" keys that you will need (either one, you'll see). There will also be the note and warning keys for you to read if you want.
Handling "id" and "status_link" (needed for 2nd thing that can happen):
The id is a unique identifier for your request to get a number, this is what you use to request your number, status_link is just the API link already filled out for you with your id (this can save you a step!). To get your number with it, use the following API request, or the status_link: https://random.owendeed.com/status/YOUR_ID_HERE (replace the YOUR_ID_HERE with your id.) Going to this will give 1 of 2 things. One, is that the key "ready" will be false and there will be no "number" key, if this happens, as the note attached to the request says, the server has not gotten to giving you a number, wait a bit, and try again. The other thing that happens, is theres no note, and "ready" is true, if this happens, then there will be a "number" key with your number.
Number expiry¶
Say you are in line for more than 5 minutes without a number, or your number is stored for more than 5 minutes (which will happen, you can't delete it, for 5 minutes, then it's gone), the timer resets when your number is generated, if it's not deleted yet, everything is fine, otherwise, the key "ready" will be false, you will get a 404 result, and also the "error" key will be there, saying "not found".
Demo¶
Click the Queue button to queue for a number and check status to get it!
Queue sends to https://random.owendeed.com/queue.
Check Status sends to https://random.owendeed.com/status/YOUR_ID (your status_link).
Click the button to get a random number!
Click "Check Status" after getting your ID above.
Warning¶
This API will not have the best uptime of all time, so make sure to have some sort of backup if your using it.