Posts

Showing posts with the label freebasic

Legacy computer home automation server

Image
Using legacy systems to do home automation when an Arduino or Raspberry Pi may not be available. They can work just as well.  Server is a Pentium III with Ubuntu and Apache2. Enabled CGI (common gateway interface). Wrote all my own scripts using html, bash, and compiled freebasic (controls the leds).    Leds are connected to the parallel port via a home made adapter cable. Most of the code and interfaces are described in previous articles.  Added the video to the home web page: Time to control real world object such as a coffeemaker. For more information: http://www.tldp.org/HOWTO/text/Coffee

Pick it for me.

Image
Random numbers can be very important in games. No matter whether you use it for possible outcomes or graphics characters, you can have a bit of fun. If you look for the oracle on this blog, you can one way a random number can be used. loop Print a random ascii character to the screen sequentially without a linefeed. until done. First let's consider freebasic to print out random characters to a screen to make the computer it has gone haywire, it is basically the same code. Some people used to use code similar to this on the old TRS-80 to confuse sales people. [code] for x = 1 to 2000     Randomed = INT(RND * ((255 + 1) - MIN) + MIN)     ?chr$(Randomed); next x [/code] Output finale: Now let us look at how it might be done in C. [code] #include <stdio.h> #include <stdlib.h> int main() {   int c, n;   for (c = 1; c <= 1000; c++) {      n = rand() % 255 + 1;      pr...

Software Clock

Image
Compile the following code in the qb45 or freebasic compiler.  (c:\>fbc -lang qb clock.bas). Porting to C should be a piece of cake. [code]  '===================================================================== ' thetimeis ' author: computothought '--------------------------------------------------------------------- ' housekeeping ' arrays dim blank$(7) dim num$(10,10) dim colon$(7) ' data num$(0, 1) = "  ###  " num$(0, 2) = " #   # " num$(0, 3) = "# #   #" num$(0, 4) = "#  #  #" num$(0, 5) = "#   # #" num$(0, 6) = " #   # " num$(0, 7) = "  ###  " num$(1, 1) = "   #   " num$(1, 2) = "  ##   " num$(1, 3) = " # #   " num$(1, 4) = "   #   " num$(1, 5) = "   #   " num$(1, 6) = "   #   " num$(1, 7) = " ##### " num$(2, 1) = " ##### " num$(2, 2) = "#     ...

Text clock.

Image
Text clocks seem to be a big thing right now. Here is one written in qbasic. qb64 result: Freebasic result: Source code: [code] 'UNSEEN'S NOT A STANDARD CLOCK DIM SEC AS STRING, MIN AS STRING, HR AS STRING SCREEN 0: COLOR 3, 15: WIDTH 40, 25 CLS DO HR$ = LEFT$(TIME$, 2): MIN$ = MID$(TIME$, 4, 2): SEC$ = RIGHT$(TIME$, 2) LOCATE 1, 1: PRINT HR$; ":"; MIN$; ":"; SEC$ 'MINUTES IF (VAL(MIN$) <  10 and val(min$) >= 5) OR (VAL(MIN$) >= 55 AND VAL(MIN$) < 60) THEN COLOR 12, 15 LOCATE 3, 2: PRINT "FIVE": COLOR 3, 15 IF VAL(MIN$) >= 10 AND VAL(MIN$) < 15 OR VAL(MIN$) >= 50 AND VAL(MIN$) < 55 THEN COLOR 12, 15 LOCATE 3, 8: PRINT "TEN": COLOR 3, 15 IF VAL(MIN$) >= 15 AND VAL(MIN$) < 20 OR VAL(MIN$) >= 45 AND VAL(MIN$) < 50 THEN COLOR 12, 15 LOCATE 3, 13: PRINT "FIFTEEN": COLOR 3, 15 IF VAL(MIN$) >= 20 AND VAL(MIN$) < 25 OR VAL(MIN$) >= 40 AND VAL(MIN$) < 45 THE...

Raspberry Pi web server setup.

Image
Web server software setup. There are two basic programs we want to install. Apache2 the web server and PHP a programming language for use with the server. $ sudo apt-get install apache2 php5 libapache2-mod-php5 php5-cli That will take a little while to install. Be patient. Then you need to do a fix for the server. $ sudo nano /etc/apache2/conf.d/name For example set add ServerName localhost or any other name: ServerName localhost or you could use Servername yourservername Save the file and restart Apache 2 $ sudo service apache2 restart Test the server: Point a browser to the RPi You should get the setup page. Now we need to test the PHP install.. $ cd /var/www You should already see index.html with the code that shows you the home page. Now we need to create a new page $ sudo nano phpinfo.php Save and exit. Now point your browser to yourhostname/phpinfo.php You should get the PHP status page. Now you should be ready to roll. Note: ...

Freebasic on the Raspberry Pi.

Image
So happy that I can run even if it is an old version of Freebasic on the Raspberry Pi. Freebasic  is a lot like but not exactly like qbasic. The first thing I did was to port a spreadsheet to the unit. To set up Freebasic, the first thing I did was to download the tarball and the extract it. (from sourceforge.net ) $ tar xvf fbc-0.91.0-pi-debian.tar.gz Install it. $ sudo ./install.sh -i And lastly install a few goodies to make the install complete.  $ sudo apt-get install libxext-dev libncurses5-dev libx11-dev libxpm-dev libxrandr-dev libstdc++6-4.4-dev You should be able to write a test program to see if the install worked. In an editor, type a simple program. $ vim test,bas PRINT "hello!" Compile it $ fbc test.bas Run it. $ ./test hello! There is more to it than that but that is a quickie starter.

Simple pie chart with Qbasic/Freebasic.

Image
Just something to play with. DIM Angle(1) DIM MyData(0 TO 4) DIM C(1 TO 4) Pi = 4 * ATN(1)                                                   '  Can use 3.141593 Radius = 200                                                      '  Change these to suit your taste  Xc = 319                               ...