The ATTiny 85 Handheld Game – New Games

The ATTiny 85 Handheld Game – New Games

Half-Byte ATTiny-85 Hand Held Game, based on the WebBoggles design

There are several new games contributed to the hand held game devised by Webboggles (and adapted by me for the Half-Byte Handheld Game.) Check them out by going here: https://drive.google.com/open?id=0BxGfuaPdM4n0Nkt5TDI4azd1Rmc

Among the new games are:

  • PONG
  • FROGGER
  • SPACE INVADERS
  • TETRIS
  • and the original games in bundles of two

There are variations of the hardware, for example, the PONG game really needs a potentiometer or paddle control. Schematics are included.

The games are free for personal use.  

Please show WebBoggles your appreciation.

Tetris Schematic:

Tetris Multi-Button

Frogger Schematics:

Frogger Attiny Schematic

Running Tiny Basic on the Micro: Bit

I was looking for some things to use in teaching my kids some programming with the BBC Micro: Bit and came across Tiny Basic on the Micro: Bit.  The implementation of Tiny Basic is a cross between Arduino Tiny Basic and Palo Alto Tiny Basic.  It’s very comprehensive and includes things like LED control, sensor reading, and serial communication via USB.  This is a great way to introduce kids and adults alike to the wonderful world of programming, hardware and the Micro: Bit. 

Full source is available, unfortunately, the GITHUB is in Japanese.  HOWEVER, you can use Google or Bing translate to translate the page for you. 

I have taken the liberty of bringing some of the information to you.  I had a bit of an issue making it work, so, here’s what I found so you don’t have to worry about it.

WHERE TO DOWNLOAD

You can, of course, download the full source and associated libraries and compile it yourself and then import into the Micro: Bit.

BUT….

