# Tiny Basic on the ATTiny85

Tiny Basic on the ATTiny85 makes a convenient remote sensor platform for the micromite family.

Due to the extremely constrained memory, normal Basic syntax is not viable. MMEdit lets you code in 'readable' basic and switch to the compressed machine version and back again.

Write your code like this:

10 M = 64: FOR J =-20 TO 20
20 FOR I =-40 TO 40
30 V = J*4:U = I*3-40:X = U :Y = V :N = 0
40 R = X*X/M :Q = Y*Y/M : IF R+Q >256 GOTO 80
50 IF N >= 64 GOTO 70
60 Y = 2*X*Y/M+V :X = R-Q+U :N = N+1: GOTO 40
70 ? " ";: GOTO 130
80 N = N-N/5*5: IF N = 0 ? "@";
90 IF N = 1 ? "$";
100 IF N = 2 ? "#";
110 IF N = 3 ? "%";
120 IF N = 4 ? "&";
130 NEXT I : ? : NEXT J
and use 'format' to change it to:

1 M=64:F.J=-20TO20
2 F.I=-40TO40
3 V=J*4:U=I*3-40:X=U:Y=V:N=0
4 R=X*X/M:Q=Y*Y/M:IFR+Q>256G.8
5 IFN>=64G.7
6 Y=2*X*Y/M+V:X=R-Q+U:N=N+1:G.4
7 ?" ";:G.13
8 N=N-N/5*5:IFN=0?"@";
9 IFN=1?"$";
10 IFN=2?"#";
11 IFN=3?"%";
12 IFN=4?"&";
13 N.I:?:N.J

Thew first step is to select "ATTiny" as the syntax. If you don't strange things might happen.

You can use 'format' to switch between the two views at any time. Use whichever view you prefer to enter code in.
The keyword shortcuts (F. for FOR etc) are created using the keyword order in ATTiny.tkn so it is important to preserve the order if you alter the file.

When entering code, the line numbers are automatically inserted. If you are adding code to the end of the file, the usual step of 10 is used.
If however, you are inserting lines, a step of 1 is used to 'hopefully' keep the line numbering in order.

Don't want the line number added, SHIFT-ENTER or right click to bring up a pop-up menu and use the first item "<Enter>"
A new line is added without any "extras"

When you switch between views, the lines are renumbered. Readable code has a line-number step of 10 while the compressed view uses 1 as the step. This can save a few precious bytes.
Any GOTO or GOSUB targets are changed to suit the new line numbers except when you have used an expression as the target.
A line such as
7 N=N-N/5*5:GOS.N+9
will not convert correctly.

Sending the code to the ATTiny85.

If you use a terminal program such as TeraTerm, you will need a character delay of 1mS. Once that is set, a copy and paste into the terminal should work.

If you are using MMCC as the terminal, set the device type to "ATTiny85", set the port, and a baudrate of 38400.
Programs should transfer without any issues.

If using TeraTerm etc, it is up to you to erase any existing program before transferring the new program.
MMEdit does issue a NEW before transferring code (unless you have specified \nonew).

Last edited: 13 August, 2023