- 3D printer
- Table saw
- Raspberry Pi 3
- Adafruit Thermal Printer & thermal paper roll
- Fingerprint sensor
- Arduino Nano
- Plywood(200cmx25cm) in total
- Chestnut varnish
Step 1: Introduction to Quantum Computing
Classical computers that we use in our daily lives: phones, tablets, computers, etc. operate on binary. 1’s and 0’s. the combination of those is what makes computation possible.
The bits in Quantum Computers on the other hand which is called Qubits can be 1 and 0 simultaneously. Thus Quantum computing is a type of computation that harnesses the collective properties of quantum states, such as superposition, interference, and entanglement, to perform calculations.
For the sake of the project, I will only introduce you to the true randomness property of Quantum Computers but I will link some resources at the end of this step so you can go further down the rabbit hole if you’re interested.
What is true randomness?
If you throw a penny in the air, wait for it to drop on the floor and check if it’s heads or tails. Is the outcome random? It might seem random at first but the thing is that if you observe the penny while being thrown and make the necessary calculations considering the density of the air the force applied by the hand etc. you can predict the outcome precisely. this also applies to dice rolls and even random number generators used by classical computers. They basically generate random numbers based on other factors. If you know the function and those factors(seeds) you can easily predict the outcome.
Quantum computers, using uniquely quantum properties, can generate truly random numbers. They don’t use any factors or seeds to generate any numbers. The randomness comes from the measurement of the quantum states. Thus a random number generated by a quantum computer, in theory, can not be predicted. In the context of this project, you would never know why a certain prompt was chosen for you from the list. And that’s the spooky quantum property that this machine is using!
Quantum. country – A really good guide on quantum computing, involves step-by-step practice-based interaction so you have a clear picture of what quantum computing is when you finish.
Quantum Dice – Practical application of the quantum dice using Python and Qiskit
Qiskit – The Qiskit website itself has a really good introduction to the basics of quantum computing, and shows how quantum computers work compared to classical computers.
Step 2: Raspberry Pi Setup – Raspberry Pi OS
Note: In this step, I’ll explain how to set up your raspberry pi from scratch, if you’ve already installed Raspberry Pi OS you can skip this step
Installing Raspberry Pi OS
note: you’ll need a keyboard, mouse, and monitor to set up your raspberry pi
Before we get into the code of our project, we first need to set up the Raspberry Pi. You can follow this official guide on how to install an operating system on your Pi:
Make sure you install “Raspberry Pi OS (32-bit) with desktop and recommended software”, this version will have all the software we need to run the code.
After you’ve installed the operating system and started your raspberry pi, open up the terminal and type:
- This will open up the configuration menu, navigate to Interfacing Options, and enable SSH.
- Under Interfacing Options, select “Serial.” Turn OFF the login shell over serial, and ENABLE the hardware serial port. This is required for the thermal printer to work!
Enabling SSH will help us get into the Raspberry Pi remotely so we won’t have to use a keyboard, mouse, and monitor every time.
Now our Raspberry Pi is ready to use! in the next step, we’ll install the required libraries for the Thermal Printer, and also we’ll install Qiskit which will let us connect to an actual Quantum Computer.
Step 3: Raspberry Pi Setup – Install Required Libraries
We need two libraries for our project to work, the first library we’re going to install is the Thermal-Printer-Library from Adafruit. The second library we need to install is Qiskit which will let us use an actual quantum computer from IBM.
Thermal Printer Library
First, we need to update packages and install the required libraries for the thermal printer. Type:
sudo apt-get update
to update the packages. Next, install the required libraries by typing:
sudo apt-get install git cups wiringpi build-essential libcups2-dev libcupsimage2-dev python-serial python-pil python-unidecode
Now we need to install the thermal printer driver. Simply type in order:
cd ~ git clone https://github.com/adafruit/zj-58 cd zj-58 make sudo ./install
This will install the required drivers for the printer to work.
Lastly, create a project folder by typing:
mkdir DeathMachine cd DeathMachine
now we can install the thermal printer library by Adafruit:
git clone https://github.com/adafruit/Python-Thermal-Printer.git
The Thermal Printer is ready to use!
Now we get to the tricky part. Currently, Qiskit isn’t optimized to use on the raspberry pi, normally we would be able to install Qiskit by simply typing
pip install Qiskit
But this does not work right now, so we have to configure some prerequisites and install some dependencies manually for it to work. This will take 3 steps
First, we install retworkx:
pip install setuptools-rust curl -o get_rustup.sh -s https://sh.rustup.rs sh ./get_rustup.sh -y
this will set up the rust language environment. now we can install it by typing:
source ~/.cargo/env pip install --prefer-binary retworkx
Next, we install libcint, pyscf, and cython:
sudo apt -y install cmake libatlas-base-dev git git clone https://github.com/sunqm/libcint.git mkdir -p libcint/build && cd libcint/build cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/ .. sudo make install pip install --prefer-binary pyscf cython
Now we are ready to install Qiskit:
pip install --prefer-binary 'qiskit[visualization]==0.20.*'
To check the installations you can type:
pip list | grep qiskit
and you should see something like this:
qiskit 0.20.1 qiskit-aer 0.6.1 qiskit-aqua 0.7.5 qiskit-ibmq-provider 0.8.0 qiskit-ignis 0.4.0 qiskit-terra 0.15.2
Qiskit is now ready to use!
Step 4: The Code
I’m using IBMQ Qiskit as the Quantum Computer provider, they have many machines available for everyone to use. Simply open an account and you’re good to go!
The first thing you need to do is to open an IBMQ account. On the homepage of your IBMQ page, you will see your API token. This token will let you connect to IBMQ from your raspberry pi.
Connect to your raspberry pi using SSH, type python, and hit enter. This will open the python environment. Now type:
>>> from qiskit import IBMQ >>> IBMQ.save_account('YOUR_API_KEY')
This will save your API key to your machine. Now you’re ready to run the code!
To download the project code first create a folder for the project:
mkdir QuantumDeathMachine cd QuantumDeathMachine
and now use GitHub to clone the project to your folder:
git clone https://github.com/gocivici/QuantumDeathMachine.git
Now you can run the code by:
I had to use an Arduino because the tx RX ports on my raspberry were occupied. I’m using the Arduino to create a brıdge between the Raspberry Pi and the fingerprint sensor. Simply download the code from this step and upload the code to your Arduino.
Note: now I will be going into detail on how I’m using Qiskit to receive true random numbers, you can skip the rest if you’re not interested in the details.
Step 5: Assembly – Electronics
You can attach everything using jumper cables, no soldering is required.
First power the Thermal printer with the power supply and connect it with jumper cables to your Raspberry Pi as shown:
|Printer||Raspberry Pi 3|
After uploading the code to the Arduino connect the Fingerprint sensor to the Arduino as shown, and connect it to raspberry pi via USB.
|Finger Print||Arduino Nano|
Now you’re done with electronics and are ready for the next step!
Step 6: First Prototype & Test
For the first prototype, I directly connected the Raspberry Pi to the thermal printer and fingerprint scanner. At this stage, the main objective is to test the setup and to check if they’re working properly.
First, connect to the Raspberry Pi with SSH and locate your project folder.
To test if the printer is working properly type:
this will let you edit the code on your Raspberry Pi, go to line 29, and put # at the beginning. next, uncomment line 31
#backend = least_busy(provider.backends(n_qubits=5, operational=True, simulator=False))
This will comment the line so we can test the printer without pinging the quantum computer and waiting for it.
Now simply type:
This will get data from the IBM quantum simulator and print the result quickly. If everything is working properly you can start to build your box! If not go to step 13 for troubleshooting.
Step 7: Wood Box: Design
I designed the wooden box in fusion360 I’m attaching the design file to this step so you can customize it to your needs.
The design was mostly inspired by 1960s wood candy vending machines. I wanted to create that retro-futuristic look.
Step 8: Wood Box: Cut & Assemble
Step 9: Wood Box: Varnish
Step 10: 3D Printing
There are two 3d printed parts for this build, one is the fingerprint mount that I designed that will be glued inside the box. You can find it attached to this step, the other part is the cat skull which I found on Thingiverse:
You can download it here:
Note: enlarge the cat skull 1.5 times before printing. and don’t forget to use support.
The printer I used is the TEVO Tornado with the following settings:
Step 11: Final Assembly & Test
Now that you’ve assembled the box you can try to power up the pi and see if it works!
Again connect to your Raspberry Pi with SSH and run the code. Put your finger in the hole and wait. If you have any problems at this stage you can look at the next step for troubleshooting. If not, put your machine in front of your door for some spooky action!
Step 12: Troubleshooting
+ I can’t connect to IBM Quantum
- make sure you have typed the API code correctly. Also, it might take some time for your credentials to be verified. If the problem continues drop a comment below
+ Program stuck in Queue
- This program sends a request to an actual quantum computer, IBM has a limited amount of quantum computers and hobby use is not prioritized. If you do not want to wait for fir the queue you can simply change the provider to ibm_qasm_simulator which is a quantum computer simulator available at all times!
+ Thermal printer not printing properly
- I had a lot of issues while setting my printer up, if the prints are not visible you can try to increase the voltage. The Adafruit printer is rated for 5-9V and sometimes increasing the voltage can solve the visibility problem. If not you can also edit the file inside Adafruit-Thermal-Printer in the project folder and increase the heat values.
Step 13: What’s Next
In this step, I will list some ideas that I had. But did not find the time/resources to add them:
- Glass in front of the cat skull. I had planned for this and made some grooves for the glass but didn’t have time to find a glass piece that fits. This would complete the retro look.
- Currently, the fingerprint scanner acts only as a button, in the future I’d love to use the data from the scanner to customize the results.
- Engraving on the front panel would also be interesting, for now, I just used a sharpie to write ‘Insert Finger’
- Some art on the sides would also add more to the aesthetic of the machine.
Source: Quantum Death Machine