All you really need is the compiled HEX file.  To get that…

  1. Download
    https://github.com/Tamakichi/ttbasic_microbit/archive/master.zip

  2. Connect the  micro:bit.
    You should see the Micro:bit drive “MicroBIT”
    Unzip the download file ttbasic_microbit-master.zip.
    From the bin folder, copy the file  ttbasic_microbit.ino.hex to the micro:bit (you can drag and drop it into the Micro: Bit folder.

  3. When the program write is finished, connect the serial with terminal software (TeraTerm, for example) etc.

  4. Set up your terminal software as follows:

    Terminal communication conditions Communication speed 115200bbs, parity none, stop bit 1, flow control: No; set the transmission delay to 1 ms/character.

Once you have downloaded the hex file to the micro: bit and setting up and connecting to your favorite terminal app, you should reset the micro: bit and see something like:

tinybasicformicrobitThe dialect of Tiny Basic is similar to Half-Byte Tiny Basic, but, it has far more capability.  With more memory to work with, no graphics and Micro: Bit hardware, there are a bunch of things you can do.

The following is copied directly from the web site.

Available keys

  • Cursor Move Cursor Key
  • Delete, CTRL-X: Delete characters at cursor position
  • BackSpace: Delete characters before cursor and move forward
  • PageUP, PageDown, ctrl-r: Refresh the screen
  • HOME, END: Move cursor to left or right edge in row
  • INS: Toggle toggle switching for insert sand
  • Enter: Line entry confirmed
  • Press ESC twice, ctrl-c: suspend execution program
  • CTRL-L, F1: Clear Screen
  • CTRL-R, F5: Screen Refresh

Pin-assigning and pin-specifying

  • Pin: Specified by PN0 through PN32, or 0 through 32
  • Pin mode specification command :GPIO pin , OUTPUT | INPUT_PU INPUT_PD INPUT_FL”
  • Digital Output:OUT Pin, HIGH| LOW|0|1
  • Digital input: variable =IN(pin)
  • Analog input: variable =ANA(pin)

Sample Program

Colored text on the screen

10 FOR I=0 TO 10
20 FOR J=0 TO 10
30 COLOR RND(8): ? "*";
35 WAIT 100
40 NEXT J
50 ?
60 NEXT I

Flashing LEDs on board


5 MATRIX OFF
10 GPIO 3,OUTPUT
20 OUT 3,LOW
30 GPIO 26,OUTPUT
35 "@loop"
40 OUT 26,HIGH
50 WAIT 300
60 OUT 26,LOW
70 WAIT 300
80 GOTO "@loop"

Analog value display

10 CLS
20 A=ANA(PN0)
30 LOCATE 5,5:?A;"    "
40 GOTO 20
Button input determination
10 CLS
20 IF !IN(BTNA) ?"Button A"
30 IF !IN(BTNB) ?"Button B"
40 WAIT 200
50 GOTO 20
LED Matrix Dot Display
10 CLS 1
20 D=1
30 FOR Y=0 TO 4
40 FOR X=0 TO 4
50 PSET X,Y,D
60 WAIT 100
70 NEXT X
80 NEXT Y
90 IF D D=0 ELSE D=1
100 GOTO 30
LED Matrix Message Display
10 CLS 1
20 MSG LEFT,200,"Hello"
30 FOR I=O TO 30
40 MSG DOWN,50,I/10
50 WAIT 50
60 MSG LEFT,100,I%10
70 NEXT I
80 WAIT 500
90 GOTO 20
Assign ed.m. character A to display
10 POKE FNT+ASC("A")*5+0,`00000000
20 POKE FNT+ASC("A")*5+1,`01010000
30 POKE FNT+ASC("A")*5+2,`00000000
40 POKE FNT+ASC("A")*5+3,`10001000
50 POKE FNT+ASC("A")*5+4,`01110000
60 MSG TOP,0,"A"
ASSIGN A FONT TO LED MATRIX CHARACTER A AND DISPLAY (2)
10 SETFONT ASC("A"),$00,$50,$00,$88,$70
MSG TOP,0,"A"
Neopixel Blue Trajectory Rotation
10 'Neopixel(1)
20 NPBEGIN 0,16
30 NPCLS
40 FOR I=0 TO 7
50 NPRGB I,0,0,(2<<I)-1
60 NEXT I
70 NPSHIFT 1
80 WAIT 50
90 GOTO 70
4x4Keypad input key determination (simple chattering measures available)
10 'Keypad 4x4
20 G0=-1
30 @(10)=1013,920,840,780,670,630,590,560,502,477,455,435,400,320,267,228
40 G0=G
50 G=GRADE(ANA(1),10,16)
60 IF G<>G0 WAIT 1 GOTO 40
70 IF G>=0 ?"KEY=[";G+1;"]"
80 GOTO 40
Time display (display the time when you press A button)
1 'トケイ
10 MATRIX ON
20 SETDATE 2018,1,16,12,0,0
30 IF !IN(BTNA) GOSUB "@ShowTime"
40 WAIT 200
50 GOTO 30
60 "@ShowTime"
70 GETTIME T1,T2,T3
80 MSG LEFT,80,#-2,T1;":";T2;":";T3;" "
90 RETURN
(new!) Browsing Misaki Font Data
1 '美咲フォントの利用
10 S="あ"
20 A=WADR(WASC(S))
30 FOR Y=0 TO 7
40 D=PEEK(A+Y)
50 FOR X=0 TO 7
60 IF D&($80>>X) ?"■"; ELSE ?"  ";
70 NEXT X
80 ?
90 NEXT Y
(new!) Character display with NeoPixcel (8×8 matrix type)
10 'NeoPixelで文字表示
20 SETFONT 0,$50,$A8,$88,$88,$70
30 MSG TOP,0,CHR$(0)
40 NPBEGIN 12,64
50 NPCLS
60 S="こんにちは☆さい玉":C0=RGB8(0,2,3)
70 FOR I=1 TO WLEN(S)
80 A=WADR(WASC(S,I))
90 FOR Y=0 TO 7
100 D=PEEK(A+Y)
110 FOR X=0 TO 7
120 IF D&($80>>X) C=C0 ELSE C=0
130 IF Y&1 POKE MEM+Y*8+X,C ELSE POKE MEM+Y*8+7-X,C
140 NEXT X
150 NEXT Y
160 NPPUT 0,MEM,64,1
170 WAIT 400
180 NEXT I
190 GOTO 70
(new!) LED Matrix Font Creation Tool (Created by Mr. Goeda)
1 'PCG EDIT
5 ATTR 0:COLOR 7
10 CLS:CLS 1:CLV:LET @(20)=79,42
20 FOR I=0 TO 4:FOR J=0 TO 4
30 LOCATE I,J:?CHR$(@(20));:NEXT J:NEXT I:GOSUB 500
40 K=INKEY()
50 X=X+(K=KRIGHT)*(X<4)-(K=KLEFT)*(X>0)
60 Y=Y+(K=KDOWN)*(Y<4)-(K=KUP)*(Y>0)
70 LOCATE X,Y:C=VPEEK(X,Y)
75 ATTR 2:?CHR$(C):LOCATE X,Y:WAIT 100:ATTR 0:?CHR$(C):LOCATE X,Y
80 IF K=32:IF C=@(20) P=@(21) ELSE IF C=@(21) P=@(20)
90 IF K<>32 GOTO 40
100 ?CHR$(P);
110 FOR I=0 TO 4:D=0
120 FOR J=0 TO 4:C=VPEEK(J,I)
130 IF C=@(21) D=D+(1<<(7-J))
140 NEXT J:@(I)=D
150 NEXT I
160 GOSUB 500:GOTO 40
500 LOCATE 0,10:?"SETFONT ASC(";CHR$(34,90,34,41);
510 FOR I=0 TO 4:?",$";HEX$(@(I),2);:NEXT I
520 SETFONT ASC("Z"),@(0),@(1),@(2),@(3),@(4)
530 MSG TOP,0,"Z"
540 RETURN

From then on is the original document

TOYOSHIKI Tiny BASIC for Arduino

The code tested in Arduino Uno R3. Use UART terminal, or temporarily use Arduino IDE serial monitor.

Operation example

> list 10 FOR I=2 TO -2 STEP -1; GOSUB 100; NEXT I 20 STOP 100 REM Subroutine 110 PRINT ABS(I); RETURN

OK >run 2 1 0 1 2

OK >

The grammar is the same as PALO ALTO TinyBASIC by Li-Chen Wang Except 3 point to show below.

(1) The contracted form of the description is invalid.

(2) Force abort key PALO ALTO TinyBASIC -> [Ctrl]+[C] TOYOSHIKI TinyBASIC -> [ESC] NOTE: Probably, there is no input means in serial monitor.

(3) Other some beyond my expectations.

(C)2012 Tetsuya Suzuki GNU General Public License

BBC Micro:Bit

66252304_2329475737122168_1827825187962224640_oThe BBC Micro: Bit is, to say the least, an outstanding product.  Designed to give the youth of Great Britain a headstart in the world of computing, the device made its way outside of the UK and has been available in the US for a time now.  I decided to give it a spin and, boy, talked about impressed.  It’s very small, very simple and very po67347291_2344305822305826_4275078865820319744_owerful. For under twenty US dollars, you get a micro that contains two buttons, a 5×5 LED matrix, ample RAM and EPROM, a simple but effective bus, battery power as an option via a built in connector, accelerometer, Bluetooth and more.  This thing is super simple to program as well (which was the goal.)  You can use Microsoft’s MakeCode IDE, the MakeCode website, A micro Python development IDE (via the WEB) and even Arduino IDE.  MakeCode is, perhaps, the easiest to use. It appears to work and look like the Scratch environment where you, literally, drag and drop controls to connect them together and form your program. You can get surprisingly sophisticated with this.  Each Micro: Bit is capable of communicating with other Micro: Bits, which allows for multiuser games or other uses.

66336575_2329475810455494_7193210424181915648_o

There is also a fair amount of third party support for Micro: Bit.  Add on LCD screens (which I have purchased one), controllers, cases, etc. I am in the process of reviewing a few and will write about them later. 

I am using these (I bought three, one for each of my younger children and one for myself—naturally.)  Both of my young ones seem to have taken to the device, with my youngest, who is six, being the most fascinated with the device.66520223_2334648659938209_3996346474836262912_o

The pricing for the device, under twenty US dollars, is perfect and the accessories are inexpensive as well.  Getting into hardware and software is easier and cheaper than ever.  This is a great way to enter the field.

Stay tuned for code, more photos and other tidbits on this terrific little device.

Building your own programmable clock

20180120_204454Wow, it’s been quite a while since the last posting.  I thought we would start the year off with a cool project, a reboot of my Half-Byte Clock, featuring Embedded Tiny Basic. This time, I use an Arduino Nano and a nice canvas/wooden ‘case’ to house it all.

Instead of using the somewhat large Half-Byte Console board, I use the Nano so it fit inside the wooden frame. The frame is roughly one inch thick, just big enough for the Nano and all of the components to fit. On this particular iteration, the light sensor and speaker are on the back of the frame and, because of poor planning, the temperature sensor sticks out of the side. I intend to remedy that, but that will be later.  I am too busy to worry about that right now.

The Components

For the project, you will need:Samsung 6980

    • Arduino Nano or similar 328 based microcontroller board
    • HC-06 Bluetooth module
    • DHT-11 Temperature sensor
    • Light Sensor (I used the OSEP LIGHT 01 module)
    • Two or Three 8×8 LED Matrix displays, assembled with controller
    • DS3231 RTC for Arduino (Real Time Clock)
    • Small speaker (I stole this out of a toy cell phone I purchased at Dollar Tree)
    • Case/Frame/Canvas

My total cost is about twenty five dollars. The most costly part was the canvas frame-$8.95 at Target. All other parts were sourced from Hobby Town or Amazon.

Features

The clock features programmability via Half-Byte Embedded BasiSamsung 6945c, though you can use whatever code you like. This project, though, is aimed at a reprogrammable device that can display the time/date, temperature/humidity, output sound, use the ambient light to brighten or darken the display and be programmable over Bluetooth.  You have about 1k of RAM to store your Basic code and, once saved, will remain in memory, even if you unplug it. Upon power up, if there is something in memory, it will auto start after five seconds.

Wiring it Up

I was going to get all fancy and draw a diagram, but I think the pin connections will make more sense to more people, so that’s what I am going to do.  There are also photos you can look at.  As my hands aren’t as steady as they once were, my soldering leaves a lot to be desired.

DHT 11:

  • Data line to pin 2 of Nano
  • (+) to +5v on NanoSamsung 7010
  • (-) to GND on Nano

 

RCT:

  • SCL to A5
  • SDA to A4
  • GND to GND
  • VCC to +5v

 

Light Sensor:

  • Pin S to A0 on NanoSamsung 7008
  • (+) to 3.3v on Nano
  • (-) To GND on Nano

 

LED Array:

  • data to pin D12    DIN pin of MAX7219 module
  • load to pin D10    CS pin of MAX7219 module
  • clk to pin D11       CLK pin of MAX7219 module

 

Speaker:

  • GND to GND
  • + to Pin D8 on NanoSamsung 7014

 

HC-06 Bluetooth:

  • VCC to +5v
  • GND to GND
  • RX to TX on Nano
  • TX to RX on Nano

Sample Embedded Basic Startup Apps:

Example 1:

100 PRINT "Welcome to Half-Byte LED Programmable Clock"
110 SCROLL " HALF-BYTE  "
111 SCROLL " Clock."
112 IF HOUR(0)<12 SCROLL " Good Morning! "
114 IF HOUR(0)>11 IF HOUR(0)<18 SCROLL " Good Afternoon! "
116 IF HOUR(0)>17 IF HOUR(0)<=23 SCROLL "  Good Evening!  "
120 TIME
125 IF IN(0)<>-1 GOTO 600
130 SCROLL ".   Temp is "
140 TEMP
145 SCROLL "F  "
150 SCROLL "Humidity is "
160 HUMID
170 SCROLL "  Hello!  "
180 IF IN(0)<>-1 GOTO 600
190 IF RND(99)>50 GOTO 110
200 SCROLL "       "
205 O=MINUTE(0)
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
265 IF IN(0)<>-1 GOTO 600
290 SET X,Y,0
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
400 K=MINUTE(0)
410 IF K-O>1 GOTO 110
590 GOTO 230
600 SCROLL "DONE  "

Example 1 will randomly display random dot pattern for about a minute. It also analyses the time and inserts ‘Morning’, ‘afternoon’ or ‘evening’ in the greeting.  If you are connected via USB or Bluetooth, you can interrupt the app by sending a character followed by the ENTER key.

EXAMPLE 2:

200 SCROLL "        "
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
590 GOTO 230
600 SCROLL "DONE  "

Example 2 is the kaleidoscope from Example 1

EXAMPLE 3:

100 SCROLL " Half-Byte Clock "
110 H=HOUR(0)
120 IF H<12 SCROLL " Good Morning! "
130 IF H>11 IF H<18 SCROLL " Good Afternoon! "
140 IF H>17 IF H<=23 SCROLL "  Good Evening!  "
150 TIME
160 IF IN(0)<>-1 GOTO 600
170 SCROLL " Temp is "
180 TEMP
190 SCROLL "F  "
200 SCROLL "Humidity is "
210 HUMID
215 SCROLL "%         "
220 SET 20,2,1
230 SET 23,2,1
240 SET 20,4,1
250 SET 23,4,1
260 SET 21,5,1
270 SET 22,5,1
280 FOR X=1 to 5
290 DIRECTION 2
300 SCROLL"  "
310 DIRECTION 1
320 SCROLL"  "
530 IF IN(0)<>-1 GOTO 600
540 NEXT X
580 SCROLL "       "
590 GOTO 110
600 PRINT "INTERRUPTED "

Example 3 displays the date and time as well as the humidity and temp. It also shows an animated smiley face.

EXAMPLE 4:

100 SCROLL ” Half-Byte Clock ”
110 H=HOUR(0)
120 IF H>=0 IF H<12 SCROLL ” Good Morning! ”
130 IF H>11 IF H<18 SCROLL ” Good Afternoon! ”
140 IF H>17 IF H<=23 SCROLL” Good Evening! ”
150 TIME
155 IF H=17 IF MINUTE(0)>=0 IF MINUTE<=10 SCROLL ”  TIME FOR name TO COME HOME!”: TONE 8,3000,3000
160 IF IN(0)<>-1 GOTO 600
163 SCROLL ” ”
170 SCROLL “Temp is ”
175 TEMP
177 SCROLL “F  Humidity is ”
180 HUMID
190 SCROLL “%”
200 SCROLL ”   ”
220 SET 20,2,1: SET 23,2,1
240 SET 20,4,1: SET 23,4,1
260 SET 21,5,1: SET 22,5,1
280 FOR X=1 TO 5
281 DELAY 40
290 DIRECTION 2
300 SCROLL ”  ”
310 DIRECTION 1
320 SCROLL ”  ”
530 IF IN(0)<>-1 GOTO 600
560 NEXT X
580 SCROLL ”       ”
590 GOTO 110
600 SCROLL “Interrupted!”

Example 4 is an example of an ‘alarm’. It evaluates the hour and minute and displays a custom message and then generates a tone. It also features the animated smiley.

Samsung 7025With some clever coding, you could write a game, create an interesting art display, message board and more.  There are unused pins on the Nano that you can also use to wire up something to control (like a pet watering device, lights, etc.)  All of the sensors are available in Basic or, if you choose to write your own custom code, use the pin outs above to read or write to them. You are only limited by your imagination. And, well, that tiny bit of RAM that these things have. C’mon, we went to moon on less.

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.

100 PRINT “INTERVAL”;: INPUT I
110 FOR X=1 TO 50
120 DWRITE 3, 1
130 DELAY I
140 DWRITE 3,0
150 DELAY I
160 NEXT X

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

Assembling the NKC 65k Color LCD Shield

Assembling the NKC 65k Color LCD Shield

The NKC 65k Color LCD Shield isn’t difficult to assemble, it is, however a bit time consuming.  The most difficult part of the assembly is soldering the connector board to the LCD itself. You must carefully line it up on both the LCD AND the shield board itself.  More on that in a moment.

To begin, first make sure you have all of the parts. Compare the packing list with what you have. Once you are sure you have every thing, you need to start with the LCD.  Take the very small connector board and, carefully, solder one of the strips to the LCD. You will know where, it’s kind of obvious, but, in case you can’t, on the shield board, look for the outline

lcdconnectorboard.jpg

LCD Connector Board

of the LCD.  On the component side, you will see several solid tracks that appear to go nowhere. This is what you will have to line up.  Once you place the LCD on the Shield board and line them up…the LCD has a tit that goes through the board on one side, line it up using that. Once satisfied, remove the LCD and continue to solder the connector board to the LCD. When you are done, place the LCD back on the shield, make sure the board lines up and then solder it to the shield board.  Congratulations, this was the toughest part of the assembly.

 

The official instrucWP_20170201_21_48_05_Pro.jpgtions say to solder the header now.  I would advise to wait. The problem is that the resistors are difficult to solder if you insert and solder the headers first. So, I would solder those outer resistors next.  Those are the 1K and 10K resistors. While you are at it, solder all of the small, .1uf capacitors (the little bright blue capacitors) into place. A few of these are also next to the headers and in difficult spots if the headers go first.

Solder the remaining resistors into place.  The board is clearly marked, so it should be very easy to figure out where to solder them.

The two large 10uf capacitors are polarized, meaning they must be soldered in a specific way. Notice they both have a gray arrow on them, that is the negative side and must be soldered in with the arrow pointing to the negative sign or round hole on the board.C1 would have the gray arrow facing the LCD and C7 has it facing the Max232 Integrated Circuit.

For the large LM317, place in the three holes, flat side facing toward the Max232.  Solder the center pin.  Carefully, bend the LM317 backward so it is as flush to the board as you can get and solder the remaining pins.

If you have a 16 pin, through hole IC socket (one does not come with the kit) I would suggest you use it in the assembly. It is ok if you do not, it makes it easier if, for some reason, you should ever have to swap the chip out.  If you have the socket, go ahead and solder it to the board, paying attention to pin one.  If you do not have the socket, insert the chip with pin one facing the edge of the board. Pin one is where the ‘u’ shape is on the outline of the chip on the board. Once you are satisfied that you have pin one in the proper place, solder the chip to the board.

The only things left should be the headers. An easy way to solder them in is to place them in your Arduino UNO and then carefully place the board over them, making sure the pins penetrate the board. Solder them.

WP_20170201_22_30_35_Pro.jpg

The Completed Board

 

 

Wow, you’ve assembled your board.  Now you need to test it.  There is a demo sketch (two of them) on the NKC Electronics web site.  Download them and then up load to your Arduino. If all went well, you see a short demo on the screen.

This is a busy but useful board and a ‘fun’ project. It shouldn’t take more than a couple of hours to assemble and test.  There are better panels out there, but this kit is currently $4.95 and could be useful in a monitoring project, a game or for an at a glance status for one of your project.

Have fun!

Official assembly guideWP_20170201_22_36_47_Pro.jpg

Demo 1 - direct I/O

Demo 2 - using digital read/write

Demo 1 is much faster and is what I would use 
for things that need speed.

Embedded Tiny Basic: build apps for your projects

Embedded Tiny Basic: build apps for your projects

I, recently, embarked on building a useful if not glitzy digital clock. My first idea involved something retro: using four, seven segment, LED’s to look like something from the late 1970’s.  At the same time, I was also playing around with 8×8 LED Arrays, using the MAX7219 chip.  While playing with that, I connected one of my 1307 RTC’s to the array and loaded up a sketch to show the date and time on the arrays.  Then, it hit me…this is a much cooler clock and I can do more with it.

So, I built a prototype using one of my Half-Byte Console boards, minus the video, audio and Nunchucky connector.  Hardware wise, it was really simple…connect the arrays to pins 10, 11 and 12, the RTC to A4 and A5 and, for extra coolness, a BMP180 temp and humidity sensor to the sca and scl on the RTC.  Viola! modify the code to handle the BMP180 and Presto! A cool clock.

wp_20170121_01_55_22_pro

Prototype clock for developing Embedded Tiny Basic

I decided to build a second one to take to work.  I thought it might be useful to be able to throw up a custom message to scroll for when, say, I was in a meeting. The more I thought, the more I was convinced this thing needed some kind of control program that would be easily modified from, say, a smartphone and Bluetooth.

Well, I already had the genesis of that control program: Half Byte Tiny Basic.

So, I looked at the source and made a copy.  I then went in and removed stuff I would not need, like all of the graphics statements and functions. I removed the TVOut library, and  all of the video handling code. And TONE.  I miss TONE.

I did not need the Nunchuck code, so it was gone as well.  What was left was a nice, small shell of my control program.  I added the libraries for the 8×8 LED Array (MAXMATRIX) and added statements to manipulate the arrays: SCROLL to display text, SET to turn on or off individual LEDs, and DIRECTION to tell the arrays  which way to scroll the text.  I already had code to handle the DHT-11 temperature sensor, so I left that in (and decided to use it instead of the BMP180) and added T

wp_20170122_21_13_11_pro

Random dots on the clock

EMP and HUMID to scroll those values across the arrays, and added code for the RTC.I was going to add a mechanism that would interrupt the running program if a signal from the serial device was detected, but, there was already one there…the IN(0) function. So I left it. I now had a decent little programming language for the clock.  With HB Tiny Basic’s ability to autorun whatever is in the EEPROM, if it lost power, th

wp_20170119_15_23_11_pro

Clock, in action

e clock would just start running on its own. Sweet!

 

The HC-06 Bluetooth module works very nicely. It connects to the serial pins and communicates as if the device were connected directly to the controlling device-a PC or smartphone.  Everything fits nicely into these cheap pencil boxes I picked up from Wal-Mart for a buck each. They are just big enough for the HB Console board and are wide enough for the LED Arrays.  They don’t look all that impressive, until you power up the clock…the bright LED’s shine through the translucent plastic nicely.

Embedded Tiny Basic is useful for giving some level of intelligence to other wise dumb devices.  While you only have about 1K of RAM to use for Embedded Tiny Basic, I think that will be adequate for most things.  There is, currently, no motor control, but it could be quickly and easily added.  The functionality that is there is probably going to be good for quite a few projects.  If not, it can be modified quickly.  I am already seeing where it can be modified, even for just this particular project.  I have a few others in mind, so stayed tuned for those.

In the mean time, below is a list of the additions and a release date for the language is forthcoming.  I need to clean up the code-a bunch-before releasing it and, as well, making sure I have all you will need in order to compile and use Embedded Tiny Basic.

 New statements and function:
  • SETTIME hours,minutes,seconds,day,month,year
    • sets the time and date for the RTC
  • SET col,row,on or off
    • Turn on or off the LED at column, row
  • X=HOUR(0)
    • Get the current hour
  • X=MINUTE(0)
    • Get the current minute
  • X=MONTH(0)
    • Get the current month
  • X=DAY(0)
    • Get the current day
  • SCROLL var or “text”
    • Scrolls whatever is in the quotes
    • If there are no quoted strings, a variable value or number is displayed
  • DIRECTION 1-4 (1 is left, 2 is right, 3 is up and 4 is down)
    • Specifies the direction of the scrolling text, 1 is the default.
  • TIME (sends the date and time to the LED array)
    • Scrolls the current date and time
  • HUMID (sends humidity to LED array)
    • Scrolls the current humidity
  • Temp (sends the temp to LED array)
    • Scrolls the current temperature
  • X=TEMP(0 or 1)
    • Get the current temperature and put it in variable 'x'
    • A zero means use Celsius, a one means Farenheit
  • X=HUMID(0)
    • Returns the humidity to the variable 'x'

Below is the listing for the current “HELLO” app:

100 PRINT “Welcome to Half-Byte LED Programmable Clock”
110 SCROLL ” HALF-”
111 SCROLL “BYTE Clock…..”
112 IF HOUR(0)<12 SCROLL ” Good Morning! ”
114 IF HOUR(0)>11 IF HOUR(0)<18 SCROLL ” Good Afternoon! ”
116 IF HOUR(0)>17 IF HOUR(0)<=23 SCROLL ”  Good Evening!  ”
120 TIME
125 IF IN(0)<>-1 GOTO 600
130 SCROLL “.   Temp is ”
140 TEMP
145 SCROLL “F  ”
150 SCROLL “Humidity is ”
155 SCROLL “%”
160 HUMID
170 SCROLL ”  Hello!  ”
180 IF IN(0)<>-1 GOTO 600
190 IF RND(99)>50 GOTO 110
200 SCROLL ”       ”
205 O=MINUTE(0)
210 W=15
220 H=7
230 X=RND(W)
240 Y=RND(H)
250 P=RND(W)
260 Q=RND(H)
265 IF IN(0)<>-1 GOTO 600
300 SET 16+(X),Y,1
310 SET 16+(X),H-Y,1
320 SET 16+(W-X),Y,1
330 SET 16+(W-X),H-Y,1
340 IF IN(0)<>-1 GOTO 600
350 SET 16+(P),Q,0
360 SET 16+(P),H-Q,0
370 SET 16+(W-P),Q,0
380 SET 16+(W-P),H-Q,0
390 IF IN(0)<>-1 GOTO 600
400 K=MINUTE(0)
410 IF K-O>1 GOTO 110
590 GOTO 230
600 SCROLL “DONE  “

A note about how the arrays are referenced, using SET.  Embedded Tiny Basic is setup to handle up to four arrays. My clock only uses two, but Basic does not know this, so individual LED addressing has to be offset by 16.  Normally, with four arrays, the upper left LED would be 0,0. In my clock, it would be 16,0 since I am only using the RIGHT MOST TWO arrays, each are 8 across and 8 down.

Some other things to note from the listing above…the line IF IN(0)<>-1 GOTO 600 that is sprinkled through out the program will poll the serial port to see if there is a key press. If there is a keypress, we want to stop execution and goto line 600.  In this case, it just says ‘Done’ and stops. Lines 205, 400 and 410 make up a timer. Lines 200 through 590 just displays a random dot pattern, as a distraction.  We don’t want this all day, so we only let it run for about a minute.  Line 205 records the minute it started and line 400 gets the minute after each pattern is displayed.  Line 410 evaluates the elapsed time by subtracting the start time from the end time. If the result is greater than a one, it goes back to the clock routine.  Otherwise, it displays a new pattern. Lines 112 through 116 determines if it is morning, afternoon or evening.

The Scroll statement is lacking and somewhat buggy. I am working on fixing it, and adding more functionality to it, to make it more versatile, like PRINT currently is. I also want to add a mechanism to the language to allow it to receive messages, via Bluetooth, from, say, a smartphone.  Limited gameplay may also show up in a future release.

Embedded Tiny Basic will be released soon.