Using Half-Byte Embedded Tiny Basic to Teach

HBPortableLabIt is 2017 and we have a slew of low cost or free tools available that teach anyone how to program a computer.  Just for Windows, we have something called Small Basic, from Microsoft. It is free and has a bunch of material you can use to teach anyone, especially children, how to code. There is also Python, Minecraft and a host of other, modern tools.

So, why use something as crude as Tiny Basic? One that requires a terminal? Well, there are a few reasons you may want to do this.

Cost, for one. 

It is free. It runs on Arduino and Arduino clones.  You can use it to also teach basic electronics.

And, that is what I am doing…using it to teach not only programming, but also how computers work.  It is really more for the latter as Small Basic cannot manipulate sensors and other hardware like Tiny Basic can.  Since Tiny Basic includes instructions for reading temperature sensors and a real time clock, it is perfect for teaching things like turning on something on if the temperature gets above a given number or it if is 5 o’clock, turn off something.

I recently started doing this with my step son.  We used Embedded Tiny Basic on my ‘portable’ lab, which contains an Arduino UNO clone, a 2 x 16 LCD, breadboard and voltmeter.  We first made one green LED blink, then added a second, red LED blink.  I used Tiny Basic to explain how to talk to the LED’s and used the DELAY instruction to make the LED’s blink at a constant interval.  I also took the opportunity to teach him binary.  We had discussed it previously, but I don’t think he really got it. Until now.  Using the DWRITE statement, which takes two parameters…pin number and a zero for off or 1 for on.  Having him use that code got him to understand the concept.  Small steps.

His mind is wandering now…’I can build a robot…a game…something to tell me when Xander is coming down the hall…’ Xander is his four year old brother. 

There are those of you out there who are thinking that this is a terrible idea, using Tiny Basic, that is.  Well, no, not really.  He is getting real instruction with a more object oriented and modern language while using Tiny Basic to learn the nitty gritty of the hardware.  You do not need a modern, object oriented language to blink an LED. 

I will post future updates on our progress as well as sample code.  Below is the code we used to blink the LED’s.

110 FOR X=1 TO 50
120 DWRITE 3, 1
140 DWRITE 3,0
160 NEXT X

(For single LED-it was on digital pin 3)


Verizon takes an OATH: the death of AOL and YAHOO!

Two of the Internet’s oldest and most well known names, Yahoo! and AOL, will soon cease to exist.  With their purchases by Verizon, both companies will be merged into something called OATH.  While it remains to be seen just how well the combined company will do, one is for certain, neither company is anything like the companies we knew and loved or loathed, back in their heyday.


Yahoo! was THE search site. Period.  It was the Google of the late nineties and very early double-aughts. If you needed to find something, you went to Yahoo!.  I used Excite, a lot, but, like today and Bing, I found myself always using Yahoo!  Then, at some point, it became Yahoo! Powered by Google.  What? What’s this ‘google’?  I know it is a very big number that Carl Sagan used to talk about…but, what’s this ‘powered by google’?  So, I used Yahoo! to search for google.  The aforementioned number was the top choice, then… I click the link and…viola! This empty page, except for the search bar and ‘google’ popped up.  Well, it looks like Yahoo! has company.  I eventually gravitated to Google for my searches.  Excite went belly up, as did most of the other search engines.  But, Yahoo! and Google were there.  Oh, this ‘MSN Search’ thing too…it eventually became useful and its name changed to Bing!, but that was years later.

Yahoo! lingered on…buying up hot properties in a desperate attempt to remain relevant, but…to no avail.  It became relegated to a collection of has-been properties, a few of which are still regarded in some fashion.

Only a few short years ago, Yahoo! was worth tens of billions of dollars.  Microsoft offered something like thirty billion to buy them, but then-CEO Jerry Yang figured that he could get ‘a better deal’ and held out.  He didn’t. He lost his title.  Marissa Mayer was brought in to right the ship…she couldn’t either.  Verizon got it for a tenth of what Microsoft had offered, not even a decade ago. I won’t even talk about the lack of security. Yikes.

America Online.

What can I say? I loved AOL.  I joined in 1992.  It was my favorite past time, well, other than a certain type of human interaction, that is.

Wow, just think, I could click a button, this loud, screaching sound came out of somewhere and, in a minute, I was ONLINE!  I had all kinds of things to do…look stuff up, download pictures, software, source code, short video clips…man, that was cool.  Sure, it took a LONG time to download files that, today, are smaller than most images on a web page, but, this was the early 1990’s and the Internet was new and not widely available. Bulletin boards were the hot things and these ‘chat rooms’ on AOL…yeah, those were cool. Perhaps the ability to share my knowledge with anyone was my favorite thing to do ‘online’.  I had written several demos and applications in this Visual Basic for DOS thing that was, for a few days, HOT.  Yep, HOT.  At least in the VB ‘room’ on AOL.  My demos and app were downloaded were downloaded…what, a dozen times.  Wow.  There was one demo, a phone dialer, that was downloaded about fifty times…I thought I was IT. Yep, fifty times. How freaking cool?

Well, as time went on, this Internet thing got big. REALLY BIG. And so did AOL.  AOL WAS THE INTERNET. For many, many people.  Think about that.

By 1998 or 1999, AOL was bigger than most tech companies. So big, in fact, that it bought Time-Warner Communications in 2000.  What a colossal mistake.  What AOL never counted on was the quick adoption of  high speed internet.  And the internal resistance within the Time Warner part of the company was overwhelming.  “these snot nosed punks aren’t coming in here to tell me what to do.”

By 2005, AOL was dead.  At least, to most they were. The company was still doing OK. It eventually spun off from Time Warner.  It became a collection of popular blogs and, believe it or not, they still had a sizable dial up customer base.  However, it wasn’t enough.

Verizon bought them.

And, now, they will be called Oath.

Admittedly, there’s a certain nostalgia surrounding both companies. That sound from-whatever-when you logged into AOL.  The anticipatory ‘You’ve got mail’. The excitement when the AOL home screen popped up (and, boy, that original DOS AOL client was both beautiful and cool) and, later on, the AOL Browser.  Yahoo! on AOL.

You know, now that I think of it, I kind of miss that sound from whatever and that anticipatory ‘You’ve got mail.’  Only kind of, though.


Type in Game: PONG! (or, something close)

WP_20160911_21_48_56_Pro (3)Today’s type in game for HB Tiny Basic is a PONG! variant.  I cannot take full credit for this one, I found the original on a Japanese educational site devoted to teaching microcontroller programming, using Half-Byte’s Tiny Basic(!) (a variation of it, anyway) and for basic electronics.  The original was written in a variant of HB Tiny Basic and also used a 10k potentiometer for the controller.  I fixed a couple of bugs, got it to work with Nunchuk AND squeezed into a somewhat smaller memory footprint.

The game has a little bit of intelligence, it does a decent job of trying to guess where the ball will go, but, it is not perfect and it is possible to win the game.  There are some nice uses of the language, such as trying to include something like an OR statement when figuring out where the ball is going and takes advantage of an undocumented ‘feature’ of LINE: if you specify ‘2’ as the ‘color’ parameter, it simply inverses the pixels in the line.  This eliminates the need for multiple statements to draw and erase the paddles.  Quite clever.

Gameplay is super simple: the computer ALWAYS serves, the score goes to nine and stops. You are always on the right. You use the thumb stick up and down to control your paddle.

Weird things are likely to happen, it is not perfect and there’s no more room for improvement (challenge?)

Anyway, have fun!

10 CLS:A=0:B=0:W=48:H=32
30 BOX 0,0,W,H,1
40 U=H/2-3:V=U
50 LINE W-5,U,W-5,U+5,2:LINE 4,V,4,V+5,2
60 CURSOR 8,1:? A:IF A=9 STOP
70 CURSOR 3,1:? B:IF B=9 STOP
80 D=1:E=1:IF (U+V)&1 E=-1
90 X=5:Y=V+3:SET X,Y
100 C=50
110 IF C>0 C=C-1:GOTO 240
130 X=X+D
140 IF X=0 A=A+1:GOTO 60
150 IF X=W B=B+1:GOTO 60
160 IF X=W-6 IF Y>=U IF Y<=U+6 D=-D:TONE 440,100
170 IF X=5 IF Y>=V IF Y<=V+6 D=-D:TONE 440,100
180 Y=Y+E
190 IF Y=1 E=-E
200 IF Y=H-1 E=-E
210 IF X=W-6 IF Y=U IF E=1 E=-1
220 IF X=W-6 IF Y=U+5 IF E=-1 E=1
230 SET X,Y
240 LINE W-5,U,W-5,U+5,2
250 U=H-2-PAD(1)/8
260 IF U<0 U=0
270 IF U>H-6 U=H-6
280 LINE W-5,U,W-5,U+5,2:LINE 4,V,4,V+5,2
300 IF D=1 GOTO 370
310 IF X>=28 GOTO 370
320 IF X=27 IF A<=B GOTO 370
330 IF E=1 Q=Y+X-4:IF Q>=H Q=32-H
340 IF E=0 Q=Y-X+4:IF Q<0 Q=-Q
350 IF Q<V+3 IF V>1 V=V-1
360 IF Q>V+3 IF V<25 V=V+1
370 LINE 4,V,4,V+5,2
400 DELAY 20:GOTO 110

HB Tiny Basic Type in Game: Hurkle

For those of you who are old enough to know and remember the TRS-80, Cromemco or Altair will remember the game of Hurkle.

WP_20160908_23_16_10_Pro (2)A Hurkle is a legendary beast that, even today, remains highly elusive creature.  So elusive, in fact, that few have seen a Hurkle and lived to tell about it.  Of course, you, our intrepid adventurer, are different.  For, you, you have HALF-BYTE’S Tiny Basic and an Arduino or compatible microcontroller at your disposal.  An arsenal worthy of such of hunt.

Our Hurkle adventure takes place on a 10 by 10 grid.  You have to find the creature by deducing its where abouts on the 10 by 10 grid. Unfortunately for you, you will have from five to twenty moves in which to find the creature. Each time your adventure begins, your time is recalculated. This makes the level of difficulty even higher. You will, of course, through the use of the microcontroller, be told which direction you must travel.  Your grid follows a North-South, East-West pattern.  The X axis is West to East and Y axis is North to South. 

This simple game is rather difficult to play.  Sure, there is a way to cheat, but I’ll let you figure that out. And, once you do, you should just type NEW and move on to something else.

This game was originally published by the People’s Computer Company in Menlo Park California. I have adapted it from the Big Book of Computer Games, published in the early 1970’s.

NOTE: I had originally posted a version of the game, as part of a sample code page. The listing was broken and the game did not work correctly, as published.  This one does.  Apologies for that.

Below is the HB Tiny Basic listing.

10  CLS: ?”HURKLE”
99  # Converted to TINY BASIC by George Gray
110 N=RND(10)+5
120 G=10
210 ?
220 ? “A hurkle is hiding on a “,G,” by “,G,” grid.”
230 A = RND(G)
240 B = RND(G)
310 FOR K=1 TO N
320 ? “Guess #”,K
330 ?”X=”;: INPUT X
335 ?”Y=”;: INPUT Y
340 IF ABS(X-A)+ABS(Y-B)=0 GOTO 500
350 # ? INFO
360 GOSUB 610
380 NEXT K
420 ? “Sorry, that’s “,N,” guesses.”
430 ? “The hurkle is at “,A,”,”,B
450 ? “Let’s play again. Hurkle is hiding.”
470 GOTO 285
500 ? “You found him in “,K,” guesses!”
530 FOR I=1 TO 10
532 TONE 1000,75
534 NEXT I
540 GOTO 440
610 ? “Go “;
620 IF Y=B GOTO 670
630 IF Y<B GOTO 660
640 ? “South “
650 GOTO 670
660 ? “North “
670 IF X=A GOTO 720
680 IF X<A GOTO 710
690 ? “West “
700 GOTO 720
710 ? “East “
720 ?””

More type in goodness…Half-Byte Tiny Basic type in game, Zapp the Moon Man, take 2

zappthemoonmanRelease three of Half-Byte Tiny Basic ate up about eight more bytes of memory than the previous release, so there are now 938 bytes free for user code to reside.  My last version of Zapp the Moon Man—previously unpublished—featured the Moon man’s ability to move down the screen and attack as well as the user’s ability to move the cannon back and forth.  Sadly, for this release, I’ve had to remove the downward mobility of the Moon Man, but I have left in the user’s ability to move and also made the ‘hit box’ better, resulting in a somewhat easier game play.

This game shows off just how versatile Tiny Basic can be, how speedy the ATMega 328 is and how quickly Tiny Basic can interpret your code.

At any one time in the game, both your cannon and the Moon Man can be moving as well as the torpedo you are shooting at the moon man.  Three objects to track on the screen. In interpreted BASIC. Running on a microcontroller that was meant for turning relays on and off, not playing video games. And, it does it rather smoothly.  The jerkiness that is there is there by design, to mimmick those games from the 1970’s.

The game is pretty primitive. It resembles Space Invaders, but there is only one ‘invader’, the Moon Man, and there are no protective shields…heck, the Moon Man does not even shoot at you…yet.  It does feature some primitive, character based, animated graphics.  The Moon Man sort of looks like a Space Invader. As it moves back and forth, its antennae move and its ‘feet’ swivel side to side.  You use a Wii Nunchuck’s thumb stick to move and the Z button to fire your torpedo. The game keeps a score…10 points for every Moon Man you destroy.  You hear a launch tone when you fire and, when you hit a Moon Man, you see a little explosion like effect. And…that’s it.  Simple and not earth shattering (that will be in a future update.)

So, with out any further delay…(One note: when typing in the code, do not put in extra spaces.  Use one space between the line number and the code, and one space before line numbers in things like GOTO or GOSUB.  The listing below inserted additional spacing, you can ignore it.)

100 CLS:ECHO 0
110 A=0:B=0:O=75
120 X=10:Y=10:Z=5:F=0:D=1:S=0
140 LINE 0,48,80,48,1
150 GOSUB 700
160 GOSUB 900
170 P=PAD(3):Q=PAD(0)
180 IF P=1 F=1:TONE 200,100
190 IF F=1 GOSUB 1000
192 IF Q>200 GOSUB 600
194 IF Q<100 GOSUB 600
200 A=A+D
210 IF A>15 D=-1
220 IF A<3 D=1
230 GOSUB 1200
290 GOTO 140
600 CURSOR X,Y:?”  “;
610 IF Q>200 I=1
620 IF Q<200 I=-1
630 X=X+I
640 IF X<2 X=2
650 IF X>17 X=17
660 GOSUB 900
900 CURSOR X,Y:?CHR(150);
1000 CURSOR X,Z:?”|”;:DELAY 20:CURSOR X,Z:?” “;:DELAY 20
1050 Z=Z-1
1060 IF Z=0 IF A=X Z=5: GOTO 1100
1070 IF Z=0 IF A=X+1 Z=5: GOTO 1100
1080 IF Z=0 Z=5:F=0
1110 ?”***”;:DELAY 180:CURSOR A,B:?”XXX”;:DELAY 170:CURSOR A,B:?”   “;:A=0:B=0:F=0
1190 S=S+10
1200 CURSOR 0,5:?”SCORE:”,S;


If you come up with any improvements, optimization, etc., please let us know.

Oh, one big caveat…as it does use up all but 15 bytes of RAM, your keyboard buffer is limited to 15 bytes…Tiny Basic does not set aside a dedicate memory for keyboard input. It dwindles as you use up memory.  So, keep in mind that you may have to delete a long line and split it up—which will use at least three bytes plus the content of the line.

Casio Calculator Watches…the original smartwatch

Back in the mid 1980’s, miniaturization and micro electronics were coming into the mass market at prices people could afford.  Pocket television, pocketable computers, small calculators and digital watches were common place.  Digital Watches, which began as consumer products in the late seventies, were in full swing with watches that mimmicked analog watches, watches that played a game, ‘databank’ watches and calculator watches. 

CasioWatchOh man, the calculator watch.  Casio. 

I had to have one.

