# Program in Logo on an Apple II

## Overview

https://www.youtube.com/watch?v=OmkahOOu0Po

You may have seen the turtle graphics library that [ladyada ported to CircuitPython](https://github.com/adafruit/Adafruit_CircuitPython_turtle) and thought, "Wow, that's cool! But can I do that on 30+ year old hardware?" Or if you're above a certain age you may remember doing something similar in school on an Apple II.

Let's set up an Apple II emulator and run old school Logo to make our own turtle graphics!

![](https://cdn-learn.adafruit.com/assets/assets/000/077/741/medium800thumb/gaming_turtle.jpg?1562097619)

# Program in Logo on an Apple II

## What is Logo?

Logo is an educational programming language designed to teach basic concepts.

Logo goes back much earlier than the Apple II, it was developed in 1967 by Cynthia Solomon, Wally Feurzig, and Seymour Papert. That's five years before C and 24 years before Python! The three worked at Bolt, Beranek, and Newman (BBN), famous for all kinds of other computing history. BBN built the first Interface Message Processors (early routers) in 1968 for the ARPANET, which would evolve into the modern internet.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/716/medium800/programming_turtlerobot.jpg?1562088272)

Logo includes commands used for drawing on the screen using a cursor known as a Turtle. Small robots called Turtles had been developed as far back as the 1940s to teach mechanical engineering and computer science. Logo uses a virtual turtle on the screen and can be linked to a physical turtle which moves in response to commands. When people remember Logo they usually talk about the Turtle graphics.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/555/medium800/programming_turtle01.jpg?1561729968 Moving the Turtle)

Enough with the history lesson, let's get started!

# Program in Logo on an Apple II

## Choose Your Emulator

![](https://cdn-learn.adafruit.com/assets/assets/000/077/718/medium800/programming_Untitled.png?1562093151)

The easiest way to get started is to use a Javascript Apple II emulator (shown in an image above). This one even has Logo ready to go: [https://www.scullinsteel.com/apple//e#logo](https://www.scullinsteel.com/apple//e#logo)

If you'd like to set up a native emulator on your system, keep reading. Otherwise you can use the Javascript one above and skip ahead to the next section.

## **Windows, Mac, Linux**

### Windows

AppleWin is a good choice for Windows systems and it's open source! Get the latest version here: [https://github.com/AppleWin/AppleWin/](https://github.com/AppleWin/AppleWin/)

Just extract the zip file and it's ready to go.

### Linux

For Linux you can run [LinApple](http://linapple.sourceforge.net), a port of AppleWin.

### All Systems

There's also [EPPLE II](https://cmosher01.github.io/Epple-II/) which runs on Windows, Mac, and Linux, and is also open source. It's a little harder to get set up and running. You'll probably need [DskToWoz2](https://github.com/cmosher01/DskToWoz2) to convert disk images to the Woz format that EPPLE II uses.

## **Raspberry Pi**

[RetroPie](https://retropie.org.uk/) comes with an Apple II emulator.

LinApple has also been optimized for the Pi, check out [linapple-pie](https://github.com/dabonetn/linapple-pie).

## Disk Images of Software

For these emulators, you'll need the disk images for Logo, those can be found at [Apple2Online](https://apple2online.com/index.php?p=1_24).

# Program in Logo on an Apple II

## Hello, Turtle!

When you first start Logo you'll reach a **?** prompt. From here you can enter Logo commands.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/558/medium800/programming_prompt01.jpg?1561736147)

We could write Hello, World, but that's boring. Let's get straight to the good stuff and draw some Turtle graphics!

Type in this line and watch the Turtle go! It will take quite a while to finish if your emulator is running at normal speed:

```
**REPEAT 20 [REPEAT 180 [FD 1 RT 2] RT 18]**
```

You can see the results at the bottom of the page.

Now that we've done something cool, let's unpack it and see what the commands did. **REPEAT** takes a number and a list, then it runs the list that many times. With the first one we're repeating whatever is in the list 20 times. A list is contained in square brackets and is made up of Logo objects, in this case we have two commands: another **REPEAT** with its own list and **RT 18**.

The inner **REPEAT** has its own list, **[FD 1 RT 2]**. These two commands are shorthand versions of turtle commands **FORWARD** and **RIGHT**. It tells the turtle to move forward one unit, then turn right 2 degrees. Repeat this 180 times and you get a circle (2 degrees \* 180 = 360)! After completing the **REPEAT** there's another **RT** , so once the circle is done we turn right 18 degrees. See where this is going? Repeat that 20 times and you get another circle (20 \* 18 = 360). Now we've got a circle of circles!

You can clear the screen by typing **CLEARSCREEN**. Try doing **REPEAT 180 [FD 1 RT 2]** and you'll see one component of the larger drawing that we just made.

## Commands
Here's an overview of some turtle commands and their shorthand equivalents:

**CLEARSCREEN** - Clear the screen. (Shorthand: **CS** )

**HIDETURTLE** - Don't show the turtle cursor. ( **HT** )

**SHOWTURTLE** - Show the turtle cursor. ( **ST** )

**HOME** - Move back to the home position.

**FORWARD** _steps_ - Move forward _steps_. ( **FD** )

**BACK** _steps_ - Move back _steps_. ( **BK** )

**LEFT** _degrees_ - Turn left this many degrees. Negative degrees work too, they'll turn it right. ( **LT** )

**RIGHT** _degrees_ - Turn right this many degrees. ( **RT** )

**SETHEADING** _degrees_ - Turn to an absolute heading of _degrees_. ( **SETH** )

**SETPOS** [_x y_] - Set the position to _x, y_ coordinates. These are Cartesian, so 0,0 is the middle of the screen.

**SETX** _x_ - Set the horizontal position to _x_.

**SETY** _y_ - Set the vertical position to _y_.

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/077/713/medium800/programming_turtle02.jpg?1562084929)

# Program in Logo on an Apple II

## More Logo

Logo has some of the basic language features you'd expect - variables, functions, and conditionals.

## **Variables**

Define a variable using **MAKE** _name_ _value_. Logo normally interprets any word as a procedure call, so to use a literal word you can prefix it with a double quote.

`MAKE "A 8`

You can use a variable by prefixing the name with a colon:

`PRINT :A
8
`

Variables created with **MAKE** are global. The only local variables in Logo are procedure arguments.

## **Functions (Procedures)**

Logo functions are called procedures, and they're defined like this:

`TO HELLO
PRINT "HI
END`

**TO** specifies the name of the function, the lines after are the function body, and it's all closed out with **END**. You can call a procedure by typing its name. You can also call a procedure from within another procedure. Logo handles recursion, so a procedure can call itself!

To run it, just type the procedure name:

`?HELLO
HI`

Procedure arguments are defined by listing them after the procedure name:

`TO HEY "NAME
PRINT "HI
PRINT :NAME
END
`

If you want to delete a procedure, use the **ERASE** command.

`ERASE "HEY`

## **Conditionals**

Logo's `IF` statement is straightforward: `IF test list1`

If _test_ is true, run _list1_. You can add another list to the end (`IF test list1 list2`) and _list2_ will be run if _test_ is false.

You can break this down a bit using **TEST** , **IFTRUE** , and **IFFALSE**. **TEST** _test_ will save the result of _test_ and use it for any calls to **IFTRUE** and **IFFALSE**.

These are equivalent:

`IF :A=8 [PR [A IS 8]] [PR [A IS NOT 8]]`

`TEST :A=8
IFTRUE [PR [A IS 8]]
IFFALSE [PR [A IS NOT 8]]
`

## **Example**

Let's put these together and draw something. First we'll define a square function:

`TO SQUARE "LEN
REPEAT 4 [FD :LEN RT 90]
END
`

Try it out! **SQUARE 50**

How about a hexagon?

`TO HEXAGON "LEN
REPEAT 6 [FD :LEN RT 60]
END
`

Now let's put them together and draw something.

`REPEAT 20 [IF RANDOM 2=1 [SQUARE 40] [HEXAGON 30] RT 18]`

**RANDOM** _num_ will output a random number from 0 to _num_. Here we use it to decide whether to draw a square or a hexagon.

That's a pretty simple example, see what you can do with Logo! There are a lot more features and we can't cover them all here, check out the Logo manuals in Resources for a full reference.

![](https://cdn-learn.adafruit.com/assets/assets/000/077/717/medium800/programming_turtle03.jpg?1562090574)

# Program in Logo on an Apple II

## Resources

## **Emulators**

- [Scullin Steel Apple IIe Javascript Emulator](https://www.scullinsteel.com/apple//e)
- [AppleWin](https://github.com/AppleWin/AppleWin/)
- [LinApple](http://linapple.sourceforge.net/)
- [LinApple-Pie](https://github.com/dabonetn/linapple-pie)
- [Epple II](https://cmosher01.github.io/Epple-II/)
- [DskToWoz2](https://github.com/cmosher01/DskToWoz2)
- [RetroPie](https://retropie.org.uk/)

## **Apple II Software**

- [Apple2Online](https://apple2online.com/index.php?p=1_24)

## **History**

- [CircuitPython Turtle Graphics](https://github.com/adafruit/Adafruit_CircuitPython_turtle) - for a modern take on the Turtle.
- [Logo Foundation at MIT](https://el.media.mit.edu/logo-foundation/what_is_logo/index.html)

## **Reference**

Logo books from the excellent Internet Archive:

[Apple Logo II Reference Manual](https://archive.org/details/Apple_Logo_II_Reference_Manual/) - Logo II was a later version, but most of the manual is still applicable to the original one that we're using.

[Introducing Logo for the Apple II, TI 99/4A, and Tandy Color Computer](https://archive.org/details/tibook_introducing-logo/)


## Featured Products

### Adafruit PyPortal - CircuitPython Powered Internet Display

[Adafruit PyPortal - CircuitPython Powered Internet Display](https://www.adafruit.com/product/4116)
 **PyPortal** , our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface GUIs, all open-source, and Python-powered using&nbsp;tinyJSON / APIs to get news, stock, weather, cat photos,...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4116)
[Related Guides to the Product](https://learn.adafruit.com/products/4116/guides)
### Adafruit PyGamer Starter Kit

[Adafruit PyGamer Starter Kit](https://www.adafruit.com/product/4277)
**Please note: you may get a royal blue _or_ purple case with your starter kit (they're both lovely colors)**

What&nbsp;fits in your pocket, is fully Open Source, and can run CircuitPython, MakeCode Arcade or Arduino games you write yourself? That's right,...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4277)
[Related Guides to the Product](https://learn.adafruit.com/products/4277/guides)
### Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino

[Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino](https://www.adafruit.com/product/4200)
What's the size of a credit card and can run CircuitPython, MakeCode Arcade or Arduino? That's right, its the **Adafruit PyBadge!** We wanted to see how much we could cram into a ​3 3⁄8 × ​2 1⁄8 inch rounded rectangle, to make an all-in-one dev board with...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4200)
[Related Guides to the Product](https://learn.adafruit.com/products/4200/guides)

## Related Guides

- [Adafruit PyPortal - IoT for CircuitPython](https://learn.adafruit.com/adafruit-pyportal.md)
- [Adafruit PyBadge and PyBadge LC](https://learn.adafruit.com/adafruit-pybadge.md)
- [Wakanda Forever Game](https://learn.adafruit.com/wakanda-forever-game.md)
- [PyPortal Adafruit Quote Book](https://learn.adafruit.com/pyportal-adafruit-quote-board.md)
- [PyPortal Roku Remote](https://learn.adafruit.com/pyportal-roku-remote.md)
- [Custom Fonts for CircuitPython Displays](https://learn.adafruit.com/custom-fonts-for-pyportal-circuitpython-display.md)
- [Using LittlevGL with Adafruit Displays](https://learn.adafruit.com/using-littlevgl-with-adafruit-displays.md)
- [AdaBox 011](https://learn.adafruit.com/adabox011.md)
- [PyPortal IoT Plant Monitor with Google Cloud IoT Core and CircuitPython](https://learn.adafruit.com/pyportal-iot-plant-monitor-with-google-cloud-iot-core-and-circuitpython.md)
- [Saving CircuitPython Bitmaps and Screenshots](https://learn.adafruit.com/saving-bitmap-screenshots-in-circuitpython.md)
- [PyPortal Alarm Clock](https://learn.adafruit.com/pyportal-alarm-clock.md)
- [PyPortal New New New Product Viewer](https://learn.adafruit.com/pyportal-new-new-new-product-viewer.md)
- [PyPortal Weather Station](https://learn.adafruit.com/pyportal-weather-station.md)
- [PyPortal Winamp MP3 Player](https://learn.adafruit.com/pyportal-winamp-mp3-player.md)
- [Playing Arduboy Games on Arcada](https://learn.adafruit.com/playing-arduboy-games-on-arcada.md)
- [CircuitPython Turtle Graphics](https://learn.adafruit.com/circuitpython-turtle-graphics.md)
- [MakeCode Arcade Platformer Level Design](https://learn.adafruit.com/makecode-arcade-platform-level.md)
