Happy Birthday Small Basic – The 8th Anniversary


667D55F8-13D6-4615-8A28-0C4C6E3C73CB

Can you read the message on the LCD in this photo?  Happy Birthday, Small Basic!

Today's Small Basic program is

' Send Text to Serial Port
' Version 0.1
' Copyright © 2016 Nonki Takahashi. The MIT License.
 
TextWindow.Title = "Send Text to Serial Port"
Init()
While "True"
  txt = TextWindow.Read()
  LDCommPort.TXString(txt + LF)
EndWhile
 
Sub Init
  LF = Text.GetCharacter(10)
  status = LDCommPort.OpenPort("COM3",9600)
  LDCommPort.SetEncoding("Ascii")
EndSub

And the Arduino sketch is

// LCD control via I2C from serial port

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Variable definition
const int r = 2;                      // rows
const int c = 16;                     // columns
LiquidCrystal_I2C lcd(0x3F, c, r); // set the LCD address to 0x3F
String inputString = "";              // received string
boolean stringComplete = false;       // received?

void setup()
{
  lcd.init();                         // initialize the lcd 
  lcd.backlight();
  Serial.begin(9600);
}

void loop() {
  if (stringComplete) {
    int len = inputString.length();
    lcd.clear();
    if (len <= c) {
      lcd_print(inputString);
    } else {
      lcd_print(inputString.substring(0, c));
      lcd.setCursor(0, 1);
      lcd_print(inputString.substring(c));
    }
    inputString = "";
    stringComplete = false;
  }
}

// Print string to LCD
void lcd_print(String str) {
  int len = str.length();
  for (int i = 0; i < len; i++) {
    lcd.print(str.charAt(i)); 
  }
}

// Serial event handler
void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();  // read 1 byte
    if (inChar == '\n') {
      // flag on if reseived newline
      stringComplete = true;
    } else {
      inputString += inChar;  // append it to the string
    }
  }
}

See Also


Comments (19)

  1. YLed says:

    Allways articles with great value !

  2. YLed says:

    I so want to see the next version of Small Basic, v1.3 i guess. I’m looking forward to try it !!
    I am certain that they will be several new functions, commands, instructions which will be added to the base engine. Congratulations Microsoft for this great free software that makes us return to our passions of amateur programmers. !

    Here is according to (wiki) the version history:

    2008-10-23 V0.1 released
    2008-12-17 V0.2 released
    2009-02-10 V0.3 released
    2009-04-14 V0.4 released
    2009-06-16 V0.5 released
    2009-08-19 V0.6 released
    2009-10-23 V0.7 released
    2010-02-04 V0.8 released
    2010-06-11 V0.9 released
    2010-11-17 V0.91 released
    2011-02-08 V0.95 released
    2011-07-12 V1.0 released
    2015-03-27 V1.1 released
    2015-10-01 V1.2 released

    1. Tryhest says:

      wishlist for v 1.3:
      -constants
      -replace cmd
      -functions
      -subs with args
      -local vars
      -debugger
      -include external files (like $I directive)
      -publish pics
      -background color change for edit window

      1. Tryhest says:

        also code hiding/expanding blocks, very welcome for long listings
        i find sb ide ++ but it’s just for sb1.0(( can it be updated for sb v1.2?

        1. Do you have a link to this? I forgot who created it.

          Thanks!

          1. Thanks! I posted on the thread to ask Gungan if he was up for making a 1.2 version.

            Thanks!

      2. YLed says:

        my wishlist to Santa Claus for SB V1.3 :))

        Sound.playmusic ( lenght of notes 1 to 64 to 1 to 128)
        Sound.playmusic ( possibilities to play 4 notes in the same time , to program chords )
        an simple alternative graphicswindow command to textwindow.read(), like graphicswindow.read() , to enter keyboard data intercative.
        a no border graphicswindow ( full screen)
        a way for MATH to handle bigger number like 10 power 75 , ex: ( Sun mass 10^30 multiply by Earth mass 10^24 ) = 10^54 , gravitational law computing.
        and finally and finally, to improve the speed of the setpixel command.

        1. Tryhest says:

          setpixel speedup is already done in ld xtension by LDImage.GetWorkingImagePixel and LDImage.SetWorkingImagePixel
          also can be done by 2d matrix LDImage.GetImagePixels and LDImage.SetImagePixels

          1. YLed says:

            Setpixel, getpixel, getRGB, there are several functions LD which are actually, yes included in the LitDev extensions, but I wish that they be included in the standard version of base SB 1.3, the only reason it’s when there is a challenge of proposed over a monthly period, we have no right to use the LD extensions or other extensions , which limit us in our programs have submitted to these challenges.
            AND, we must ask Santa Claus all of our wish, like this one : I would like SB version 1.3 to open for example a 25 megapixels of my Nikon RAW images and save them in tiff. 16-bit format, so that I can do special effects, like solarization, Posterization, ect.. wow would’nt be great !!!!!!

          2. Tryhest says:

            u should use the ms paint.net app then, which uses c# language and scripts to control each pixel very fast

          3. I got some push back from our community council and teachers about adding more into the core library that’s currently available as extensions. We’ll get some new data in the future and see if we want to make that request again. But one solution is the Extension Manager, which makes it easier to find, install, and turn on/off extensions.

      3. Debugger is high on our list!

        A lot of the other requests were omitted purposefully (a debugger was as well) to make Small Basic the easiest syntax-based language to learn!

        Debugger rose to the top because a lot of teachers find it necessary to teach debugging as part of the core programming experience.

    2. That’s right! Nice bit of history! Our biggest improvement for 1.3 is a web version!

  3. YLed says:

    Hi Nonki,
    just a little things, for your main title of this article:

    the word anniversary is written like this: anniversary
    🙂

  4. YLed, thank you for your comments. I will fix the title.
    Tryhest, I will copy your wish list to a wiki article. Thanks.

Skip to main content