When they first came out, they were expensive.  But, seemingly, overnight, the price plunged and I could afford one.  I bought myself a Casio. I don’t remember the model number, but I recall it was sleek, black with white trim and it could store 16 memos or something like that. It was very cool.

I had that watch for years. In fact, I had it up until my last move, some five years ago. The case broke right where strap is held in place by the pin.  I think I replaced the battery once in the twenty some years I had it. WP_20160804_21_35_542_Pro

The calculator watch, like most digital watches, faded away.  Forgotten.  Or, so it seemed.

I don’t know if the current ‘smartwatch’ fad has anything to do with it, but I saw them on sale at my local CVS drug store.  For five dollars.  I had to buy it.

Now, this thing is cheap, it looks cheap and feels cheap.  But…it’s a bloody CAL-CU-LATOR WATCH!  How freaking cool is that?!  Is it just me?

Anyway, I don’t care how long it lasts, I like it and it took me down memory lane.   Best five dollars spent in a long time.

Tiny Basic, Signetics 2650 and a SC/MP: HalfByte’s early days

I am sitting here, banging away on a run of the mill HP Windowsc03742269 computer. It has a decent set of specs for today, but is no match for even a low end gaming PC or a research oriented computer. For the few games I play, the Internet browsing, code writing and Microsoft Office tasks, it works well.  Compare it to the comptuers that I started out with, however, it might as well be a Cray Supercomputer. 

Indeed, this AMD based HP would be the hottest thing in 1974, the year I can remember first ‘using’ a home computer (or, actually, ANY kind of computer.)  Back then, home computers were barely out of science fiction. In fact, that first computer was the Mark 8 ‘mini’ computer first showing up on the pages of Radio-Electronics Magazine.  It was an Intel based 8008 ‘beast’.  It was something that my Dad was working on and, once it got to a bootable point, I was hooked.

mark8_re_coverIf I remember correctly, this thing was a pain in the butt to use. Just to ‘boot’ it up, you had to key in a sequence of sixteen bytes, one bit at a time, on the front panel.  Once they were keyed in, the computer would start.  My Dad had this ‘TV Typewriter’ that we used to talk to the computer. It was, in reality, a Serial based video terminal, but it was new then.  A fellow by the name Don Lancaster designed it. My Dad bought the bare board and built it himself. That’s how things were done, you did not go to a Best Buy and just buy one. No, you built it.

So, this computer couldn’t do much.  My Dad bought something called ‘SCELBI Tiny Basic’ on a paper tape.  He had scrounged (something he was very good at) a paper tape reader and we were able to load this program into the computer. He would painstakingly key in a Tiny Basic program that I could then use.  I was only nine at the time, so programming was not something I thought about, but I was intrigued.

Fast forward a year and my father built another, more powerful, cTinyTrekBasicListingomputer. This one, a sixteen bit behemoth, was based on the Signetics 2650 microprocessor.  Man, this thing was great.  Signetics made them for quite a long time and they special because of their architecture: 16 bit internal, 8 bit bus.  It was unique among a sea of ‘me too’ chips.  More importantly, there was a dynamite version of Tiny Basic for the chip. This is when I started to figure out this programming thing.  It was addictive and started purely by accident.  See, my Dad was an engineer and built a lot of things. But, he was not good at this programming thing.  He, one day, gave me a program listing, the Tiny Basic manual he had printed out and told me to figure out how to get the program listing to work with Tiny Basic.  It was a Lunar Lander game from a very famous (at the time) book: Dave Ahl’s 101 computer games in Basic. I figured out that some statements just would not work, which ones needed small changes and I even figured out how to make some work by making a ‘gosub’ function-which is what I called a subroutine then.  It took me several weeks, but i got the game to work. Then, I found out, that my Dad already had a version that worked and was specifically for that version of Tiny Basic.  At first, I was upset. All that time I wasted.  Something struck me though…I had a blast making it work.  That is what he had hoped would happen. 

It paid off too.

Now, I had the bug in me. I WANTED to figure out and learn this programming stuff.  I started making small programs…mostly code that made Tiny Basic do thing it was not supposed to do. Like string handling and ‘graphics’ by making the cursor move about the screen and ‘drawing’ with ASCII characters.

