Step 56: Explanation of Subroutines and Functions
Here is a list of the major subroutines and functions
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.
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
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
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"
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 .
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
This subroutine sets the assigned port number a logical low or off
syntax LowOutput(3) - Turns off Output 3 of the Phidgets