Learn TINYBASIC with Real Code Examples
Updated Nov 21, 2025
Code Sample Descriptions
1
TinyBasic Button Press Counter
10 LET count = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 END
1000 REM UpdateUI
PRINT "Button Count: "; count
RETURN
2000 REM ButtonPress
count = count + 1
GOSUB 1000
RETURN
Counts button presses and updates the display.
2
TinyBasic Theme Toggle
10 LET isDark = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 END
1000 REM UpdateUI
IF isDark THEN PRINT "Theme: Dark" ELSE PRINT "Theme: Light"
RETURN
2000 REM ToggleTheme
isDark = 1 - isDark
GOSUB 1000
RETURN
Toggles between Dark and Light themes.
3
TinyBasic Score Tracker
10 LET score = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 3000
50 GOSUB 4000
60 END
1000 REM UpdateUI
PRINT "Score: "; score
RETURN
2000 REM Increment
score = score + 10
GOSUB 1000
RETURN
3000 REM Decrement
score = score - 5
GOSUB 1000
RETURN
4000 REM Reset
score = 0
GOSUB 1000
RETURN
Tracks a score with increment, decrement, and reset.
4
TinyBasic Simple Timer
10 LET time = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 END
1000 REM UpdateUI
PRINT "Time: "; time; " sec"
RETURN
2000 REM Tick
time = time + 1
GOSUB 1000
RETURN
Counts time in seconds and prints elapsed time.
5
TinyBasic Health Tracker
10 LET health = 100
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 3000
50 END
1000 REM UpdateUI
PRINT "Health: "; health
RETURN
2000 REM Damage
health = health - 20
GOSUB 1000
RETURN
3000 REM Heal
health = health + 10
GOSUB 1000
RETURN
Tracks health with damage and healing.
6
TinyBasic Level Tracker
10 LET level = 1
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 GOSUB 3000
60 END
1000 REM UpdateUI
PRINT "Level: "; level
RETURN
2000 REM NextLevel
level = level + 1
GOSUB 1000
RETURN
3000 REM ResetLevel
level = 1
GOSUB 1000
RETURN
Tracks game levels with increment and reset.
7
TinyBasic Coin Counter
10 LET coins = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 GOSUB 3000
60 END
1000 REM UpdateUI
PRINT "Coins: "; coins
RETURN
2000 REM CollectCoin
coins = coins + 1
GOSUB 1000
RETURN
3000 REM LoseCoin
coins = coins - 1
GOSUB 1000
RETURN
Counts coins collected and lost in a game.
8
TinyBasic Ammo Tracker
10 LET ammo = 10
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 GOSUB 3000
60 END
1000 REM UpdateUI
PRINT "Ammo: "; ammo
RETURN
2000 REM Shoot
ammo = ammo - 1
GOSUB 1000
RETURN
3000 REM Reload
ammo = 10
GOSUB 1000
RETURN
Tracks ammo usage with shoot and reload actions.
9
TinyBasic Star Collector
10 LET stars = 0
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 GOSUB 3000
60 END
1000 REM UpdateUI
PRINT "Stars: "; stars
RETURN
2000 REM CollectStar
stars = stars + 1
GOSUB 1000
RETURN
3000 REM LoseStar
stars = stars - 1
GOSUB 1000
RETURN
Counts collected stars and displays progress.
10
TinyBasic Power-Up Timer
10 LET powerTime = 10
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 2000
50 GOSUB 3000
60 END
1000 REM UpdateUI
PRINT "Power-Up Time: "; powerTime
RETURN
2000 REM Tick
powerTime = powerTime - 1
GOSUB 1000
RETURN
3000 REM Reset
powerTime = 10
GOSUB 1000
RETURN
Counts down power-up duration and resets.