Connect your Scamp
Connect your Scamp computer to a host computer using a Micro USB cable. The USB connection provides both power and communication for your Scamp.
When connected to a host computer or USB power source, the green power LED should light up indicating that your Scamp has power. The power LED is connected to the output of the voltage regulator, and shows that input power is present and the regulator is also operating. |
Communicating WITH A Mac or Linux computer
If you're using a Windows host, see Getting Started (Windows)
screen is an ANSI-compatible UNIX terminal emulator that is included with MacOS X and Linux, and may be used to communicate with your Scamp. On a Mac, open the Terminal app (found in the /Applications/Utilities folder). This will give you a command prompt.
At your Mac or Linux computer's prompt enter:
At your Mac or Linux computer's prompt enter:
ls /dev
to show a list of attached devices. Your Scamp will appear as a usbmodem device, something like cu.usbmodem1421 or ttyACM0 for example. (The device name is assigned by the host. The number assigned changes depending on which USB port you plug into.)
|
If your Scamp doesn't appear, check that your cable is a full USB cable. Some people have been caught out by charger-only cables that supply power, but don't support comms.
|
|
On a mac, type:
screen /dev/cu.usbmodem1421
(or whatever the device name is) to connect to your Scamp.
On a Linux machine (including a Raspberry Pi), it may appear as something like ttyACM0. You may also need to sudo screen under Linux. (Thanks to Martin Heermance for pointing this out.)
On a Linux machine (including a Raspberry Pi), it may appear as something like ttyACM0. You may also need to sudo screen under Linux. (Thanks to Martin Heermance for pointing this out.)
sudo screen /dev/ttyACM0
If your computer goes to sleep, screen may terminate because its side of the connection is lost. Forth is still running on your Scamp. Just reconnect to the screen session by typing screen -r in your terminal program
|
Note that the FlashForth site has a python shell (in the section Interacting with FlashForth) that can be used in place of a terminal program.
|
|
OK
Press the return key a few times, and Forth should respond with ok. That’s Forth’s prompt. Forth is very much old school. You type commands in, and get a response on the console. There’s no integrated development software to install on your host computer. You interact directly with the machine.
Forth says ok when it’s ready for your next command.
Forth says ok when it’s ready for your next command.
|
Forth does not have a command history. Typing an up or down arrow on your keyboard will send key codes that will just confuse it. If you use a text editor to write your code and then paste it into Forth, be sure to have smart quotes turned off and no rich-text formatting. The hidden formatting codes found in rich text make no sense in a Forth environment.
|
|
LEDs
There is a LED on your Scamp that you can use as a status indicator in your applications. Type:
ledon
and press the return key, and the LED will turn on. Conversely:
ledoff
will turn the LED off, while:
blink
will make it blink once. You can use these commands within your programs to control the LED.
The Scamp2 and Scamp3/3e have an additional array of 16 red LEDs that you can use in your application. To write a value to the LEDs, place the value on the stack and then call the leds word. For example, to turn all the LEDs on, type the (hex) value of $ffff and call leds.
$ffff leds
To turn the LED array off:
0 leds
Type in the following program called "test" (spaces are important):
: test begin random leds blink key? until ;
Now type:
test
That's how easy Forth is. (Press any key to stop test.)
Reset
If at any stage you get stuck and need to restart your Scamp, press the RESET button. A hardware reset will also cause your USB connection to reset, therefore you will need to reestablish the connection with your host computer.
Alternatively, you can trigger a warm (software) reset by typing the warm command at the prompt.
Alternatively, you can trigger a warm (software) reset by typing the warm command at the prompt.
The empty word can be used to restore Forth back to "factory settings." Any programs (words) you have created will be erased, and all system parameters will be reset to their default. If you have created a buggy program that permanently snarls Forth so that it no longer works properly, use empty to reset everything back to normal.
The about command will display version number and copyright information.
The free command will show you how much Flash and RAM is available.
The about command will display version number and copyright information.
The free command will show you how much Flash and RAM is available.
Next, learn about Forth and its history.