Skip to content

Instantly share code, notes, and snippets.

@mdavey
Created August 11, 2025 10:20
Show Gist options
  • Save mdavey/0f281fcaeea33f9d4d2a879cb9024631 to your computer and use it in GitHub Desktop.
Save mdavey/0f281fcaeea33f9d4d2a879cb9024631 to your computer and use it in GitHub Desktop.
'Power dbm/watts conversion program for MMBasic
sub Wait_For_Enter ()
PRINT
INPUT "Press enter to return to menu..."; DUMMY$
end sub
Sub Dbm_To_Watts()
CLS
INPUT "Enter power in dBm: ", DBM
WATTS = (10 ^ (DBM / 10)) / 1000
PRINT
PRINT DBM; " dBM is equal to "; WATTS; " watts"
PRINT
Wait_For_Enter()
end sub
Sub Watts_To_Dbm()
CLS
INPUT "Enter power in watts: ", WATTS
IF WATTS <= 0 THEN
PRINT "Invalid input."
Wait_For_Enter()
return
endif
DBM = 10 * (LOG(WATTS * 1000) / LOG(10))
PRINT
PRINT WATTS; " watts is equal to "; DBM; " dBm."
PRINT
Wait_For_Enter()
END SUB
MAIN_MENU:
CLS
PRINT "RF Power Conversions"
PRINT
PRINT "Options:"
PRINT
PRINT "1. dBm to wats"
PRINT "2. Watts to dBm"
PRINT "3. Exit"
PRINT
INPUT "Enter choice (1, 2, OR 3): ", CHOICE
PRINT
IF CHOICE = 1 THEN Dbm_To_Watts()
IF CHOICE = 2 THEN Watts_To_Dbm()
IF CHOICE = 3 THEN END
GOTO MAIN_MENU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment