Import serial library
Import time library
Open serial connection (COM3, 9600 baud rate)
Define send_command function:
Accept command as input
Encode command and send it via serial connection
Delay for a short period
Loop:
Prompt user for command input
If command is 'q', exit loop
If command is valid:
Call send_command function with the command
Else, display error message
Close serial connection