3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Propeller Platform

Step 19Using It: Your first Propeller Program

Using It: Your first Propeller Program
First, download the Propeller tool (windows or mac) so you can write your program. Also, make sure you have a PropPlug.

Boot it up the Propeller Tool and let's start with the most simple program, an LED blinky;



I'll break down each line:

PUB main
Programs start execution at the first method it finds. In this case, there's only one method (main), and it's a PUBlic method, but we don't need to worry about that now

dira[0] := 1
dira[0] is the 'direction register' for pin 0. By writing a value of 1 to the register, we make pin 0 an output. := is the assignment operator.

REPEAT
do everything that's tabbed below. A REPEAT loop without an UNTIL will repeat forever. Tabs are important in spin - everything indented under this line is part of the REPEAT loop.

!OUTA[0]
the ! operator means 'flip' and OUTA is the output register for pin 0. So this line takes the current value of outa[0], flips it, and write it back. If the pin is high, it will flip low. If the pin is low, it will flip high.

A fancy way of describing the ! is a 'Bitwise NOT assignment operator'.

WAITCNT(CLKFREQ + cnt)
Translation: Hold up for 1 second. WAITCNT(Time) will pause execution until the system clock == Time.

CLKFREQ is a system value - it equals the number of ticks in each second. CNT is another system value, it's the current system time (how many ticks since the Propeller has started). By adding 1 second's worth of ticks to the system clock, we're figuring out what the system clock will be one second from now.

And that's your first program!

What would you change if you wanted the LED to blink twice per second?

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
164
Followers
53
Author:Gadget Gangster(GadgetGangster.com)