After completing the circuit, the user can enter data into the code, and it will be transferred to the smartphone via Bluetooth, displaying on the smartphone screen.
import bluetooth def start_bluetooth_server(): server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) port = 1 # You can use any available port server_sock.bind(("", port)) server_sock.listen(1) print("Waiting for Bluetooth connection...") client_sock, client_info = server_sock.accept() print("Accepted connection from", client_info) try: while True: message = input( ) if not message: break client_sock.send(message) print(f"Sent: {message}") except KeyboardInterrupt: print("Interrupted by user") finally: print("Closing connection...") client_sock.close() server_sock.close() print("Server closed") if __name__ == "__main__": start_bluetooth_server()