Added fingerprint support
This commit is contained in:
parent
798eb2f15b
commit
9d710f4f9a
@ -5,11 +5,15 @@ from qiskit import QuantumCircuit, execute, Aer, IBMQ
|
|||||||
import qiskit as q
|
import qiskit as q
|
||||||
from qiskit.tools.monitor import job_monitor, backend_overview
|
from qiskit.tools.monitor import job_monitor, backend_overview
|
||||||
from qiskit.providers.ibmq import least_busy
|
from qiskit.providers.ibmq import least_busy
|
||||||
|
import serial
|
||||||
import time
|
import time
|
||||||
|
|
||||||
#You can add remove or edit prompts from this list.
|
#You can add remove or edit prompts from this list.
|
||||||
DeathList = ["Bees","Sour milk","Cuteness","Monsters from\nthe Deep","In space,\nAlone","In Sleep","Peacefully","Toilet","Furnace","Rollercoaster","Extreme cold","Bear","Heat death of\nthe universe","Goose attack","sneezing","Boat accident"]
|
DeathList = ["Bees","Sour milk","Cuteness","Monsters from\nthe Deep","In space,\nAlone","In Sleep","Peacefully","Toilet","Furnace","Rollercoaster","Extreme cold","Bear","Heat death of\nthe universe","Goose attack","sneezing","Boat accident"]
|
||||||
|
|
||||||
|
#open serial communacition to arduino
|
||||||
|
ser = serial.Serial('/dev/ttyUSB0',9600)
|
||||||
|
|
||||||
#load account from disk
|
#load account from disk
|
||||||
provider = IBMQ.load_account()
|
provider = IBMQ.load_account()
|
||||||
|
|
||||||
@ -25,52 +29,59 @@ qc.measure([0, 1, 2, 3],[0, 1, 2, 3])
|
|||||||
#Print all avaliable quantum computers
|
#Print all avaliable quantum computers
|
||||||
print("\nAll backends overview:\n")
|
print("\nAll backends overview:\n")
|
||||||
backend_overview()
|
backend_overview()
|
||||||
#find the least busy quantum computer and print it.
|
|
||||||
backend = least_busy(provider.backends(n_qubits=5, operational=True, simulator=False))
|
|
||||||
print("\nLeast busy 5-qubit backend:", backend.name())
|
|
||||||
#backend = provider.get_backend('ibmq_belem')
|
|
||||||
|
|
||||||
#number of shots for the quantum computer. We are only throwing the dice once.
|
while True:
|
||||||
shots = 1
|
#Read serial data coming from the arduino and print it on the console
|
||||||
#execute the circuit on the avaliable quantum computer
|
read_serial=ser.readline().decode('utf-8').rstrip()
|
||||||
job = execute(qc, backend, shots=shots, memory=True)
|
print(read_serial)
|
||||||
#monitor the process
|
#execute the program if finger is detected on the sensor
|
||||||
job_monitor(job)
|
if read_serial == "Image taken":
|
||||||
#get the result and store it in result.
|
#find the least busy quantum computer and print it.
|
||||||
result = job.result()
|
backend = least_busy(provider.backends(n_qubits=5, operational=True, simulator=False))
|
||||||
#get the qubits from the result and store it in dice
|
print("\nLeast busy 5-qubit backend:", backend.name())
|
||||||
dice=result.get_memory(qc)
|
#backend = provider.get_backend('ibmq_qasm_simulator')
|
||||||
#print the received qubits
|
|
||||||
print("Received qubits: " + dice[0])
|
|
||||||
#the int command here will turn the binary to a decimal
|
|
||||||
print("Quantum dice roll result: " + str(int(dice[0],2)))
|
|
||||||
time.sleep(4)
|
|
||||||
#define and wake the Thermal printer
|
|
||||||
printer = Adafruit_Thermal("/dev/serial0", 9600, timeout=5)
|
|
||||||
printer.wake()
|
|
||||||
|
|
||||||
#print the result
|
#number of shots for the quantum computer. We are only throwing the dice once.
|
||||||
print("Printing Result..")
|
shots = 1
|
||||||
printer.justify('C')
|
#execute the circuit on the avaliable quantum computer
|
||||||
printer.feed(1)
|
job = execute(qc, backend, shots=shots, memory=True)
|
||||||
printer.setSize('L')
|
#monitor the process
|
||||||
printer.setSize('M')
|
job_monitor(job)
|
||||||
printer.println("This is how")
|
#get the result and store it in result.
|
||||||
printer.setSize('L')
|
result = job.result()
|
||||||
printer.println("YOU DIE")
|
#get the qubits from the result and store it in dice
|
||||||
import gfx.arrow as arrow
|
dice=result.get_memory(qc)
|
||||||
printer.printBitmap(arrow.width, arrow.height, arrow.data)
|
#print the received qubits
|
||||||
printer.setSize("L")
|
print("Received qubits: " + dice[0])
|
||||||
printer.println("---------------")
|
#the int command here will turn the binary to a decimal
|
||||||
printer.println(DeathList[(int(dice[0],2))])
|
print("Quantum dice roll result: " + str(int(dice[0],2)))
|
||||||
printer.println("---------------")
|
time.sleep(4)
|
||||||
printer.feed(1)
|
#define and wake the Thermal printer
|
||||||
printer.setSize("S")
|
printer = Adafruit_Thermal("/dev/serial0", 9600, timeout=5)
|
||||||
printer.print("Your Qubits: ")
|
printer.wake()
|
||||||
printer.println(dice)
|
|
||||||
|
|
||||||
printer.feed(3)
|
#print the result
|
||||||
|
print("Printing Result..")
|
||||||
|
printer.justify('C')
|
||||||
|
printer.feed(1)
|
||||||
|
printer.setSize('L')
|
||||||
|
printer.setSize('M')
|
||||||
|
printer.println("This is how")
|
||||||
|
printer.setSize('L')
|
||||||
|
printer.println("YOU DIE")
|
||||||
|
import gfx.arrow as arrow
|
||||||
|
printer.printBitmap(arrow.width, arrow.height, arrow.data)
|
||||||
|
printer.setSize("L")
|
||||||
|
printer.println("---------------")
|
||||||
|
printer.println(DeathList[(int(dice[0],2))])
|
||||||
|
printer.println("---------------")
|
||||||
|
printer.feed(1)
|
||||||
|
printer.setSize("S")
|
||||||
|
printer.print("Your Qubits: ")
|
||||||
|
printer.println(dice)
|
||||||
|
|
||||||
printer.sleep() # Tell printer to sleep
|
printer.feed(3)
|
||||||
#printer.wake() # Call wake() before printing again, even if reset
|
|
||||||
printer.setDefault() # Restore printer to defaults
|
printer.sleep() # Tell printer to sleep
|
||||||
|
#printer.wake() # Call wake() before printing again, even if reset
|
||||||
|
printer.setDefault() # Restore printer to defaults
|
||||||
|
Loading…
Reference in New Issue
Block a user