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.

Dance Dance Roverbot! Build a Light Activated Dancing Snap Circuits Programmable Robot.

Step 5A Sample Program for the PICAXE

A Sample Program for the PICAXE
This is what a PICAXE Programming Editor flowchart looks like. The flowchart in this example is very simple--can you guess what it does? It will turn a motor that is connected to pin 4 on the PICAXE for 10 seconds. We can take a look at how each step is processed.

The "start" terminator is ignored by the compiler, but is useful to you to easily locate the start of your program.

The "pause" process tells the PICAXE to wait 1000 miliseconds, or 1 second before proceeding to the next step in the program. When you tell the PICAXE to execute the program, you will notice a 1 second pause before anything happens.

The parallelogram flowchart symbol represents data, or input/output. It contains the command "high 4" and this command will set pin 4 high, which means the microcontroller will send voltage to that pin, or output current to that pin. If you have a motor connected to pin 4 then current from this pin will pass through the motor and the motor will begin to spin.

This "pause" process tells the PICAXE to wait 10000 miliseconds, or ten seconds. This means pin 4 will remain high for 10 seconds thus continuing to send current to the motor for ten seconds (the motor will spin for ten seconds).

This data flowchart symbol contains the command "low 4." It tells the PICAXE to turn the pin off, or to output 0 volts. This will cut power to the pin and the motor connected to it will stop spinning.

If you want to see what the BASIC code looks like, you can click Flowchart and then click Convert Flowchart to BASIC. The code will look like the the following:

‘BASIC converted from flowchart:
‘C:\DOCUMENTS AND SETTINGS\DESKTOP\SNAPROVERBOT.CAD
‘Converted on 10/30/2011 at 20:53:11
main:
pause 1000     'Tells the PICAXE to wait 1000 miliseconds (1 second)
high 4                'Sets pin 4 high, which sends current to pin 4 (if there is a motor connected it will spin)
pause 10000   'Tells the PICAXE to wait 10000 miliseconds (10 seconds--motor will spin for 10 seconds)
low 4                  'Sets pin 4 low, or ouputs 0 volts. This cuts the power to the pin and the motor stops spinning
« 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!
15
Followers
12
Author:KRA5H(Fun With Snap Circuits)
IT professional.