I also got my very own computer. 

That computer, based on the National Semiconductor SC/MP, had 16k of RAM (quite a bit then) and a version of Tiny Basic called NI/BL.  Nibble, as I called it, was quite sophisticated for its day. Written for control applications (the SC/MP was an industrial controller, much like the ATMEL line of microcontrollers) Nibble was able to directly talk to the hardware, had the DO-UNTIL construct for looping, direct memory addressing, direct serial line addressing and memory management.  The computer also a cursor addressable video terminal and cassette I/O, which required me to write a ‘loader’ application in Nibble.  I could save my code just by typing LIST and pressing record, but I had to write code to load it back because the cassette was too fast for the input routine of Nibble.  I had to read the tape, 128 bytes at a time, poke it into a memory page, wait 1 second, and get more code.  The cassette was controlled by a relay, so I could start and stop it as needed. A 2K program took a couple of minutes to load, but it was much faster than typing.  I eventually had a paper tape reader and punch as well.

Ferguson-BigBoard-IBy now, my Dad had a disk drive based Z80 computer and something called ‘CP/M’.  It was a computer made from the ‘furgeson big board’.  The Big Board was very close to the design of modern day motherboards: integrated memory, cpu logic, video terminal and disk controller on one board.  Prior to that, we used the ‘S-100’ bus.  In this setup, the ‘motherboard’ only contained the connectors for the bus itself and no real logic.  Some had a power supply, most did not.  Each piece of the computer was on a separate board.  The Big Board, however, had it all on the SAME board.   It was very cool and was used as the design in the first real ‘personal’ computer from Xerox: the Xerox 820.  I had one.  My dad was able to get the board and built it into a desk, along with two 8 inch disk drives, keyboard, monitor and a printer.  I was set now.  In the interim, I also bought a ZX-81 and got a TRS-80 Color Computer. But, the Xerox is what I did my ‘real’ stuff on and the others were relegated to games or collected dust. 


Before the Xerox 820, my passion was the ZX-81 because I BUILT IT.  zx81adI bought the kit with money got back on my very first income tax refund.  Yep. $99 was sent to Sinclair for the kit.  Wow, I built it and…it did not work.  In looking at my work and the schematic, my Dad figured out that I was missing a resistor…to pull the Z80 reset pin low (I think) which allowed it to start up. I may have that backward, it has been so long. Once I soldered the resistor into place (there was a spot on the board, and it was on the schematic, but it was missing from the parts list and instructions) the Zed Ex came to life. I was thrilled. My Dad, he was unimpressed.  Not sure why, but he always hated Sinclair and anything Uncle Clive ever did. That little computer was awesome. To this day, I wish I still had the six or so that I had (I collected them for a bit, was going to make something great…never did.)  This thing introduced me to wanting to get into electronics more, but that waited until recently with my Arduino stuff.

The TRS-80 Color Computer also grabbed my heart.  I had one well into the late 1990’s or early double 00’s.  I don’t remember when, but I gave it to some kid at a hamfest.  Games, peripherals, the computer, etc.  He was so excited. I hope it inspired him. At any rate, the CoCo introduced me to GUI’s too.  I wrote a couple in Extended Basic.  Went on to write one in assembler, but it sucked.

Looking back, however, I think I was happiest on that 2650 and the SC/MP. They were, comparatively speaking, so basic and so primitive and the things I could do with them. Man, that was exciting. Exciting enough to keep me interested (well, there was that time when I discovered the opposite sex, but that is something for another time…and blog) in pursuing programming as a career.

I look back with much fondness and some sadness as well.  Those were the days when I bonded with my Dad.  Learned quite a bit and was genuinely excited.  Names like Les Soloman, Don Lancaster and Dave Ahl were the ‘rock stars’ of my world.  They were among the founders of the home computer revolution that you never hear about. Sure, I saw Microsoft rise, witnessed Apple’s few innovations (Apple ][, Apple //c) and saw IBM create an entire industry (the Wintel computer) but, more importantly, that time with my Dad and a small number of class mates in high school. Neil, Patrick…you guys rock.  Sadly, though, those computers are history and my Dad…well he is too.

I miss those days.