It’s here! Half-Byte Tiny Basic 2 for Arduino and compatibles

It’s back! Better than ever. Yes, that’s right, Half-Byte Tiny Basic 2 for Arduino.  The first was so good, there just had to be a follow up.  And this version has even more fun stuff like new graphics functionality like ARC and CROSSHAIRS.  New math in SIN and COS.  Enhanced LIST statement and more.  Read on for more on the new goodies.

Tiny Basic weather?

WP_20140826_22_20_46_ProWell, yes and no. Yes in that support for the DHT-11 temperature and humidity sensor has been included. No, it won’t generate satellite images or predict snow storms. But, if you have a project where you need to capture the temperature and/or humidity, this will work.  Temperature is returned in either Celsius or Fahrenheit.  TEMP( 0 ) will return the temperature in Celsius and TEMP( 1 ) will return it in Fahrenheit. HUMIDITY with any value parameter will return the relative humidity.

EXAMPLE:

100 CLS
110 PRINT “Temperature: “, TEMP( 0 ),”C”
120 PRINT “Relative Humidity: “,HUMIDITY( 0 ),”%”
130 DELAY 4000
140 GOTO 100

New Graphics Functions

POLY

Poly will draw an abnormal circle. It is abnormal because the sides will not be ‘normal’. They will be straight lines IF the radius is small. As the radius gets larger, the circle looks more normal, then it begins to ‘explode’. Poly gives nice random like patterns or explosions for games.

POLY start_x, start_y, radius, points, color
Where start_x and start_y are the screen position to draw the poly;
Radius is width of the circle;
Points is the size of the ‘sides’ of the circle;
Color is black or white
100 CLS: CENTER: PRINT “EXPLODING”
110 R=RND(20): P=RND(15)
120 POLY 40,20,R,P,1
130 DELAY 100
150 POLY 40,20,R,P,0
160 DELAY 100
170 GOTO 110

 

INVERT

One thing you can do to get a user’s attention is to flash the screen. Tiny Basic allows you to do this quickly, by using the INVERT statement. It takes no parameters and its syntax is simply:

INVERT
100 CLS
110 CURSOR 3,2
120 PRINT “TO CONTINUE WITH”
130 CURSOR 3,3
140 PRINT “PROCESSING, PRESS C”;
150 A=INKEY(0)
160 IF A=67 GOTO 210
170 INVERT
180 DELAY 500
190 GOTO 150

210 #CONTINUE…

Starting at line 150, we wait for a key to be pressed. If it is C, goto 210 else, we invert the screen, wait a half second and do it again. If there is no delay, the screen would be just obnoxious. Inserting a delay slows it down a bit.

 

CROSSHAIRS

Crosshairs draws a graphical ‘t’ on screen. The ‘t’ can be controlled to be tight and small or apart and big. This is useful for creating crosshairs on screen for shoot them up game, driving game or some other type of game. Or, use it for art.

 

ARC

ARC draws a partial circle, a PIE piece.
ARC has eight parameters:
Start x, start y, radius, angle, end radius, color, pie, fill
Start x and y are center point
Radius is just that
Angle is the angle of the arc
End radius is the end point
Color is 0 or 1 for black or white
Pie is 0 or 1
Fill is 0 or 1 and will fill the arc or leave it open

WP_20140930_22_18_20_Pro

CENTER

CENTER will start PRINTing at the center point of a line

LIST

The LIST statement has been enhanced.  You can now list a single line, five lines or the entire program.

LIST by itself lists the whole program
LIST number- will list the program starting at number and go for five lines
LIST number. will list just that line.

MATH

COSine and SINe have been added.

a=COS( x )
b=SIN( y )
The functions were contributed by reader Jim F – Calgary Alberta Canada , thanks Jim!

OTHER STUFF

The overall interpreter is a bit speedier as there have been some optimizations and I was able to cut a lot of redundant code out. Because the functions added some RAM overhead, I lost about 30 bytes, so usable memory is around 970 or so bytes.  This is plenty for small games, control applications and for learning. It is also enough for great demos too.  If you use this on a Mega, then you will have a lot more memory. Just remember, you will need to change the pins used at the top of the code (for nunchuck, TV OUT, sound and the DHT-11 if you use that.)

To run Tiny Basic on your Arduino, download the package below. Put the Half-Byte Tiny Basic files in your Arduino directory. The TV OUT and DHT-11 libraries need to be imported into your IDE. Please follow the procedure for importing libraries. The Fonts need to go in the the TVOut font directory.  Next, open the Half-Byte Tiny Basic in your IDE and then compile and upload to your Arduino.

DOWNLOAD IT

You can download all files to install Tiny Basic 2 on your Arduino here. Tiny Basic 2  manual is here.

101_3353

26 thoughts on “It’s here! Half-Byte Tiny Basic 2 for Arduino and compatibles

  1. What pins do I connect the keyboard and tv on the Arduino? Sorry, I’m probably missing something really simple here.

    1. Hi Dave!
      Thanks for visiting. The pinouts I used–and the default for Tiny Basic–are: Keyboard (PS/2 FEMALE Connector):
      Pin 1 to Pin 5 on chip
      Pin 2 to GND
      Pin 3 to Pin 4 on chip
      Pin 5 to +5

      Video:
      Center video (470OHM Resistor) pin connected to pin 9
      Sync Resistor (1K OHM)connected to pin 7
      Outer video pin connected to GND
      Audio connected to pin 11
      Outer Audio connected to GND
      These are UNO and UNO compatibles.

      1. Hi, Thanks for the fast reply. I’ll be building this on stripboard (Veroboard) in the next few days. I’ll let you know how I get on.

      2. Awesome! We are looking forward to your results. If you want, write something up and I’ll post it here. Pictures would be good too. You can email it me. If not, just post something here. Either way, thanks for coming by and come back often.

      3. Hi, Just trying out your code but having problems with . I just cannot find this library anywhere. Any ideas? Thanks again.

      4. It says the item does not exist on the link you provided. If you have the files you could always email them to me. Thanks

      5. Sorry, found them. I was clicking on the wrong thing. Thanks Again, you’ve been a great help. I’ll keep you posted how I get on.

  2. Hi, George – Great Project! I’ve been wanting to make my own tiny computer ever since I started messing with these AVR chips, and your code is perfect – thanks for posting the old libraries, too. Question: Does it matter what clock speed/source (i.e. fuse settings) I burn the chip fuses with?

      1. Actually, I take that back. The video may have a problem if run at any speed other than the 16mhz of the UNO or my board.
        Of course, you can adjust the timings in the TVOut library, but this is something I’ve not done.

  3. Can you help me ? I can’t load de sketch to Arduino, the IDE says:

    HalfByteTinyBasic:75: error: variable ‘keywords’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    static unsigned char keywords[] PROGMEM = {

    ^
    and

    deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

    TV.print_centered(“”);

    ^

    1. What version of the IDE are you using? Try something prior to 1.6.x. For PROGMEM, they changed the way you use it. It MUST be a CONST now, when you declare the variable:
      static const unsigned char keywords[] PROGMEM = {
      The second error does not ring any bells. I know the latest version of the Arduino IDE does not like HalfByte Tiny Basic. I am working through the problems, but, for now, use an older version if you can.

  4. Arduino:1.8.1 (Windows 10), Kart:”Arduino Nano, ATmega328″

    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

    from sketch\HalfByteTinyBasic.ino.cpp:1:

    HalfByteTinyBasic:75: error: variable ‘keywords’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    HalfByteTinyBasic:166: error: variable ‘func_tab’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    HalfByteTinyBasic:209: error: variable ‘to_tab’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    HalfByteTinyBasic:214: error: variable ‘step_tab’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    HalfByteTinyBasic:219: error: variable ‘relop_tab’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    HalfByteTinyBasic:237: error: variable ‘highlow_tab’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    C:\Users\YiÄŸit\Desktop\TinyBasic2\HalfByteTinyBasic\HalfByteTinyBasic.ino: In function ‘void loop()’:

    HalfByteTinyBasic:1742: error: ‘class TVout’ has no member named ‘crossHair’

    HalfByteTinyBasic:1804: error: ‘class TVout’ has no member named ‘draw_arc’

    HalfByteTinyBasic:1905: error: ‘class TVout’ has no member named ‘drawArc’

    HalfByteTinyBasic:2205: error: ‘class TVout’ has no member named ‘print_centered’

    “TVout.h” için birden fazla library bulundu
    Kullanılıyor: C:\Users\Yiğit\Documents\Arduino\libraries\TVout
    Kullanılmıyor: C:\Program Files (x86)\Arduino\libraries\TVout
    “PS2Keyboard.h” için birden fazla library bulundu
    Kullanılıyor: C:\Users\Yiğit\Documents\Arduino\libraries\PS2Keyboard
    Kullanılmıyor: C:\Program Files (x86)\Arduino\libraries\PS2Keyboard_014A
    exit status 1
    variable ‘keywords’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    //i have these problems can ı help me please

    1. Download the tvout and keyboard libraries from my page. Search for tiny basic 3 on Half-Byte and download that package… Should have everything you need.

Leave a comment