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.

Build Your Own Butler Robot!!! - Tutorial,Photos, and Video

Step 56Explanation of Subroutines and Functions

Explanation of Subroutines and Functions
I have included in the code a lot of subroutines and functions to make the code easier to use and easier to understand .

Here is a list of the major subroutines and functions

1. Speak
The Speak subroutine will play the sound file which is specified . All sound files must be in the "Voice" folder in order to play.
The syntax for the Speak subroutine is : Speak (filename as String)
ex: Speak "File1" - this will play the sound file "File1.wav" which is in the folder "Voice"

Note: For variables such as weather conditions make sure that the proper sound file exists for the condition.

2. Pause
The Pause subroutine will as it's name implies pause the code for a certain amount of milliseconds.The Pause function uses the Sleep function( a Win32 function) , but before sleeping it makes sure that all prior commands were fully completed.
Syntax for the Pause subroutine is : Pause (milliseconds as Integer)
ex: Pause 2000 - this will sleep for 2000 milliseconds a.k.a 2 seconds

3. Drive
The Drive subroutine is responsible for controlling the drive motors. The subroutine requires two variables to be filled in order to work. The two variables that it relies on are strDriveDirection and strUnits. strDriveDirection is a public variable because that way the direction can be set separately and in a different procedure than strUnits.

strDriveDirection tells the subroutine which drive relays to activate and strUnits tells the subroutine how long to activate the relays.
Syntax for the Drive subroutine is:

strDirection = (direction as String)
Drive (milliseconds as Integer)

ex: strDirection = "Forward" ' set the Direction to forward
Drive 3000 'Drives for 3000 milliseconds or 3 seconds

4. Get_Time
The Get_Time public subroutine returns the current time in a variety of variables. It has the ability to separate the time into the singles and tens place, set the time to 12 hour time, divide the day into AM and PM, and even divide the day into day phases(e.g. afternoon).

The syntax for it is either Get_Time or Call Get_Time

It returns the following public variables:
strDayDivider - this is either AM or PM
strHours - the amount of hours in 12 hour time ( maximum is 12)
strRawHours- the amount of hours in 24 hour time ( maximum is 24)
strRawMinutes- the amount of minutes ( double digit)
strSinglesMinutes- the amount of minutes in the singles place only ( single digit)
strTensMinutes- the amount of minutes in the tens place only ( e.g. 30 , 40 , 50 )
strDayPhase - either "Morning" , "Afternoon", or "Night"

5. Get_Weather_Info
Gets the weather information( temperature and conditions) and returns public variables.

The syntax is either Get_Weather_Info or Call Get_Weather_Info

It returns the following public varables:
strTemperature - temperature in degrees farenheit ( double digit)
strDegrees_Singles - temperature in the singles place only ( single digit)
strDegrees_Tens - temperature in the tens place onle ( e.g. 10 , 20 , 30 , 40)
strFeels_Like - feels like temperature in degrees farenheit ( double digit)
strFeels_Like_Singles - feels like temperature in the singles place only (single digit)
strFeels_Like_Tens - feels like temperature in the tens place only (e.g. 10, 20 ,30)
strWeather_Conditions - the weather conditions outside ( can be anything from herehere )

There are many other minor subroutines and functions , but the average user will not need to use them .

6. HighOutput
This subroutine sets the assigned port number a logical high or on.

syntax HighOutput(portnumber as integer)

ex: HighOutput (9) - Turns on Output 9 of the Phidgets

7. LowOutput
This subroutine sets the assigned port number a logical low or off

syntax LowOutput(3) - Turns off Output 3 of the Phidgets

« Previous StepDownload PDFView All StepsNext Step »
1 comment
Dec 16, 2011. 3:06 PMAron313 says:
Wish i could make a robot like that!!!!!

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!
28
Followers
1
Author:Erobots