{"id":2274,"date":"2020-02-10T10:24:27","date_gmt":"2020-02-10T10:24:27","guid":{"rendered":"https:\/\/4tronix.co.uk\/blog\/?p=2274"},"modified":"2020-02-10T10:24:27","modified_gmt":"2020-02-10T10:24:27","slug":"starting-with-scratchgpio-on-pi2go-mk2","status":"publish","type":"post","link":"https:\/\/4tronix.co.uk\/blog\/?p=2274","title":{"rendered":"Starting with ScratchGPIO on Pi2Go Mk2"},"content":{"rendered":"<h1>Pi2Go Mark 2 with ScratchGPIO<\/h1>\n<p>Simon Walters (Cymplecy) has worked on ScratchGPIO for many years and continues to add new products to the supported list. Pi2Go Mk2 is now also supported &#8211; here&#8217;s a brief introduction on how to get started.<\/p>\n<h2>Step 1: Install ScratchGPIO<\/h2>\n<p>Visit the <a href=\"http:\/\/simplesi.net\/scratchgpio\/scratch-raspberrypi-gpio\/\" target=\"_blank\" rel=\"noopener\">ScratchGPIO install page<\/a> here.<\/p>\n<p>From a command line, first run the wget to download the installer<\/p>\n<p style=\"padding-left: 30px;\">wget https:\/\/git.io\/vMS6T -O isgh8.sh<\/p>\n<p>Then run the installer:<\/p>\n<p style=\"padding-left: 30px;\">sudo bash isgh8.sh<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step1_wget.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2275 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step1_wget.jpg\" alt=\"\" width=\"681\" height=\"436\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step1_wget.jpg 681w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step1_wget-300x192.jpg 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step2_bashStart.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2276 size-full alignnone\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step2_bashStart.jpg\" alt=\"\" width=\"726\" height=\"191\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step2_bashStart.jpg 726w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step2_bashStart-300x79.jpg 300w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><\/a><\/p>\n<h2>Step 2: Run ScratchGPIO8Plus<\/h2>\n<p>Make sure you choose the correct program to run here. Do NOT run ScratchGPIO8, nor Scratch2GPIO&#8230;<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step3_ScratchGPIO8Plus.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2277 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step3_ScratchGPIO8Plus.jpg\" alt=\"\" width=\"370\" height=\"771\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step3_ScratchGPIO8Plus.jpg 370w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step3_ScratchGPIO8Plus-144x300.jpg 144w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/a><\/p>\n<h2>Step 3: Create an Addon Variable<\/h2>\n<p>You need to create a variable and set it to &#8220;Pi2Go2&#8221; (without the quotes)<\/p>\n<p>Select the Variables tab (top left) and press &#8220;Make a variable&#8221;<\/p>\n<p>Name the variable &#8220;AddOn&#8221;<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step4_CreateVariable.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2278 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step4_CreateVariable.jpg\" alt=\"\" width=\"675\" height=\"533\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step4_CreateVariable.jpg 675w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step4_CreateVariable-300x237.jpg 300w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<p>Move the block &#8220;set AddOn&#8230;&#8221; to the programming area and enter Pi2Go2 as the variable name.<\/p>\n<p>While you&#8217;re at it, grab a green flag block from the Control tab and lock the 2 blocks together<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step5_SetVariabletoPi2Go2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2279 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step5_SetVariabletoPi2Go2.jpg\" alt=\"\" width=\"670\" height=\"323\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step5_SetVariabletoPi2Go2.jpg 670w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step5_SetVariabletoPi2Go2-300x145.jpg 300w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/a><\/p>\n<p>Click on the green flag and the AddOn variable in the stage will show up as Pi2Go2 as in the image above.<\/p>\n<h2>Step 4: Check the Sensors are available<\/h2>\n<p>Now, when you look into the Sensing tab, next to the bottom is a block showing &#8220;slider sensor value&#8221;. If you click on the slider you can see all the other sensors available, including those for the Pi2Go Mk2: battery, frontleftlight, frontrightright, etc. You can now use all these sensors in your program.<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step6_SensorsAvailable.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2280 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step6_SensorsAvailable.jpg\" alt=\"\" width=\"433\" height=\"681\" srcset=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step6_SensorsAvailable.jpg 433w, https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step6_SensorsAvailable-191x300.jpg 191w\" sizes=\"auto, (max-width: 433px) 100vw, 433px\" \/><\/a><\/p>\n<h2>Step 5: Drive the Motors<\/h2>\n<p>Now you can create two more variables for the motors. MotorL and MotorR for the Left and Right motors respectively.<\/p>\n<p>Setting these to values between 0 and 100 will drive the motors. Note that speeds below 30 or so may not be able to power the motors &#8211; it depends what batteries and what voltage is available.<\/p>\n<p>The program below drives the left motor for 1 second at speed 60, then stops<\/p>\n<p><a href=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step7_MotorAfor1Sec.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2281 size-full\" src=\"https:\/\/4tronix.co.uk\/blog\/wp-content\/uploads\/2020\/02\/Step7_MotorAfor1Sec.jpg\" alt=\"\" width=\"161\" height=\"165\" \/><\/a><\/p>\n<h2>Step 6: Further Programming<\/h2>\n<p>Now visit the <a href=\"http:\/\/simplesi.net\/pi2go-mk2\/\">ScratchGPIO page<\/a> dedicated to Pi2Go Mk2 for further tips and information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pi2Go Mark 2 with ScratchGPIO Simon Walters (Cymplecy) has worked on ScratchGPIO for many years and continues to add new products to the supported list. Pi2Go Mk2 is now also supported &#8211; here&#8217;s a brief introduction on how to get started. Step 1: Install ScratchGPIO Visit the ScratchGPIO install page here. From a command line, &hellip; <a href=\"https:\/\/4tronix.co.uk\/blog\/?p=2274\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Starting with ScratchGPIO on Pi2Go Mk2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2274","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2274"}],"version-history":[{"count":1,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2274\/revisions"}],"predecessor-version":[{"id":2282,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2274\/revisions\/2282"}],"wp:attachment":[{"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/4tronix.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}