Search Results
285 results found with an empty search
- Junior Robot Wars 25 Nov 2020
< Back Junior Robot Wars 25 Nov 2020 This is the program to be run on the competitors JackBords for the juniors robot wars competition on the 3rd Dec 2020 at Paraparaumu College. The claw servo is connected to pin a3 and is used to open and close the claw when the user presses the u1 button on the drive page or the u2 button. This program assumes there are two bumpers on the robot connected to pins A1 & A2. These are the triggers. There is also an RGB LED attached to pins C1 to C3 on port C in the following manner: C1 = RED C2 = GREEN C3 = BLUE When the program starts the LED will flash green several times. The robot will start with a health of 10. When a bumper is triggered a random value between -6 and 6 will be generated and added to the robots health. Thus if the value is negative the health will go down and if positive it will go up. The RGB LED will flash a color ONCE if the health was positive and TWICE if negative. The health colors will be: 0 WHITE 1 RED 2 GREEN 3 BLUE 4 CYAN 5 PURPLE 6 YELLOW End of the Round: If the number of triggers is 10 then the robot died and the LED will show RED. If the robot ran out of health it will show BLUE. Robot Death Cause: RED Hits BLUE Health <= 0 Note: Make sure you set the program to run at boot with the setboot command. eg if its in program slot 2 use setboot 2 Program --- Junior Robot Wars Program 3 Dec 2020 --- prog_vars = d/hits 0 d/hit_result 0 d/health 10 d/flashes 0 d/died 0 prog_vars. prog_start = "Mine Start" coff repeat 10 -> tg c2|d100 -- Setup the bumper pins A1 & A2 btp a1 do_boom btp a2 do_boom btp u1 svp a3 120 btp u2 svp a3 0 prog_start. prog_loop = any /health <= 0 -> -- Dead "XXXXXX WE DIED XXXXX" inc /died 2 repeat 10 -> tg c1|d50 exitnow enda. -- Exit if many hits any /hits >= 10 -> inc /died|exitnow 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 -> /hit_result -- Update the health var add /health /hit_result -> /health -- Flash for neg /hit_result ie deduct health any /hit_result < 0 -> /flashes 2 -- Count no of hits inc /hits print "T /hits TR /hit_result H /health F /flashes" -- Display hit result on RGB LED show_hit_color /hit_result /flashes do_boom. show_hit_color /hit_color 0 /hit_flashes 0 = -- All c off coff -- Get abs version of color abs /hit_color -> /hit_color repeat /hit_flashes -> -- Set the color on Port C ant /hit_color -> = 1 -> c1 1 = 2 -> c2 1 = 3 -> c3 1 = 4 -> c2 1|c3 1 = 5 -> c1 1|c3 1 = 6 -> c1 1|c2 1 -> c1 1|c2 1|c3 1 ant. d100 coff repeat. show_hit_color. prog_stop = --- RED = Died from Hits BLUE = Died from Health --- coff ant /died -> = 1 -> "Died Hits"|c1 1 = 2 -> "Died Health"|c3 1 -> c2 1 ant. -- clear the buttons rstb prog_stop.
- Raspberry Pi Shake Test Program 2 Aug 2021
< Back Raspberry Pi Shake Test Program 2 Aug 2021 This is a test program. It plots the data on two charts. Program --- Raspberry Pi Shake Test Program --- prog_vars = d/count 0 d/xpos 0 d/pro_EHZ 0.0 d/prev_EHZ 0.0 d/pro_EHZ_max 0.0 d/prev_EHZ_max 0.0 d/range_EHZ 0.0 prog_vars. prog_start = pclear d1000 -- Display the Title. ptl 100 -15 ^ts=24^tc=blue^ "Raspberry Shake Alert Program" -- Add Quit Button pb 25 50 ^n=Quit^p=exitprog^ prog_start. prog_loop = -- main program loop inc /count -- Stop after 10,000 readings any /count >= 10000 -> exitprog any /count >= 3 -> -- grsk AM.R5C47 -- TKMP grsk AM.R7DD4 -- Pcol d500 -- d-trend the reading sub /rs_EHZ /prev_EHZ -> /pro_EHZ -- Invert the negative values abs /pro_EHZ -> /pro_EHZ sub /rs_EHZ_max /prev_EHZ_max -> /pro_EHZ_max abs /pro_EHZ_max -> /pro_EHZ_max sub /rs_EHZ_max /rs_EHZ_min -> /range_EHZ abs /range_EHZ -> /range_EHZ d/title "My Graph Title" -- Plot the pro_EHZ geophone value plot 10 100 ^id=rs^n=/title^t1n=EHZ^t2n=Max^xdp=100^xp=/xpos^v1=/pro_EHZ^v2=/pro_EHZ_max^ plot 10 400 ^id=ra^t1n=EHZ^t2n=Max^xdp=100^xp=/xpos^v1=/rs_EHZ_max^v2=/range_EHZ^ -- Display the plot value ptl 30 20 ^ts=16^ "X /xpos > EHZ /rs_EHZ pro EHZ /pro_EHZ max /pro_EHZ_max" -- Check for a Quake any /pro_EHZ >= 500 -> -- YES we have a quake ptl 100 40 ^ts=25^tc=red^ "Tapapa Hopukina Kia mau" else -- NO no quake ptl 100 40 ^ts=25^tc=Lime^ "OK" enda. -- Next Xpos inc /xpos enda. -- Update the previous value. /prev_EHZ /rs_EHZ /prev_EHZ_max /rs_EHZ_max prog_loop. jack = tg l1 jack. prog_stop = ptl 525 5 ^ts=75^ "Bye" prog_stop.
- L298 H-Bridge Commands
< Back L298 H-Bridge Commands clr298 - Clear L298 Bridge Settings to Defaults Purpose This will disable the l298 bridges and return the Port C & D pins to their defaults. Syntax clr298 con298 - Control an L298 H-Bridge Purpose Allows the specified L298 H-bridge to be controlled. The direction and speed of each half of the bridge may be set. Note: The L298 H-Bridge must be connected to the JackBord as follows: L298 JackBord L298 ENA1 (PWM signal) C1 L298 IN1 C2 L298 IN2 C3 L298 ENA2 (PWM signal) C4 L298 IN3 C5 L298 IN4 D1 Syntax con298 bridge motor speed Arguments bridge The number of the bridge to control. 1 or 2. motor The number of the motor on the bridge to control. 1 or 2. speed The speed to be applied to the specified motor. The speed is between -100 and 100. 100 = Full forwards speed 0 = Stop -100 = Full reverse speed Examples con298 1 1 100 Full forward speed on motor 1 on bridge 1. l298 - List the L298 bridge settings Purpose Shows the settings of the L298 bridges. Syntax l298 p298 - Pulse L298 H-Bridge Purpose Pulse the specified l298 h-bridge no for the no of pulses with each separated by a delay in msecs. Note: The L298 H-Bridge must be connected to the JackBord as follows: L298 JackBord L298 ENA1 (PWM signal) C1 L298 IN1 C2 L298 IN2 C3 L298 ENA2 (PWM signal) C4 L298 IN3 C5 L298 IN4 D1 Syntax p298 B M P L D Arguments B The number of the bridge to control. 1 or 2. M The number of the motor on the bridge to control. 1 or 2. P The number of pulses to send. L The length in milli-seconds of each pulse. D The delay in milli-seconds between each pulse. Examples p298 1 1 5 75 100 Pulse motor 1 on bridge 1 with 5 pulses each 75ms wide and with a 100ms delay between pulses. rst298 - Reset L298 Bridge Settings to Defaults Purpose Reset the l298 bridges and disable them. Syntax rst298 sap - Set Linear Actuator Position Purpose This command will set the specified linear actuator shaft to the specified position. Syntax sap B M pos Arguments B The number of the bridge to control. 1 or 2. M The number of the motor on the bridge to control. 1 or 2. pos The position of the END of the shaft from its fully closed position. Examples p298 1 1 5 75 100 Pulse motor 1 on bridge 1 with 5 pulses each 75ms wide and with a 100ms delay between pulses. Notes The width in pulses of the actuators full draw must be established beforehand to avoid damage. The actuator should be of the type that automatically stops at each end of its extension. apid - Set the Wifi access point SSID to use in World mode Purpose Sets the Wifi access point SSID that the JackBord will try to connect to when it boots into World mode. Syntax apid SSID Arguments SSID The Wifi access point SSID. From 1 to 30 characters. Examples apid Tree Set the SSID to Tree apid Big Fat Cat Set the SSID to Big Fat Cat appw - Set the Wifi access point password to use in World mode Purpose Sets the Wifi access point’s password of the access point the JackBord will try to connect to in World mode. Syntax appw password Arguments password The Wifi access point password. From 8 to 20 characters minimum. Examples appw fish eat frogs Set the access point password to fish eat frogs fuserap - Force the use of the user set Wifi access point. Purpose If its set to 1 this means we want to force the JackBord to use the SSID set in the var even though the JBHub access point may also be available. Syntax fuserap value Arguments value 0 = Don’t force the use of the users ap. 1 = Yes do force the use of the users ap Examples fuserap 0 fuserap 1 hget - Do an http request to the specified URL Purpose This will do an http GET request to the specified URL and store the results in the output variable, which must be of a text type. Syntax hget “URL” -> result Arguments “URL” The http URL, in “” quotes to which the GET request is to be made. result This is a text variable that holds the result of the get request. Examples hget “www.google.com” -> /result
- Basic Soil Moisture Meter
< 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.
- Moving Circle
< Back Moving Circle Use the TOP to connect the POT1 to pin A1 and POT2 to pin A2. The LEFT POT will control the balls position on the X-axis and the RIGHT POT will control the balls position on the Y-axis. Program --- Moving Circle Program Use the TOP to connect the POT1 to pin A1 and POT2 to pin A2. The LEFT POT will control the balls position on the Xaxis and the RIGHT POT will control the balls position on the Yaxis. --- prog_vars = d/count 0 d/display_width 874 d/display_height 630 prog_vars. prog_start = pclear print "Moving Circle Program" gvr a1 0 /display_width -- Y-axis up and Down gvr a2 0 /display_height -- Xaxis left and right prog_start. prog_loop = -- main program loop -- Display the X and Y values ptl 10 10 "X /a1 Y /a2" -- Display the orange ball on the Show page at the position -- set by the values of A1 and A2. pcr /a1 /a2 50 ^id=cat^fc=orange^ prog_loop. prog_stop = print "Bye" prog_stop.
- Traffic Light
< 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.
- Sensors - Short Range Proximity
< Back Short Range Proximity This sensor uses an infrared transmitter and receiver to gauge the distance between the sensor and an object near it. It has a digital and an analog output which can be used to control things in response to the presence or absence of an object. This sensor uses an infrared transmitter and receiver to gauge the distance between the sensor and an object near it. It has a digital and an analog output which can be used to control things in response to the presence or absence of an object. Quick Commands To get the sensor working, assuming the analog pout is connected to port A a1 and the digital output is connected to a2, enter the commands below at the command prompt. gvr a1 0 100 get a2 The gvr a1 0 100 will result in the value of a1 increasing as an object moves away from the sensor. You can see this change on the LIVE page. Buttons The button press btp and button release btr commands can be used with this sensor. This example uses a button on port a pin a2 and turns the USER LED (l1) on when the sensor detects an object. Removing the object turns it off. btp a2 l1 1 btr a2 l1 0 Videos Getting Started Using the Sensor NOTES AND CAUTIONS: This sensor needs to be adjusted if you want to use the digital output It's maximum range is about 5cm Ambient lighting can affect the performance of the sensor Parts of the Sensor Power LED - Turns on when the power is applied. Detection LED - Turns on when an object is detected. Variable Resistor - Used to adjust the sensitivity of the digital output. Transmitter - The infrared transmitter. Receiver - The infrared receiver. How it Works The transmitter sends an infrared signal and the receiver receives any signal reflected by an object nearby. The closer the objects the stronger the infrared signal that's returned and the lower the output voltage on the analog output. The digital output will go high (3V) when an object is detected and the blue variable resistor sets the trigger threshold for the digital output. Input and Output Pins The sensor has two output pins described below: Connecting the Sensor to the JackBord First bolt the sensor onto port A using an M4 nut and bolt. This is because we're going to use the pins from port A to control the sensor and specifically we need the analog inputs on port A. Take a green jumper wire and connect it to the ground pin on the JackBord and take the other end and connect it to the green ground pin on the sensor. Connect a yellow jumper wire to the 3V pin on the JackBord on port A and then connect the other end to the 3V power input on the sensor. Connect a black jumper wire to the digital output of the sensor and the other end goes to port A pin a2. Connect the analog output of the sensor which is the white pin onto port pin a1 of the JackBord. When you are done it should look like the picture below: Previous Next
- Sensors - Colour Sensor Module
< Back Colour Sensor Module The TCS34725 colour module allows the JackBord to determine the colour of a surface or object placed near the sensor. The TCS34725 color module allows the JackBord to determine the color of a surface or object placed near the sensor. Connecting the Sensor to the JackBord The sensor uses the I2C bus on the JackBord, which is located on port D. The diagram below shows the connections between the color sensor and the JackBord. Once you have connected the sensor to the JackBord log into your dashboard and open the command line. Once there we need to type the following commands 1. To turn on the I2C System, type: i2con 2. To find the color sensor, type: f2c This will find the sensor and display a result like the one below. > f2c < Finding I2C Devices.... < TCS34725 RGB Color Sensor at address [41] < Found 1 devices If the sensor is not found check your connections. 3. To get some readings, type: gt you should see something like this: 26 CT COLOR TEMP 7749 7749.00 K 27 LIGHT LUX 845 845.00 lux 28 RED RED 797 797.00 Int 29 GREEN GREEN 1307 1307.00 Int 30 BLUE BLUE 1310 1310.00 Int 31 CLEAR CLEAR 3354 3354.00 Int 32 COLOR COLOR 3354 3354.00 Txt Note the maximum value for all of the channels is 65535. Previous Next
- Sensors
Sensors BME280 Temperature, Relative Humidity and Pressure This sensor allows you to measure air temperature, relative humidity and atmospheric pressure. Learn more Colour Sensor Module The TCS34725 colour module allows the JackBord to determine the colour of a surface or object placed near the sensor. Learn more Infrared Obstacle Avoidance This unit will detect the presence of objects at distances of between about 2cm to 30cm. Learn more RGB Colour Detects the RGB (red, green and blue) colours of an object. Learn more Sound Detection Use the simple sound detector module to determine if there is sound above a pre-set threshold. Learn more Capacitive Soil Moisture This analog capacitive soil moisture sensor measures soil moisture by detecting the change in capacitance that stems from the moisture content of the surrounding soil. The output of the sensor is a voltage between 0V and 3V, with 0V being very dry soil and 3V being wet soil. Learn more HC-SR505 Mini PIR Infrared Motion HC-SR505 is an infrared module which detects the movement of a person or animal, at distances of up to 3m. Learn more MQ4 Methane Gas The MQ4 module allows the JackBord to detect methane gas at concentrations from 300 ppm to 10,000 ppm. The reading output from the sensor is an analog voltage from 0.1V to 4.5V. There is a digital output as well, pin DO, which is normally high and goes low when gas is detected. Learn more Short Range Proximity This sensor uses an infrared transmitter and receiver to gauge the distance between the sensor and an object near it. It has a digital and an analog output which can be used to control things in response to the presence or absence of an object. Learn more
- Turbidity Program
< Back Turbidity Program Measures turbidity and displays it on the USER led as colors. Program --- Turbidity Meter Program --- prog_vars = d/count 0 d/turbidity 0 prog_vars. prog_start = pclear print "Program Start" gvr a1 100 0 prog_start. prog_loop = mapi 0 100 1 16 /a1 -> /turbidity "a1 /a1 turbidity /turbidity" d250 l1 /turbidity prog_loop. prog_stop = print "Bye" prog_stop.
- Sensors - Capacitive Soil Moisture
< Back Capacitive Soil Moisture This analog capacitive soil moisture sensor measures soil moisture by detecting the change in capacitance that stems from the moisture content of the surrounding soil. The output of the sensor is a voltage between 0V and 3V, with 0V being very dry soil and 3V being wet soil. This analog capacitive soil moisture sensor measures soil moisture by detecting the change in capacitance that stems from the moisture content of the surrounding soil. The output of the sensor is a voltage between 0V and 3V, with 0V being very dry soil and 3V being wet soil. CAUTION Don't place the sensor in soil or water past the white line The sensor is powered from 5V The JackBord is NOT waterproof, so don't allow it to become wet How the Sensor Works The sensor has an oscillator whose frequency is controlled by capacitance, and this capacitance is affected by the moisture content of the soil in which the sensor is placed. Under dry conditions the sensor's output will be 3V, and as the sensor gets wet the output voltage will fall until it reaches 0V. The type of soil will also influence the readings so some experimentation may be required. Sensor Pins The pins of the sensor are shown below. Note this is the top view. The pins are shown in order starting from the top and moving down. The best wire color is included so you get into the habit of using consistent wires for the ground and power supply as this will save you a lot of trouble in the future. Connecting the Sensor to the JackBord To make using the sensor easier we have fitted some longer wires which may then be connected to the JackBord via the TOP terminals. So we first need to connect the TOP to the JackBord, then we need to connect the sensor to the TOP Connecting the TOP We will use the JackBord TOP to aid in connecting the sensor to the JackBord. The table below lists the connections we will make. See the pictures below for each step. The connections we will make to the JackBord are given below. The sensor's output will go to pin A1 which will be set as an analog input. Follow these steps. First we will connect the various jumpers to the TOP, make sure that you have your TOP already mounted on the JackBord and that the power wires for the TOP have already been connected. 1. Turn off the JackBord 2. Connect the green jumper wire from ground on the TOP to pin 3 of the TER, this is the 3 pin terminal block at the top of the TOP. 3. Connect the orange jumper wire to TER pin 2, then connect the other end to Port A1. This is the analog output from the sensor. 4. Connect the red jumper wire to the TER pin 1 and the other end to one of the +5V power pins on the top right of the TOP. This will supply power top the sensor. Once you have made the connections check them against the picture below and make sure they match. Now that the TOP is connected to the JackBord we need to connect the sensor to the TOP. Follow the steps below. Connecting the Sensor to the TOP To connect the sensor to the TOP via the terminal follow these steps. You will need a Philips screwdriver for this step to tighten the screws on the terminal block. DO NOT TIGHTEN THEM TOO MUCH. 1. Get the sensors black wire and insert it into the lower hole on the terminal block as shown below, this is TER pin no 3. Tighten up the screw by turning it clockwise. You should not be able to easily pull the wire out of the terminal. 2. Get the sensors yellow wire, this is the analog output wire, and connect it to the second terminal block slot as shown below, this is TER pin no 2. 3. Connect the sensors red wire to pin TER 3 of the terminal block. This is the 5V power supply from the JackBord to the sensor, this is TER pin no 1. Check your connections, they should look like the picture below. Also make sure the terminal block screws are tight enough, but not too tight. Using the Sensor with the JackBord Now that the sensor is connected to the JackBord turn it on and log into your dashboard. A convenient way to represent soil moisture is as a percentage where 0% is very dry and 100% is saturated. But the sensor is the opposite, it puts out 0V for wet and 3V for dry. Thus we need a way of scaling the readings between 0% for dry and 100% for wet. The gvr command will let us get the voltage reading from pin A1 and scale it between 0 and 100 such that the reading will increase with increasing moisture. At the command prompt, type the command below: gvr a1 100 0 This turns pin a1 into an analog input and tells it to scale the voltage readings so they are in the range 100 to 0, where 100 = 0V and 0 = 3V, remember the sensor puts out 0V for high moisture, which we want to be 100%. This is why the 0 and 100 in the gvr command are the opposite way around to what they would normally be. Go to the LIVE page and you should start to see readings from the sensor. Note: It does take a sensor a while to register an increase in soil moisture so don't be surprised if it takes between 20 and 30 seconds to respond. Testing the Sensor In Dry Air First get a reading for dray air, i.e. the sensor is by itself. This will be between 0 and about 10. Ours was 6. In Water: Now get a glass of water and place the sensor in it, be careful the water does NOT go past the line on the sensor, as shown below: BE CARFUL not to get the electronics wet. Now look at the live page and you will see the reading is about 50 to 60, yours will vary but should be about this. Ours was 57. We now have our two extreme readings, these tell us the minimum and maximum values we can expect from the sensor. Now its time to do some tests in soil and see how the sensor responds. In Dry Soil: Get a glass and put some dry soil in it. Make sure the soil level is high enough to reach just below the white line on the sensor. Now look at the readings and see what you get. For ours we got a reading of 18. In Moist Soil: Add some water to the soil, to just wet it but not soak it. Check the reading from the sensor, ours was about 33. In Soaked Soil: For this one add enough water that all of the soil is completely wet but there should NOT be pools of water at the top. Take a reading, ours was 57. In Flooded Soil: This is the last case and for this we add water such that there are pools of it at the top of the soil. This represents the maximum amount of water we can possibly get into the soil. Take a reading, ours was 58 which is about right. Dry Air Reading: Remove the sensor from the wet soil and clean it. Then check the reading has returned to its previous dry air value of about 6. Final Table of Soil Moisture Readings from the Sensor The table below lists the calibration values we got from the sensor. Yours will differ, this can be caused by things like the type of soil etc. Final Calibration Values: The final calibration values we got for our sensor are: These values will be used to set the initial values of the /min_value and /max_value variables in the basic soil moisture program below. https://www.jackbord.org/jobs/basic-capacitive-soil-moisture-sensor Project: Portable Soil Moisture Meter Once you have completed the above and got the sensor working properly, you can use the Basic Soil Moisture Meter Program to turn your JackBord into a stand alone soil moisture meter that will display the soil moisture reading as the color of the USER LED on the front of the JackBord. Run the Program Automatically on Start Up: If you want to have the soil moisture program run on boot use the setboot command to have the JackBord run the soil moisture meter program after its turned on. For example if your program is in program no 8 on the PROG page you would type: setboot 8 From now on the program will run when the JackBord is turned on. To stop running it automatically type: setboot 0 By default the program will take 100 measurements and then exit, to disable this and have it run continually coment out the line below in the code: any /count >= 100 -> exitprog Previous Next
- Smart RGB LED Random Flashing
< Back Smart RGB LED Random Flashing Smart RGB LED Random Flashing Program This program has 6 WS2812B smart LEDs connected to port A pin a1. It will cycle the LEDs through random colors. Program --- Smart LED Random Flashing Program This program has 6 WS2812B smart LED's connected to port A pin a1. It will cycle the LEDs through random colors. --- prog_vars = d/led_no 0 d/red 0 d/green 0 d/blue 0 prog_vars. prog_start = print "Smart LED Program Started" -- turn all 6 leds off sled a1 6 0 /red /green /blue prog_start. prog_loop = -- Set each color to a random value rand 0 255 -> /red rand 0 255 -> /green rand 0 255 -> /blue -- Set the LEDs color -- /led_no is the LED we are setting. sled a1 6 /led_no /red /green /blue -- Inc to the next LED and then start again. any /led_no >= 6 -> /led_no 0 else inc /led_no enda. prog_loop. prog_stop = print "prog stopped" prog_stop.
- RC Servo Commands
< Back RC Servo Commands svp - Set servo position Purpose This sets the shaft position of an rc servo connected to the JackBord Syntax svp #~ pos Arguments #~ The pin to which the servo is connected to on ports A, C, D & E. pos svs - Sweep Servo from 0 to pos Purpose Sweep the servo from 0 to the specified position and back. An optional delay between 1deg steps may also be added. Syntax svs #~ pos delay Arguments #~ The pin to which the servo is connected to on ports A, C, D & E. pos The position to sweep to. 0 -180deg. delay (optional) This is an optional delay, in milli- seconds, between each 1deg step of the servo’s shaft. 5 to 50,000 milli-seconds. Examples svs a1 0 svs a1 90 svs a1 180 50 svt - Sweep Servo from position 1 to position 2 Purpose Allow a servo to sweep from one angle to another and back. eg from 90 to 100 and back. Syntax svt #~ pos1 pos2 delay Arguments #~ The pin to which the servo is connected to on ports A, C, D & E. pos1 The start position to sweep the servo to. 0 top 180deg. pos2 The stop position to sweep the servo to. 0 top 180deg. delay (optional) This is an optional delay, in milli- seconds, between each 1deg step of the servo’s shaft. 5 to 50,000 milli-seconds. Examples svt a1 45 90 svt a1 90 120 50 svt a1 /pos1 /pos2/ /delay
- Sensors - RGB Colour
< Back RGB Colour Detects the RGB (red, green and blue) colours of an object. The RGB Colour Sensor detects the RGB (red, green and blue) colors of an object. Quick Commands Setup the i2c system by typing: i2con Once the command has run the color sensor should be detected. Now you can view the colors from the sensor on the command line by typing this command: jp "red /cs_red green /cs_green blue /cs_blue clear /cs_clear" Videos RGB Color Sensor Part 1: Introduction RGB Color Sensor Part 2: Using the sensor NOTES AND CAUTIONS The sensor has a short range of about 2cm, ideally the object to be measured should be up against the sensor if the sensors LED light is on. The sensor has a built in LED that is controlled from pin 5 on the USI. Setting the pin high turns the LED on and setting it to 0 turns it off. Connection Example Parts of the Sensor The main parts of the sensor are shown in this photograph. First of all we have the sensor on the far left, this is where the RGB elements are that detect the colors. The sensor has a number of pins the main ones being the red power supply pin which needs to be 5 volts, the green ground pin, the blue serial clock pin, the white serial data pin and the LED control pin. Looking at the lower image you can see the RGB sensor in the center and slightly below that you can see the LED light the purpose of which is to eliminate the subject whose color you're trying to detect. The LED input can be used to turn the LED light on and off from the JackBord. How it Works As you may already know the white light that we see every day is actually composed of several different colors which is where the rainbow comes from. For electronics and robotics we rely on the fact that most colors we can see can be created from just three base colors red green and blue. If we mix these colors as shown in the picture below we derive other colors such as yellow. You can also see at the center, when we combine all three colors we end up with white. The Sensor At the center of the sensor is a small IC or integrated circuit that has a number of light sensors on it. These are sensitive to ambient light or normal light, red, green and blue light. You can see the color sensor IC in the picture below, above the white LED. You can use these values to determine the color of the object the sensor is looking at. For example if we are getting equal values of red and green and the blue value is much lower this means the object is most likely yellow. This is because yellow light it maid up of red and green. Communications The sensor uses a special protocol called I2c to communicate with the JackBord on port D. Input and Output Pins: The pins of the sensor are listed below: Connecting the Sensor to the JackBord To make it easier to connect the sensor to the JackBord we locate it at port D using an M4 bolt and nut. This is because the sensor needs to use the JackBord's i2c port and this is located at port D. This is shown in the picture below. Connecting the Jumper Wires The diagram below shows how the sensor should be connected to port D of the JackBord. Note that the INT line is not needed. Steps: First take a green jumper wire and connect it to the ground pin on the JackBord and then to the green ground pin on the sensor Next we take a red jumper wire and connect it from the 5 volt power supply pin on port D of the JackBord and connect it to red 5 volt power supply pin on the sensor. Take a blue jumper wire and connect it from the blue pin on the sensor to port pin d4 of the JackBord Take a white jumper wire and connect it from the white pin on the sensor to port pin d5 of the JackBord Finally use a black jumper wire to connect the black LED pin on the sensor to port pin d1 on the JackBord. We will use Port D pin 1 on the JackBord to control the sensor's built in LED light. The jumper wire colors you use don't have to exactly match those shown above, the main thing is each jumper needs to connect to the correct pin on the sensor and the JackBord. Using the Sensor The sensor has a number of detectors that measure the amount of light in clear, red, green and blue. The clear value is the overall amount of light which is a combination of all the colors together. While the 3 other values are for their respective colors only. Accessing the Color Values In Octagon there are a number of system variables used with this sensor: You can display the values from the sensor using the print statement below in an Octagon program: print "Clear /cs_clear Red /cs_red Green /cs_green Blue /cs_blue" Controlling the Sensors LED Light When the sensors LED light pin is at 0V or connected to ground the light will be turned off. When its high i.e. connected to 3V the LED will be turned on. If the LED line is connected to pin d1 on the JackBord you can turn it on by turning pin d1 on by typing this command: d1 1 and you can turn it off with this command: d1 0 Previous Next
- USER LED Colour Control
< Back USER LED Colour Control This program controls the color of the USER LED using a variable resistor. Turning the knob will change the color of the USER LED. In this version the variable resistor POT1 on the JackBord TOP is connected to port pin B1 on a block 2 JackBord. For a block 3 JackBord use port Pin A1. Program --- Control the Color of the USER LED using a variable resistor. Turning the knob will change the color of the USER LED. --- prog_vars = d/count 0 prog_vars. prog_start = pclear print "Program Start" gvr b1 0 15 l1 prog_start. prog_loop = -- main program loop print "Count /count" inc /count any /count >= 1000 -> exitprog prog_loop. prog_stop = print "Bye" prog_stop.
- sled Example 8 LED Program
< Back sled Example 8 LED Program This program works with a strip of 8 smart RGB leds connected to the SLED pin on port E (pin E1 in some models.) It randomly chnages the color of each LED. Program --- sled Example Light Program This program works with a strip of 8 smart RGB leds connected to the SLED pin on port E (pin E1 in some models.) It randomly chnages the color of each LED. --- prog_vars = d/count 0 d/led_no 1 d/color 0 d/no_of_leds 8 prog_vars. prog_start = print "Program Start" -- Set the number of LEDS sledn /no_of_leds prog_start. prog_loop = -- main program loop print "Count /count" inc /count any /count >= 1000 -> exitprog -- Set a random color rand 0 15 -> /color -- Set the led sled /led_no /color inc /led_no -- Return to first led. any /led_no > 8 -> /led_no 1 prog_loop. prog_stop = print "Bye" prog_stop.
- Random Light Flasher Using the an Command
< 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.
- Delay Commands
< Back Delay Commands dly Delay for a Set Period of Milliseconds dly Delay for a set period of milliseconds Purpose Delays the execution of a program by the specified number of milliseconds Syntax dly ms Pushers No Returns Nothing Examples dly 100 Wait 100ms dly 1000 Wait 1 second Notes This command does not delay the command line or other functions when run in a program.
- MK1-S1 Ultrasonic Ruler
< Back MK1-S1 Ultrasonic Ruler This is the code for the MK1-S1 Ultrasonic Ruler project. It displays the distance to an object in cm on the Show page. Program --- MK1-S1 Ultrasonic Ruler Program For Me-Kit project MK1-S1 Ultrasonic Ruler Displays the distance to an object in cm on the Show page. --- prog_vars = d/count 0 prog_vars. prog_start = pclear -- Show title ptl 10 0 ^ts=35^ "MK1-S1 Ultrasonic Ruler" ptl 40 180 "999 = out of range." -- Quit button pb 10 70 ^n=Quit^p=exitprog^ -- Setup the ultrasonic radar on port C. uradar c1 c2 prog_start. prog_loop = -- main program loop -- Display the distance reading in cm ptl 40 120 ^ts=40^tc=blue^ "Distance /35 cm" -- Wait 100ms d100 prog_loop. prog_stop = ptl 10 0 ^ts=35^ "Bye" prog_stop.
- Input/Output Commands
< Back Input/Output Commands #off Turn All of a Port's Pins Off #off Turn all of port #’s pins off. Purpose This will turn all of the pins on the specified port off. Syntax #off Arguments # The port letter a, c, d, e Examples aoff Turn all port A pins off coff Turn all port C pin off Notes See the #on command to turn port pins on #on Turn All of a Port's Pins On #on Turn all of port #’s pins on. Purpose This will turn all of the pins on the specified port on. Syntax #on Arguments # The port letter a, c, d, e Examples aon Turn all port A pins on con Turn all port C pin on Notes See the #off command to turn port pins off. #~ Turn Pin On or Off #~ Turn pin on or off Purpose Allows you to turn a given port A, C, D, E pin on or off. Syntax # ~ state Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 state The desired state of the pin. 0=OFF 1=ON Pushers No Returns Nothing Examples a1 1 Turn port A pin 1 on a1 0 Turn port A pin 1 off Notes This can be used from the command line and in programs. Channels & Vars Updates the corresponding channel. get #~ Turns the Pin Into an Input and Gets a Reading From It get #~ Turns the pin into an input and gets a reading from it Purpose Set the pin as an input and get a fresh reading from it in real time. Syntax get #~ Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 Notes Takes a direct reading from the hardware pin. glr Get a Fresh Set of Readings and Display Them glr Get a fresh set of readings and display them Purpose This will get fresh readings from any sensors etc and display them. Syntax glr gqr Get Quick Readings in One Line Form gqr Get quick readings in one line form Purpose Gets a set of readings and puts them on one line Syntax gqr Examples > gqr < a1000a2000a3000a4000a5000 b1 000 b2 000 b3 000 b4 000 b5 000 c1 000 c2 000 c3 000 c4 000 c5 000 d1 000 d2 000 d3 000 d4 000 d5 000 e1 000e2000e3000e4000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 grd Get Raw Readings from the Channels in One Line Form grd Get raw readings from the channels in one line form Purpose Gets a fresh set of raw readings and displays them on one line Syntax grd Examples > grd < 1 0 0.00|2 0 0.00|3 0 0.00|4 0 0.00|5 0 0.00|6 0 0.00|7 0 0.00|8 0 0.00|9 0 0.00| 10 0 0.00|11 0 0.00|12 0 0.00|13 0 0.00| 14 0 0.00|15 0 0.00|16 0 0.00|17 0 0.00| 18 0 0.00|19 0 0.00|20 0 0.00|21 0 0.00| 22 0 0.00|23 0 0.00|24 0 0.00|25 0 0.00| 26 0 0.00|27 0 0.00|28 0 0.00|29 0 0.00| 30 0 0.00|31 0 0.00|32 0 0.00|33 0 0.00| 34 0 0.00|35 0 0.00|36 0 0.00|37 0 0.00| 38 0 0.00|39 0 0.00|40 0 0.00| Notes The format of the output is: |chan raw raw_float| grrd Get Real Raw Readings from the Channels in One Line Form grrd Get real raw readings from the channels in one line form Purpose Gets a fresh set of raw readings and displays them on one line Syntax grrd Examples > grrd < a10a20a30a40a50b10b20b3 0 b4 0 b5 0 c1 0 c2 0 c3 0 c4 0 c5 0 d1 0 d2 0 d3 1 d4 0 d5 0 e1 0 e2 0 e3 0 e4 0 Notes The format of the output is: pin value gt Get the Values of the Specified Port gt Get the values of the specified port. Purpose Returns a table of the current values of the port #. If the # port is left out it return the values of all ports. Syntax gt# or gt Arguments # The port letter a, b, c, d, e Examples gt a Get the port A values gt 6 Get the value of channel 6 Notes The type column shows the current type of the pin. pulse Pulse Output pulse Pulse Output Purpose Pulses the selected output on for the specified length of time Syntax pulse #~ time Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 time (milli secs) The amount of time for which the pin will remain high. Pushers No Examples pulse a1 100 Pulse a1 on for 100ms puon Set the Pin as an Input with the Pull-Up Resistor Enabled puon Set the pin as an input with the pull-up resistor enabled Purpose Makes the pin an input with an internal pull-up resistor enabled Syntax puon #~ Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 Examples puon c5 puon a4 spex Set Port Expander spex Set Port Expander Purpose This will setup the specified MCP23017 i/o expander on a virtual port with a port letter from h to l Syntax spex addr port Arguments addr The i2c address on which the expander is located port The letter of the virtual port to which the i/o expander is to be associated with: h, i, j, k or l Pushers No Examples spec 12 h Link the i/o expander on i2c address 12 to virtual port h Notes Once linked the i/o expander port pins may be used in the same manner as normal pins. ie using the #~ notation. The difference is that each i/o expander port has 8 pins instead of 5. spm Set a Pin's Mode of Operation spm Set a pins mode of operation Purpose Set the mode of operation of a pin Syntax spm #~ mode Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 mode The mode of operation for the pin Mode Description 0 Logic input no pull-up resistor 1 Logic input with pull-up resistor on 2 Logic output 3 Analog input port b only Notes spm a1 1 Set pin a1 as a logic input with a pull- up resistor spm a4 2 Set pin a4 as a logic output tg #~ Toggle the Value of the Selected Pin tg #~ Toggle the value of the selected pin Purpose Toggles the value of the selected pin. If it’s on it will go off and vice versa Syntax tg #~ Arguments # The port letter a, b, c, d ~ The port pin number 1 to 5 Pushers Yes Returns Nothing Examples tg a1 Toggle value of a1 tg d1 Toggle the value of the USER LED tg d1 -> /user_led_state




