Search Results
285 results found with an empty search
- Motor and Drive Commands
Command Guide < Back Motor and Drive Commands allstopon - STOP ALL MOVEMENT Purpose This stops all movement of the robot and puts it in a safe mode. Syntax allstopon Notes This command overrides ALL other commands that would normally be able to induce some kind of movement in the robots drive system. The ONLY way to leave all stop on mode is to run the allstopoff command. allstopoff - Leave all stop on mode. Purpose This causes the robot to leave all stop on mode. Syntax allstopoff bmd - The direction of BOTH motors Purpose Allows the direction of movement of both drive motors to be set at the same time. Syntax bmd dir Arguments dir 0 = Forwards 1 = Reverse. bms - Set the speed of both drive motors Purpose This sets the speed of both drive motors to the same value. Syntax bms value Arguments value -100 to 100 Where: -100 full reverse 0 stop 100 full forward Pushers No Returns Nothing Examples bms 0 STOP bms 50 Half forward bms -50 Half back Channels & Vars Channel 150 both motor speed 160 left motor speed 170 right motor speed Notes This is for robots with motor drives. cbst - Cold start boost for the drive motors Purpose This is an extra duty cycle added to the motors speed when its starting from stand still. Syntax cbst value Arguments value 0 to 1000 This is a duty cycle. Examples cbst 100 Set to 100 Notes This is for robots with motor drives. dmlp - Set Left Drive Motor Esp32 Pin no Purpose This is the pin on the esp32 to use for the left drive motors pwm. Syntax dmlp pin Arguments pin The pin no on the esp32 to use. Notes This is for robots with motor drives. Don’t use unless you know what you are doing. dmrp - Set Right Drive Motor Esp32 Pin no Purpose This is the pin on the esp32 to use for the right drive motors pwm. Syntax dmrp pin Arguments pin The pin no on the esp32 to use. Notes This is for robots with motor drives. Don’t use unless you know what you are doing. dslimit - Disable Steering Limit Checking Purpose This allows the steering limit switch checking to be enabled and disabled on robots using a linear actuator with limit switches for steering. Syntax dslimit value Arguments value 0 = Don’t disable 1 = Disable Pushers No Returns Nothing Examples dslimit 0 Don’t disable steering limit switches dslimit 1 Disable steering limit switches Notes This should only be used for testing. faster - Pulse the drive motors forwards a little. Purpose This will briefly pulse both drive motors in the forwards direction a little and then turn them off. Syntax faster Examples faster Move robot forwards a little left - Pulse the robot to the left Purpose On a robot with motor drives fitted this command will cause the robot to turn a little to the left. Syntax left Examples left Turn slightly to the left. Notes This is for robots with motor drives. lmd - Set Left Drive Motors Direction Purpose Set the direction of travel of the left drive motor. 0 = forward Syntax lmd dir Arguments dir 0 = forward 1 = reverse 1 = reverse lmo - Set Left Drive Motors Offset Purpose This is added to the motors speed at a low level to compensate for differences in the motors. Syntax lmo offset Arguments offset The duty cycle offset between 0 and 1000. lms - Set the speed of the left drive motor Purpose This sets the speed of the left drive motor. Syntax lms value Arguments value -100 to 100 Where: -100 full reverse 0 stop 100 full forward Pushers No Returns Nothing Examples lms 0 STOP lms 50 Forward half lms -50 Back half Channels & Vars Channel 150 both motor speed 160 left motor speed Notes This is for robots with motor drives. lmt - Left motor start threshold Purpose This is the min speed value at which the left motors wheels will turn. Range 0 to 100. Syntax lmt value Arguments value 0 to 100 Examples lmt 25 Channels & Vars Channel 165 Notes This is for robots with motor drives. right - Pulse the robot to the right Purpose On a robot with motor drives fitted this command will cause the robot to turn a little to the right. Syntax right Examples right Turn slightly to the right. Notes This is for robots with motor drives. rmd - Set Right Drive Motors Direction Purpose Set the direction of travel of the right drive motor. 0 = forward Syntax rmd dir Arguments dir 0 = forward 1 = reverse rmo - Set Right Drive Motors Offset Purpose This is added to the motors speed at a low level to compensate for differences in the motors. Syntax rmo offset Arguments offset The duty cycle offset between 0 and 1000. rms - Set the speed of the right drive motor Purpose This sets the speed of the right drive motor. Syntax rms value Arguments value -100 to 100 Where: -100 Full reverse 0 STOP 100 Full forwards Examples rms 0 rms 50 rms -50 Channels & Vars Channel 150 both motor speed 170 right motor speed Notes This is for robots with motor drives. rmt - Right motor start threshold Purpose This is the min speed value at which the right motors wheels will turn. Range 0 to 100. Syntax rmt value Arguments value 0 to 100 Examples rmt 25 Channels & Vars Channel 175 Notes This is for robots with motor drives. rstdv - Reset the motor drive system Purpose Resets the drive system to the way it is when the JackBord is turned on. Syntax rstdv Examples rstdv sbms - Set the speed of both drive motors to different values Purpose This sets the speed of both drive motors to the different values in the same command. Syntax sbms left right Arguments left Speed of the left motor. -100 to 100 Where: -100 full reverse 0 stop 100 full forward right Speed of the right motor. -100 to 100 Where: -100 full reverse 0 stop 100 full forward Pushers No Returns Nothing Examples sbms 0 0 Stop sbms 25 50 Left turn sbms 50 25 Right turn sbms 20 20 Forwards Channels & Vars Channel 150 both motor speed 160 left motor speed 170 right motor speed Notes This is for robots with motor drives. sdmct - Set the JackBord drive motor controller type Purpose Set the type of motor being used on the robots drive system. Options are: Type Description 0 NO motor drive installed. 1 Normal MOSFET mode 2 DRV8833 H-bridge 3 L298N H-bridge 4 BTS7960B H-bridge 5 Mobility scooter drive using MCP4161 Digital Potentiometer 6 Single Front Wheel Drive on, front. Connected to the L298 H-bridge Output 2. Syntax sdmct value Arguments value Drive type type, see above. Examples sdmct 2 Set DRV8833 H-bridge type. Notes This is for robots with motor drives. sdtur - s et default turn urgency Purpose Set the default turn urgency Syntax sdtur value Arguments value 1 to 50 Examples sdtur 10 Set default turn urgency to 10 setstmax - Set the Maximum Safe Operating Speed for the robot Purpose This allows a safe maximum speed to be specified and it will be enforced automatically. Syntax setstmax speed Arguments speed -100 to 100 Where: -100 full reverse 0 stop 100 full forward Notes This is for robots with motor drives. The limit set here is automatically enforced by the drive system. setstmin - Set the Minimum Safe Operating Speed for the robot Purpose This allows a safe minimum speed to be specified and it will be enforced automatically. Syntax setstmin speed Arguments speed -100 to 100 Where: -100 full reverse 0 stop 100 full forward Notes This is for robots with motor drives. The limit set here is automatically enforced by the drive system. slower - Pulse the drive motors backwards a little. Purpose This will briefly pulse both drive motors in the reverse direction a little and then turn them off. Syntax slower Examples slower Move robot backwards a little ssv - Set Speed Step Value Purpose Set the amount by which the speed of the drive motors will be changed by other commands such as turn. Syntax ssv value Arguments value 1 to 50 Pushers No Returns Nothing Examples ssv 10 Set to 10 Notes This is for robots with motor drives. straight - Drive in a straight line Purpose Causes the robot to drive in a straight line. Syntax straight stop - Stop both of the robots drive motors Purpose Use this to bring the robot to a halt. Syntax stop Examples stop Halt the robot Notes This is for robots with motor drives. strpw - Set the linear actuator pulse width in milli secs Purpose This sets the width of the pulses used to move linear actuators attached to the JackBord via an L298 H-bridge. The shorter the pulse the slower and more precise the control is. Syntax strpw value Arguments value Pulse width in milli-seconds between 1 and 1000ms. Examples strpw 200 Set the pulse width to 200ms Notes This is for robots with motor drives. strtype - Set the steering type Purpose Set the type of steering being used on the robots drive system. Options are: Type Description 0 Normal differential drive 1 Rack and pinion steering 2 Single front steering wheel 3 L298 Linear Actuator ie Beach Robot. On L298 h-bridge motor no 1. Syntax stur value Arguments value Steering type, see above. Pushers No Returns Nothing Examples strtype 0 Set differential steering Notes This is for robots with motor drives. stur - Set turn urgency Purpose This is the increment used when turning. The higher the value the more aggressive turning will be. Syntax stur value Arguments value Turn urgency 1 to 500. This is a duty cycle. Pushers No Returns Nothing Examples stur 200 Set the turn urgency to 200 Notes This is for robots with motor drives. tgdir - Toggle the direction of travel. Purpose This toggles the current direction of travel of the drive motors. Syntax tgdir tsf - Set turn speed factor Purpose This is the increment used when turning. The higher the value the more aggressive turning will be. Syntax tsf value Arguments value 1 to 50 Pushers No Returns Nothing Examples tsf 10 Set the turn speed factor to 10. Notes This is for robots with motor drives. turn - Turn the robot left or right Purpose Provides a means of steering a robot using values in the range: -100 Full left turn 0 Straight 100 Full right turn The exact limits for left and right are set using the minleft and minright commands. Syntax turn value Arguments value -100 Full left turn 0 Straight 100 Full right turn Examples turn 0 Go straight turn -10 Soft left turn turn 90 Hard right turn Channels & Vars Channel 153 Notes This is for robots with motor drives. vd View - drive system status Purpose View the status of the motor drive system. Syntax vd
- Bumper Robot
This program is for the bumper robot. It has a front bumper connected to port A pin A1 and a back bumper connected to port A pin A2. When the robot collides with an object on the front bumper, it will first of all go backwards and secondly it will do a slight turn so as to avoid the object in the future. Likewise when it hits an object in the rear it will move forwards and do a slight turn. < Back Bumper Robot This program is for the bumper robot. It has a front bumper connected to port A pin A1 and a back bumper connected to port A pin A2. When the robot collides with an object on the front bumper, it will first of all go backwards and secondly it will do a slight turn so as to avoid the object in the future. Likewise when it hits an object in the rear it will move forwards and do a slight turn. Program --- Bumper Robot Program This program is for the bumper robot. It has a front bumper connected to port A pin A1 and a back bumper connected to port A pin A2. --- prog_vars = -- Keep track of the number of bumps. d/front 0 d/back 0 -- Track to no of times we have run. d/count 0 prog_vars. prog_start = print "Bumper Robot Program Setup" -- Reset the buttons rstb -- Setup the front bumper. -- Go back and turn left. btp a1 bms -50|lms -10|d500|lms -50|inc /front -- Setup the back bumper. -- Go forward and turn right. btp a2 bms 50|rms 10|d500|rms 50|inc /back -- Set both motors to forwards at 50 bms 50 prog_start. prog_loop = -- main program loop -- Increase the /count by 1 inc /count -- Check if we shoukd exit. any /count > 1000 -> exitprog prog_loop. prog_stop = print "Bye Front /front Back /back" -- Clear the buttons rstb -- Stop the robot stop prog_stop.
- Smart Led Example
This program will use the sled command in two ways. For this program you need a strip of 4 smart LEDs connected to port pin C5 of the JackBord. This program will set 4 LEDs to colors 1, 2, 3 and 4 respectively and do it live, so the LEDs will update as the program runs. Note there is a 1 second delay between each LED being set. In the second test the LEDs are set to the same colors with the same 1 second delay, except that we added the 0 at the end of each sled command. This tells the JackBord NOT to update the LEDs in real time and instead they all get turned on in one go at the end when the uled command is run. This shows the effect of the uled command. The program will run a few times and stop. < Back Smart Led Example This program will use the sled command in two ways. For this program you need a strip of 4 smart LEDs connected to port pin C5 of the JackBord. This program will set 4 LEDs to colors 1, 2, 3 and 4 respectively and do it live, so the LEDs will update as the program runs. Note there is a 1 second delay between each LED being set. In the second test the LEDs are set to the same colors with the same 1 second delay, except that we added the 0 at the end of each sled command. This tells the JackBord NOT to update the LEDs in real time and instead they all get turned on in one go at the end when the uled command is run. This shows the effect of the uled command. The program will run a few times and stop. Program --- Smart Led Example Program No 1 --- prog_vars = d/count 0 prog_vars. prog_start = pclear print "Setup Program" -- Setup 4 smart LEDs sledn 4 prog_start. prog_loop = -- Update the LEDs as we go. "Test 1 Update live" sledoff sled 1 1 d500 sled 2 2 d500 sled 3 3 d500 sled 4 4 d500 sledoff -- Update the LEDs at the end. "Test 2 Update at end." sled 1 1 0 d500 sled 2 2 0 d500 sled 3 3 0 d500 sled 4 4 0 d500 -- Update ALL LEDs in one go. usled dly 1000 sledoff inc /count any /count >= 3 -> exitprog prog_loop. prog_stop = print "Bye" sledoff prog_stop.
- Trigonometry: Calculate the Area of a Triangle
Trigonometry: Calculate the Area of a Triangle. Use of Sine function to find area of triangle. This program uses radians for the input angles. < Back Trigonometry: Calculate the Area of a Triangle Trigonometry: Calculate the Area of a Triangle. Use of Sine function to find area of triangle. This program uses radians for the input angles. Program --- Trigonometry: Calculate the Area of a Triangle Use of Sine function to find area of triangle This program uses radians for the input angles. By Geoff Fellows --- prog_vars = d/length1 0.0 d/length2 0.0 d/degrees_angle 0.0 d/radians 0.0 d/area 0.0 d/raw_sine 0.0 d/pi 0.0 prog_vars. prog_start = "Calculate the area of a triangle using the Sine function" "You need the length of two sides and the angle joining them" div 22 7 -> /pi -- the input sine function expects radians not degrees -- which means we will convert the angle to radians prog_start. prog_loop = "Enter length one and two and the angle" getline -> /length1 getline -> /length2 getline -> /degrees_angle "/length1 /length2 /degrees_angle" -- convert degress to radians div /degrees_angle 180 -> /radians mul /radians /pi -> /radians "/degrees_angle degrees = /radians radians" sin /radians -> /raw_sine mul 0.5 /length1 /length2 /raw_sine -> /area "=================================" "Print the area of the triangle is /area" exitprog prog_loop. prog_stop = print "Good bye" prog_stop.
- Weather Station
< Back Weather Station Program --- Wind vane A1 Anno A5 Rain B2 --- prog_vars = d/count 0 d/air_temp 0.0 d/rh 0 d/press 0.0 d/light 0 d/wind_speed 0.0 d/wind_dir 0 d/at_arc 0 d/display_update_timer 0 prog_vars. prog_start = pclear ptl 10 0 ^ts=35^ "Live Weather" i2con sctp a5 gvr a1 360 0 sctp b2 scgoff 38 1 574.0 -- Create a new Dataset for the Data newds "met 12 Oct 2021" -- Set the chans to include dslc 1 dslc 5 dslc 7 dslc 35 dslc 36 dslc 37 dslc 38 -- Set the log interval to 5mins slog 300 -- Start logging lgon setuct 1 25 setuct 2 5 -- Set the light update thresh to 500 setuct 35 500 -- Quit button pb 700 10 ^n=Quit^p=exitprog^ "Setup Done" prog_start. prog_loop = -- main program loop any /display_update_timer > 100 -> update_display "/display_update_timer" /display_update_timer 0 else inc /display_update_timer enda. prog_loop. update_display = -- Display the readings -- Air temp round /36 2 -> /air_temp pg 10 125 /air_temp ^id=airt^ts=24^tc=red^w=200^n=Air T^min=-10^max=40^ ptl 40 220 ^ts=20^tc=red^ "Air T /air_temp" -- RH /rh /37 pvl 250 150 /rh ^id=rh^lw=10^lc=blue^ ptl 240 220 ^id=rht^ts=20^tc=blue^ "RH /rh" -- Light mapi 0 50000 0 200 /35 -> /light sub 200 /light -> /light pvl 440 150 /light ^id=srad^lw=10^lc=yellow^ ptl 440 220 ^ts=20^tc=yellow^ "Light /light /35" -- Wind Direction sub 360 /a1 -> /wind_dir pal 150 420 80 /wind_dir ^lw=10^lc=cyan^ ptl 150 500 ^ts=20^tc=cyan^ "Dir /wind_dir" update_display. prog_stop = print "Bye" prog_stop.
- Basic Soil Moisture Meter
This program uses a capacitive soil moisture probe connected to pin a1 of the JackBord to measure the moisture in some soil and display the reading using the USER LED on the JackBord. The color of the LED will match the soil moisture reading as follows: >= 90% Green >= 75% Cyan >= 50% Navy >= 25% Orange >= 10% Magenta >= 0% Red < Back Basic Soil Moisture Meter This program uses a capacitive soil moisture probe connected to pin a1 of the JackBord to measure the moisture in some soil and display the reading using the USER LED on the JackBord. The color of the LED will match the soil moisture reading as follows: >= 90% Green >= 75% Cyan >= 50% Navy >= 25% Orange >= 10% Magenta >= 0% Red Program --- Basic Soil Moiture Meter Program Get readings from the sensor on pin a1 and scale them between the min and max calibration values to get a reading between 0 and 100. Display them using the JackBords USER LED. That wy you dont need a web browser to use the meter. --- prog_vars = d/count 0 -- Calibration values d/min_value 6 d/max_value 56 -- The final soil moisture reading d/soil_moisture 0 d/moisture_color 0 prog_vars. prog_start = pclear print "Program Start" -- Setup the sensor on pin a1 gvr a1 100 0 prog_start. prog_loop = -- main program loop -- Get a fresh reading get_soil_moisture -- Update the USER LED's color display_moist_color /soil_moisture print "/count a1 /a1 Soil moisture /soil_moisture" -- Check if we have done 100 readings inc /count any /count >= 100 -> exitprog -- New reading every second d1000 prog_loop. get_soil_moisture = -- Get the reading from a1 and scale it mapi /min_value /max_value 0 100 /a1 -> /soil_moisture get_soil_moisture. display_moist_color /moisture 0 = -- Use ant command to shoose color to display. -- >= 90% Green -- >= 75% Cyan -- >= 50% Navy -- >= 25% Orange -- >= 10% Magenta -- >= 0% Red -- NO Reading Dim white ant /moisture -> >= 90 -> l1 8 >= 75 -> l1 12 >= 50 -> l1 13 >= 25 -> l1 5 >= 10 -> l1 14 >= 0 -> l1 3 -> l1 1 ant. display_moist_color. prog_stop = print "Bye" prog_stop.
- Auto Booting/Running a Program
The setboot command is used to set one of the programs on the JackBord to run when the JackBord is turned on. < Back Auto Booting/Running a Program The setboot command is used to set one of the programs on the JackBord to run when the JackBord is turned on. Program Setting a Program to Run at Boot The command format is: setboot prog_number Where prog_number is the number of the program we wish to run at boot, ranging from 1 to 10. To set program number 5 to run at boot type: setboot 5 The next time the JackBord starts it will run program number 5. You can check which program is set to auto run using the vp program status command. Once you have set the boot program you can test it using the reboot command to re-start the JackBord, if all is well the selected program should run. Clearing a Set Boot Program Use the setboot command with program number 0 eg: setboot 0 This will stop the currently running boot program and clear it so no program will run automatically on the next boot. Running the Boot Program Just Once To run the boot program just once, ie because it just needs to configure the robot, you should place an exitprog command at the bottom of the prog_loop task. That way the program_loop will only run once and the program will exit. Notes: You cant run other programs while the boot program is running, this is because the JackBord can only run one program at a time. You can use the command line and most of the commands while the boot program is running.
- Korahs Random Lights
This program will randomly flash 5 LEDs attached to Port C using a random number to decide which LEDs are lit. < Back Korahs Random Lights This program will randomly flash 5 LEDs attached to Port C using a random number to decide which LEDs are lit. Program --- Korahs Random Lights Program This program will randomly flash 5 leds attached to port C using a random number to decide which LEDs are lit. --- prog_vars = -- Holds the random number d/random 0 d/count 0 prog_vars. prog_start = print "Korahs Random Lights Program" /random 0 prog_start. prog_loop = -- main program loop -- Increase the /count by 1 inc /count -- Get a new random number between 0 and 6. rand 0 6 -> /random print "Count /count rand no /random" -- Use the ant the determine which LED we should light -- up based upon the random number. -- A 6 will turn them all off. ant /random -> = 1 -> c1 1 = 2 -> c2 1 = 3 -> c3 1 = 4 -> c4 1 = 5 -> c5 1 -> coff ant. -- Check if we shoukd exit. any /count > 1000 -> exitprog prog_loop. prog_stop = print "Bye" prog_stop.
- Advanced Mine
This program assumes that the mines trigger switches are on pins A2 & A3. When one of the switches is triggered we will either add or remove health from the robot. The RGB LEDs are connected to Port C: RED C1 GREEN C2 BLUE C3 The color values for the /color variable are: The port C values say which port C pin will be on for a given color. Color no 0 off 1 Red. C1 2 Green C2 3 Blue C3 4 Cyan C2 C3 5 Purple. C1 C3 6 Yellow C1 C2 < Back Advanced Mine This program assumes that the mines trigger switches are on pins A2 & A3. When one of the switches is triggered we will either add or remove health from the robot. The RGB LEDs are connected to Port C: RED C1 GREEN C2 BLUE C3 The color values for the /color variable are: The port C values say which port C pin will be on for a given color. Color no 0 off 1 Red. C1 2 Green C2 3 Blue C3 4 Cyan C2 C3 5 Purple. C1 C3 6 Yellow C1 C2 Program --- Advanced Mine Program --- prog_vars = d/triggers 0 d/health 10 d/trig_result 0 d/flashes 0 d/start_time 0 d/run_time 0 prog_vars. prog_start = "Mine Start" /start_time /uptime -- Setup the trigger for pin A2 & A3 btp a2 do_boom btp a3 do_boom prog_start. prog_loop = -- Calc run time sub /uptime /start_time -> /run_time -- Check if we are dead >>>>>>>>>>> any /health <= 0 -> -- Dead "XXXXXX WE DIED XXXXX" repeat 10 -> tg c1|d50 exitprog enda. -- Exit any /triggers > 10 -> exitprog any /run_time >= 60 -> "Time up"|exitprog prog_loop. do_boom = --- The mine is triggered work out the health or damage. --- /flashes 0 -- Get a new random number between -6 and 6. rand -6 6 -> /trig_result -- Update the health var add /health /trig_result -> /health -- Check for negative health, if so flash 4 times. any /trig_result < 0 -> /flashes 4 inc /triggers print "Trig /triggers TR /trig_result Health /health flash /flashes" set_color /health /flashes do_boom. set_color /color 0 /led_flash 0 = --- Colors 0 off 1 Red 2 Green 3 Blue 4 Cyan c2 c3 on 5 Magenta c1 c3 6 . Yellow c1 c2 --- -- All c off coff -- Get abs version of color abs /color -> /color repeat /led_flash -> -- Set the color on Port C ant /color -> = 1 -> c1 1 = 2 -> c2 1 = 3 -> c3 1 = 4 -> c3 1|c4 1 = 5 -> c1 1|c3 1 = 6 -> c1 1|c2 1 -> c1 1|c2 1 ant. d250 -- any /led_flash > 2 -> d250 -- any /led_flash < 2 -> d1000 coff repeat. set_color. prog_stop = print "Bye" -- clear the buttons rstb prog_stop.
- Counting
This program lists the numbers from 0 to 10 and exits. < Back Counting This program lists the numbers from 0 to 10 and exits. Program --- Counting Program Lists the numbers from 0 to 10. --- prog_vars = d/count 0 prog_vars. prog_start = print "Counting Program Start" prog_start. prog_loop = -- Main program loop -- Increment the value of the /count var by 1 inc /count -- Display the new count print "Count /count" -- Decide if it's time to exit any /count >= 10 -> exitprog prog_loop. prog_stop = print "Bye" prog_stop.
- Traffic Light
Pressing a button on pin C1 cycles the USER LED traffic light through green, orange and red. < Back Traffic Light Pressing a button on pin C1 cycles the USER LED traffic light through green, orange and red. Program --- Traffic Light Program Pressing a button on pin C1 cycles the USER LED traffic light through green, orange and red. --- prog_vars = -- Traffic Light State -- 1 = green 2 = orange 3 = red d/tl_state 1 prog_vars. prog_start = pclear print "Traffic Program Start" -- Setup the button btp c1 change_light -- Set the light to red by default l1 3 prog_start. prog_loop = -- main program loop patdog prog_loop. change_light = -- Button pressed -- Move to next state any /tl_state <= 3 -> inc /tl_state enda. -- Reset back to green any /tl_state >= 4 -> /tl_state 1 enda. -- Update the color ant /tl_state -> = 1 -> l1 8 = 2 -> l1 5 = 3 -> l1 3 -> l1 3 ant. print "New State /tl_state" change_light. prog_stop = print "Bye" prog_stop.
- Random Light Flasher Using the an Command
Random Light Flasher Program using the rand and ant comamnds This program uses the rand and ant commands to randomly flash LEDs connected to port A. The rand command generates a number between 1 and 5 and stores it in the /rand_no var. The ant command evaluates the value of /rand_no and toggles the required LED on port A. The program will run for /runs_to_do and stop. < Back Random Light Flasher Using the an Command Random Light Flasher Program using the rand and ant comamnds This program uses the rand and ant commands to randomly flash LEDs connected to port A. The rand command generates a number between 1 and 5 and stores it in the /rand_no var. The ant command evaluates the value of /rand_no and toggles the required LED on port A. The program will run for /runs_to_do and stop. Program --- Random Light Flasher Program using the rand and ant comamnds This program uses the rand and ant commands to randomly flash LED's connected to port A. The rand command generates a number between 1 and 5 and stores it in the /rand_no var. The ant command evaluates the value of /rand_no and toggles the required LED on port A. The program will run for /runs_to_do and stop. --- prog_vars = d/runs_to_do 50 d/runs_done 0 d/rand_no 0 prog_vars. prog_start = aoff prog_start. prog_loop = -- Do /runs_to_do runs repeat /runs_to_do -> -- Get a random number rand 1 5 -> /rand_no "rand no /rand_no run no /runs_done" ant /rand_no -> = 1 -> tg a1 = 2 -> tg a2 = 3 -> tg a3 = 4 -> tg a4 = 5 -> tg a5 -> "out of range number /rand_no" ant. repeat. -- dec the runs to do and inc runs done dec /runs_to_do inc /runs_done -- exit after runs done any /runs_done >= /runs_to_do -> exitprog prog_loop. prog_stop = -- Turn the port A Leds off aoff print "Bye" prog_stop.
- Any Statement Example
In this example we check the value of /count against 10 and quit when /count is 10. < Back Any Statement Example In this example we check the value of /count against 10 and quit when /count is 10. Program -- Any example no 1 prog_vars = d/count 0 prog_vars. prog_start = print "Any example no 1" prog_start. prog_loop = inc /count print "Count /count" any /count >= 10 -> exitprog prog_loop. prog_stop = print "Bye" prog_stop.
- All Statement Test Example
This is an example program showing how to use all statements. < Back All Statement Test Example This is an example program showing how to use all statements. Program --- all Statement Test Program no 1 This is an example program showing how to use all statements. --- prog_vars = d/pin1 0 d/pin2 1 d/pin_no 0 d/text1 "Jack" d/text2 "Jill" prog_vars. prog_start = print " -------------- " print "all statement test program" prog_start. prog_loop = -- Test 1 Should be TRUE ie /pin_no != 1 /pin1 0 /pin2 1 /pin_no 2 all /pin_no != 1 -> print "Test 1 TRUE CORRECT" else print "Test 1 FALSE WRONG" exitprog enda. -- Test 2 Should be FALSE ie /text1 not = to /text2 all /text1 = /text2 -> print "Test 2 TRUE WRONG" else print "Test 2 FALSE CORRECT" exitprog enda. -- Test 3 Should be TRUE ie /text1 is != /text2 all /text1 != /text2 -> print "Test 3 TRUE CORRECT" else print "Test 3 FALSE WRONG" exitprog enda. -- Test 4 Should be TRUE ie /text1 is "JacK" all /text1 = "Jack" -> print "Test 4 TRUE CORRECT" else print "Test 3 FALSE WRONG" exitprog enda. prog_loop. prog_stop = print "Bye" prog_stop.
- TOP Smart RGB LED Demo 2
This program uses the TOPs RGB LED to slowly display red, green and blue colors one after the other. < Back TOP Smart RGB LED Demo 2 This program uses the TOPs RGB LED to slowly display red, green and blue colors one after the other. Program --- TOP Smart RGB LED Demo 2 This program uses the TOP's RGB LED to slowly display red, green and blue colors one after the other. --- prog_vars = d/count 0 d/led_red 0 d/led_green 0 d/led_blue 0 prog_vars. prog_start = pclear sledn 1 print "Smart RGB Demo 2: Start" prog_start. prog_loop = -- main program loop -- red repeat 255 -> -- display the color sled 1 /led_red /led_green /led_blue inc /led_red 1 repeat. /led_red 0 -- green repeat 255 -> -- display the color sled 1 /led_red /led_green /led_blue inc /led_green 1 repeat. /led_green 0 -- blue repeat 255 -> -- display the color sled 1 /led_red /led_green /led_blue inc /led_blue 1 repeat. exitprog prog_loop. prog_stop = print "Bye" sledoff prog_stop.
- A/D Commands
Command Guide < Back A/D Commands adcal - Set the A/D Converter gradient and offset values Purpose Use this to set a gradient and offset for the JackBord’s A/D converter. This will be used on all analog readings. Syntax adcal grad offset Arguments grad A floating point gradient value. offset A floating point offset value. Examples adcal 3.3 12 Notes Don’t use this unless you know what you are doing. gav - Get analog voltage reading. Returns a floating point value. Purpose Get a voltage reading from the specified port analog pin. If the min and max values are provided the output will be scled between them. If no min & max values are provided the output will be the reading from the A/D in volts. Syntax gav #~ min max Arguments #~ The pin from which to get the reading min An integer minimum value. -1000 to 1000 max An integer maximum value. -1000 to 1000 Examples 1. Just get a voltage reading from port pin A1: gav a1 The reading will be between 0V and 3.1V. 2. Scale the input voltage between 0 and 12V: gav a1 0 12.0 This means that if the input voltage is 3.1V the voltage from the JackBord will be 12V. You can use this to turn the JackBord's analog input into a voltage probe that can measure various voltage ranges. For example if you put two 10K resistors into a potential divider and feed the center into port pin A1, run this command: gav a1 0 6.2 This will have the effect of scaling the input between 0 and 6.2V and the value given by the gav command will be correct. Notes: To stop using the pin as an analog input run the gav command with the pin name and 0. eg to stop using a2 as an analog input run gav a2 0 . admax - Set the A/D Converter Max Voltage Scale Value Purpose If this is not 0 it is used to set the Max voltage that the A/D converter 4096 reading represents. Syntax admax value Arguments value A floating point voltage value, 0 to 100 Notes Don’t use this unless you know what you are doing. adwmax - Set the A/D converters ad_max_raw_value Purpose Sets the max digital reading we will get at full scale. This is usually 10 bits = 1024 12 bits = 4096 Syntax adwmax value Arguments value A positive integer value, between 1000 and 4096. Notes Don’t use this unless you know what you are doing.
- RGB Color Sensor Demo 2
This program is for the RGB color sensor, and plots the clear, red, green and blue color values as vertical bars on the show page. < Back RGB Color Sensor Demo 2 This program is for the RGB color sensor, and plots the clear, red, green and blue color values as vertical bars on the show page. Program --- RGB Color Sensor Demo 2 --- prog_vars = d/red_line 0 d/green_line 0 d/blue_line 0 d/clear_line 0 prog_vars. prog_start = pclear d1000 ptl 10 5 ^ts=24^ "RGB Color Sensor Demo Program" -- Enable the I2c system i2con -- Display the Quit button pb 400 20 ^n=Quit^p=exitnow^ prog_start. prog_loop = -- main program loop -- Invert the values so the bars go up sub -1 /cs_clear -> /clear_line sub -1 /cs_red -> /red_line sub -1 /cs_green -> /green_line sub -1 /cs_blue -> /blue_line -- Display the colors as vertical bars pvl 25 300 /clear_line ^lc=yellow^lw=20^ pvl 75 300 /red_line ^lc=red^lw=20^ pvl 125 300 /green_line ^lc=green^lw=20^ pvl 175 300 /blue_line ^lc=blue^lw=20^ -- Display the values ptl 15 300 ^ts=16^ "/cs_clear" ptl 65 300 ^ts=16^ "/cs_red" ptl 115 300 ^ts=16^ "/cs_green" ptl 165 300 ^ts=16^ "/cs_blue" -- Set the USER 1 LED to the color. l1 /cs_red /cs_green /cs_blue prog_loop. prog_stop = ptl 100 200 ^ts=75^ "Bye" prog_stop.
- Short Range Proximity Sensor
This program displays the analog output from the sensor as a bar gauge. The sensors analog output goes to pin a1. The analog output of the sensor is scaled between 0 and 100 by the gvr command. < Back Short Range Proximity Sensor This program displays the analog output from the sensor as a bar gauge. The sensors analog output goes to pin a1. The analog output of the sensor is scaled between 0 and 100 by the gvr command. Program --- Short Range Proximity Sensor Program This program disoplays the analog output from the sensor as a bar gauge. The sensors analog outpout goes to pin a1. tmt3Nndt --- prog_vars = d/line_length 0 prog_vars. prog_start = pclear print "Program Start" -- Setup the pin as an analog input. gvr a1 0 100 ptl 10 10 ^ts=24^ "Distance" -- Add the quit button pb 150 20 ^n=Quit^p=exitprog^ prog_start. prog_loop = -- main program loop -- Invert the line so it goes up as the value does. sub -1 /a1 -> /line_length -- Plot the sensor value pvl 50 175 /line_length ^lw=10^ -- Display the value ptl 45 175 ^id=dis^ts=24^ "/a1" -- Short delay d250 prog_loop. prog_stop = ptl 10 10 ^ts=24^ "Bye" prog_stop.
- Sheep Dog Program
This program works out how many sheep dogs are required to look after a given number of black and white sheep. < Back Sheep Dog Program This program works out how many sheep dogs are required to look after a given number of black and white sheep. Program --- Sheep Dog Program --- prog_vars = d/white_sheep 0 d/black_sheep 0 d/total_sheep 0 d/runs_to_do 10 d/runs_done 1 d/colors[] "" prog_vars. prog_start = print "Sheep Program." print "No of runs to do /runs_to_do" -- Setup the colors /colors[1] "Black" /colors[2] "White" prog_start. prog_loop = -- Get more sheep, and see what color they are. get_sheep -> /qty_of_sheep /color "/runs_done > New Sheep qty /qty_of_sheep color /colors[/color]" -- Check the type of sheep, update respective count any /color = 1 -> -- update black sheep add /black_sheep /qty_of_sheep -> /black_sheep else -- update white sheep add /white_sheep /qty_of_sheep -> /white_sheep enda. -- Update the total no of sheep add /white_sheep /black_sheep -> /total_sheep -- Check how many sheep dogs we need for the sheep check_dogs /total_sheep -> /dogs_needed -- Check if its time to exit yet any /runs_done >= /runs_to_do -> exitprog enda. -- Next run inc /runs_done prog_loop. get_sheep -> /qty_of_sheep 0 /color 1 = --- Returns a random quantity of sheep, of a random color. --- rand 0 100 -> /qty_of_sheep -- Get the color of this batch of sheep. -- 1 = black 2 = white rand 1 2 -> /color get_sheep. check_dogs /no_of_sheep 0 -> /dogs_needed 0 = --- Calc the number of sheep dogs we need to manage this many sheep. Return the no of dogs we need. --- mul 0.1 /no_of_sheep -> /dogs_needed check_dogs. prog_stop = -- display the final results print "We need /dogs_needed dogs to manage them" print "Total sheep /total_sheep" print "Black /black_sheep White /white_sheep" print "Exit Prog" prog_stop.
- Colour Plot
This program uses a variable resistor on Port pin A1 to control the color of the USER LEDs and plot the values as well. < Back Colour Plot This program uses a variable resistor on Port pin A1 to control the color of the USER LEDs and plot the values as well. Program --- Color Plot Program Uses a variable resistor on Port pin A1 to control the color of the USER LEDs and plot the values as well. --- prog_vars = d/color 0 d/xpos = 0 prog_vars. prog_start = pclear ptl 50 10 ^ts=24^ "Color Program Start" -- Setup the analog input gvr a1 200 500 pb 50 50 ^n=Quit^p=exitprog^ prog_start. prog_loop = -- main program loop print "Xpos /xpos" inc /xpos 2 any /xpos >= 600 -> pclear|/xpos 0 -- Plot the Point pp /xpos /a3 ^lw=2^fc=/color ^lw= /color ^ -- Set the User led colors mapi 200 500 0 15 /a3 -> /color l1 /color l2 /color l3 /color prog_loop. prog_stop = ptl 200 200 ^tc=red^ts=24^ "Bye" prog_stop.
