VEX Switch Blocks Explained: The Key to Advanced Programming!

Creator Academy Australia · Beginner ·🛠️ AI Tools & Apps ·1y ago

Key Takeaways

Creator Academy Australia explains VEX Switch Blocks for advanced programming using Python

Full Transcript

switch blocks are the most game-changing development in Vex programming full stop as someone who has been teaching robotics since 2017 I've seen the biggest hurdle for students moving from block-based coding to more advanced systems and that is the transition to text based coding but now with switch blocks Vex has created a powerful tool that helps bridge this Gap they allow students to get comfortable with python by seamlessly integrating text based code into their block based projects and this not only makes the jump smoother but also boosts confidence and creativity if you want to learn how to fully harness the power of switch blocks in your team be sure to stick around for the whole [Music] video first up let's start with something basic if you have clawbot built like I have then make sure that you have IQ brain second gen selected and the drivetrain created for Port 1 and six and using the inertial brain gyro sensor after that you have a look at this code when it starts we print out Mr code to the brain then we set the drive velocity to 70% and we drive forwards and backwards let's start by replacing that first block here print mytic code so I go into the switch blocks and then I drag in a switch stack over here I can now reference the brain uh because that is what I need to do in order to access the print method so here I can start typing by pressing B you'll notice that this menu pops up straight away this is called code hinting and code hinting makes it easier for you to type in code faster and also reduce the error errors so you can select a um an item using the up and down arrow keys and then press enter instead of typing the whole thing by hand and it's really important to use code hinting especially with these more modern IDE systems it's because if you mistype something in Python then it can cause an error okay so keep that in mind so brain. screen do print and then I'm going to put in Mr code close the bracket that's it I've replaced one line of code using python what about the set Drive velocity I can do the exact same thing I can add another switch block and then in order to reference the drive velocity I need to go and talk to the drivet train so I go D drivet train and then here drivet train pops up press enter Dot and then set Drive velocity is right down here setor drivecore velocity that's really really clear isn't it so here I can just go down set Drive velocity to uh 70 comma and then percent here again using the code hints as much as possible to reduce the errors for example if I had typed in percent without capitals then it would cause all sorts of issues for me about driving forwards and backwards let's do one more switch block now how did I know to access the brain or the drivetrain or anything like that you will need to spend a little bit of time reading through the python documentation the python documentation is a um uh on the on the side hints inside a textbase project when you select Python inex and uh you can access this Anytime by starting a Vex uh python project and uh understanding all the documentation is really important for you to uh know how to use these blocks uh these switch blocks uh effectively okay so here I go drivetrain do drive4 going to go forward comma 200 comma mm close the bracket and then I can actually add a second line of code here so I can uh add multiple lines of code into a switch stack block so here I'm going to go reverse 200 mm okay if I really wanted to I could put all the code into one switch stack block but that also reduces my flexibility because then I won't be able to separate out the blocks uh for use in different areas of my code now I spent a lot of time making robotics content videos just like these so if you find this video helpful or interesting then please consider liking and subscribing to my channel now let's try something a little bit more advanced let's try making a loop using switch blocks so getting back to our code here we have uh a little bit of a pattern where we're moving forwards 200 mm and then turning right and then we're repeating that four times the result of this is that our robot moves in the shape of a square now I want to change out this repeat four block with a switch block and how do I do that I look for the same block uh of the same shape and it is this one here okay this switch C block you see how they both look like the letter c so this is going to replace my repeat for block and I can put the code that I want to repeat inside and to do a loop in Python we go for I the I is an iterator variable in range four colon we have to end anything that we put into a switch C block with a colon as well now this is going to make it so that I repeat whatever is in here four times I can also change these out and then replace these with switch blocks as well so here put in a switch stack block drivetrain do drive4 forward comma 200 mm and then what about the turn drivetrain Dot and then we can go down to whoops drivetrain dot uh turn four and then we're going to go uh the direction angle and units so turn four go right uh 90° all right and it's easy as that so you might be wondering Mr code how did you know to use the four keyword to write a loop or how did you know how to use a range function in order to repeat something four times and the answer to that is that it is all basic Python and I teach it every single week in our YouTube member live streams for just $4.99 9 a month or $1 1999 Australian doar a month you'll get access to exclusive weekly live stream coding tutorials where we dive deep into advanced programming in scratch and python both of which are great to expand your coding knowledge and these live sessions are perfect for anyone looking to take their skills to the next level whether you're preparing for a competition or just love learning more about programming your membership not only gives you access to valuable content but also contributes significantly to the running of this channel helping me bring you more highquality videos and tutorials I would really appreciate your support and I'd love to see you in our next live stream so if you're interested hit the join button below this video to become a member today so now let's have a look at sensors now I have attached a uh touch led to Port three and then a distance sensor to port five and now I have a basic code here where we are looping in a forever block where we're checking the distance of the object in front of our distance sensor if it is within 50 mm then the touch LED will glow red else if the distance is less than 100 mm it will be orange and otherwise it's going to Glow green so firstly let's replace the forever Loop to replace the forever loop we're going to write a switch C block uh to repeat something forever to repeat something forever with python we say while true that's it while true uh with capital t uh and ending with a column will repeat something forever so if I put this back in it'll be exactly the same functionality but not only that I want to replace this um uh massive if statement as well so if else if else uh I want to replace that so how do I do it I go and uh put in an expandable uh switch block and then I can put in my condition here if distance dot uh object distance uh millim is less than 50 colum remember inside uh switch C blocks you have to end all your lines with um with columns okay so if that is the case then I glow red I can add another one LF that's uh short for else if in Python LF distance doob distance in millimet uh is less than 100 then I switch my color to yellow and then finally else I switch my color to green and there we have it I've now got the majority of my code written in Python my robotics Center Creator Academy is dedicated to teaching kids about coding and Robotics if your team is looking for coaching advice we provide remote coaching building and coding assistance for teams all around the world visit www.c Creator Academy . Au or drop me a message to find out more and that's it from me today remember if you want to join our weekly live streams and learn how to incorporate python into your teams robot code press the join button below and I'll see you next time bye-bye [Music]

Original Description

Switch Blocks are a game-changer for VEX programming, offering an easy way to transition from block-based coding to Python. In this tutorial, I’ll show you how to harness the power of Switch Blocks to elevate your team's programming skills and tackle more advanced challenges. Whether you’re a beginner or looking to introduce your students to text-based coding, Switch Blocks provide the perfect stepping stone. In this video, we’ll cover: What Switch Blocks are and why they’re important How to integrate text-based code into block-based projects Practical examples of using Switch Blocks in VEX Stick around to learn how to maximize Switch Blocks and unlock new programming potential for your VEX robotics team! 👉 Don’t forget to like, subscribe, and hit the notification bell so you never miss an update on our robotics tutorials. For more in-depth science, building and coding on this subject, visit www.creatoracademy.com.au
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Creator Academy Australia · Creator Academy Australia · 0 of 60

← Previous Next →
1 LEGO Wedo 2.0 Kangaroo and Joey Demonstration
LEGO Wedo 2.0 Kangaroo and Joey Demonstration
Creator Academy Australia
2 LEGO Wedo 2.0 Koala Demonstration
LEGO Wedo 2.0 Koala Demonstration
Creator Academy Australia
3 LEGO WeDo 2.0 Eagle vs Rabbit Demonstration
LEGO WeDo 2.0 Eagle vs Rabbit Demonstration
Creator Academy Australia
4 Animatronic Australia: The Kangaroo
Animatronic Australia: The Kangaroo
Creator Academy Australia
5 How Semiconductors Work: 3D Animation
How Semiconductors Work: 3D Animation
Creator Academy Australia
6 LEGO Wedo 2.0 Koala
LEGO Wedo 2.0 Koala
Creator Academy Australia
7 First impressions and unboxing First Lego League: Into Orbit 2018
First impressions and unboxing First Lego League: Into Orbit 2018
Creator Academy Australia
8 FLL Into Orbit Team Ranking Gears talks about Artificial Gravity
FLL Into Orbit Team Ranking Gears talks about Artificial Gravity
Creator Academy Australia
9 FLL Into Orbit team Ev3lution discusses isolation in space
FLL Into Orbit team Ev3lution discusses isolation in space
Creator Academy Australia
10 PI3-BOT (Pie Bot) Prototype
PI3-BOT (Pie Bot) Prototype
Creator Academy Australia
11 Dynamic display stand for LEGO Bugatti Chiron (preview)
Dynamic display stand for LEGO Bugatti Chiron (preview)
Creator Academy Australia
12 Creative Kids TV announcement featuring Creator Academy
Creative Kids TV announcement featuring Creator Academy
Creator Academy Australia
13 LEGO WeDo 2.0 Guided Lesson: Milo
LEGO WeDo 2.0 Guided Lesson: Milo
Creator Academy Australia
14 LEGO SPIKE PRIME: Turtle Prime Demonstration
LEGO SPIKE PRIME: Turtle Prime Demonstration
Creator Academy Australia
15 LEGO SPIKE PRIME "Wheelchair Prime"
LEGO SPIKE PRIME "Wheelchair Prime"
Creator Academy Australia
16 10 Reasons why EV3 is SUPERIOR to SPIKE Prime
10 Reasons why EV3 is SUPERIOR to SPIKE Prime
Creator Academy Australia
17 Your first launch after installing Python: Python for Kids Webinar Highlight
Your first launch after installing Python: Python for Kids Webinar Highlight
Creator Academy Australia
18 What is "Sharpening the Saw": Python for Kids Webinar Highlight
What is "Sharpening the Saw": Python for Kids Webinar Highlight
Creator Academy Australia
19 Why We Use Comments: Python for Kids Webinar Highlight
Why We Use Comments: Python for Kids Webinar Highlight
Creator Academy Australia
20 Build a Scratch Dinosaur Park (Full Lesson)
Build a Scratch Dinosaur Park (Full Lesson)
Creator Academy Australia
21 Scratch 3.0: Cat and Mouse Game Stream (Krunal)
Scratch 3.0: Cat and Mouse Game Stream (Krunal)
Creator Academy Australia
22 Python Tutorial: Make a Toilet Paper Calculator (Full Lesson)
Python Tutorial: Make a Toilet Paper Calculator (Full Lesson)
Creator Academy Australia
23 Scratch 3.0 Tutorial: Making a chatbot that plays 'heads or tails' (Full Lesson)
Scratch 3.0 Tutorial: Making a chatbot that plays 'heads or tails' (Full Lesson)
Creator Academy Australia
24 Getting Started with MicroPython on SPIKE PRIME (old)
Getting Started with MicroPython on SPIKE PRIME (old)
Creator Academy Australia
25 Easter Egg Game Tutorial in Scratch (Full Lesson)
Easter Egg Game Tutorial in Scratch (Full Lesson)
Creator Academy Australia
26 Accessing Weather API with Python (Highlights)
Accessing Weather API with Python (Highlights)
Creator Academy Australia
27 Accessing Translate API with Python (Highlights)
Accessing Translate API with Python (Highlights)
Creator Academy Australia
28 Scissors, Paper, Rock with Scratch 3.0 (Highlights)
Scissors, Paper, Rock with Scratch 3.0 (Highlights)
Creator Academy Australia
29 Making a really scary game with Scratch 3.0 (Highlights)
Making a really scary game with Scratch 3.0 (Highlights)
Creator Academy Australia
30 Making a Lemmings game with Scratch 3.0 (Highlights)
Making a Lemmings game with Scratch 3.0 (Highlights)
Creator Academy Australia
31 Space Navigation Game in Scratch (Highlights)
Space Navigation Game in Scratch (Highlights)
Creator Academy Australia
32 Scratch Supercat Game (Full Lesson)
Scratch Supercat Game (Full Lesson)
Creator Academy Australia
33 Introduction to Robots with LEGO Wedo 2.0 (Full Lesson)
Introduction to Robots with LEGO Wedo 2.0 (Full Lesson)
Creator Academy Australia
34 Getting Started With LEGO Spike Prime (Full Lesson)
Getting Started With LEGO Spike Prime (Full Lesson)
Creator Academy Australia
35 Scratch Walk Cycle Animation Tutorial (Full Lesson)
Scratch Walk Cycle Animation Tutorial (Full Lesson)
Creator Academy Australia
36 Building a Scissor Lift with LEGO Simple Machines (Highlights)
Building a Scissor Lift with LEGO Simple Machines (Highlights)
Creator Academy Australia
37 EV3 datalogging RPM challenge (highlights)
EV3 datalogging RPM challenge (highlights)
Creator Academy Australia
38 Learning about buses with LEGO (Full Lesson)
Learning about buses with LEGO (Full Lesson)
Creator Academy Australia
39 Make "Flappy Bird" in Scratch 3.0 (Highlights)
Make "Flappy Bird" in Scratch 3.0 (Highlights)
Creator Academy Australia
40 "Memory Arrows" game with Scratch 3.0 Lists (Highlights)
"Memory Arrows" game with Scratch 3.0 Lists (Highlights)
Creator Academy Australia
41 Learning about Gear Ratios with LEGO Simple Machines (Highlights)
Learning about Gear Ratios with LEGO Simple Machines (Highlights)
Creator Academy Australia
42 Scratch 3.0 Bouncing Ball with Stretch, Speed and Acceleration (Full Lesson)
Scratch 3.0 Bouncing Ball with Stretch, Speed and Acceleration (Full Lesson)
Creator Academy Australia
43 LEGO SPIKE Prime Order Tracking Robot (Highlights)
LEGO SPIKE Prime Order Tracking Robot (Highlights)
Creator Academy Australia
44 Scratch 3.0 Race Guesser (Full Lesson)
Scratch 3.0 Race Guesser (Full Lesson)
Creator Academy Australia
45 How Banks Work - a quick explanation for kids
How Banks Work - a quick explanation for kids
Creator Academy Australia
46 SPIKE Prime Safe + importance of passwords (Highlights)
SPIKE Prime Safe + importance of passwords (Highlights)
Creator Academy Australia
47 Combination Safe Coding Guide with LEGO SPIKE Prime
Combination Safe Coding Guide with LEGO SPIKE Prime
Creator Academy Australia
48 LEGO SPIKE Prime Parcel Scanning Robot
LEGO SPIKE Prime Parcel Scanning Robot
Creator Academy Australia
49 Building "Addy" the Addition Chatbot
Building "Addy" the Addition Chatbot
Creator Academy Australia
50 SPIKE 2.x PID Balancer with Scratch for SPIKE Prime / 51515: Gyro Girl
SPIKE 2.x PID Balancer with Scratch for SPIKE Prime / 51515: Gyro Girl
Creator Academy Australia
51 What is Procedural Programming
What is Procedural Programming
Creator Academy Australia
52 Zombie game in SCRATCH (plus horrifying zombie facts!)
Zombie game in SCRATCH (plus horrifying zombie facts!)
Creator Academy Australia
53 Swarming Bugs Scratch Game
Swarming Bugs Scratch Game
Creator Academy Australia
54 LEGO Mindstorms/SPIKE Prime Scanner and Printer
LEGO Mindstorms/SPIKE Prime Scanner and Printer
Creator Academy Australia
55 Fishing Game with SCRATCH (For Fathers Day!)
Fishing Game with SCRATCH (For Fathers Day!)
Creator Academy Australia
56 Measuring Paper Plane Speed with SPIKE Prime Line Graphs
Measuring Paper Plane Speed with SPIKE Prime Line Graphs
Creator Academy Australia
57 Comparing Mindstorms Robot Inventor and SPIKE Prime
Comparing Mindstorms Robot Inventor and SPIKE Prime
Creator Academy Australia
58 Code a 'Knock Knock Joke' game in Scratch 3.0
Code a 'Knock Knock Joke' game in Scratch 3.0
Creator Academy Australia
59 Creator Academy Australia Live Stream
Creator Academy Australia Live Stream
Creator Academy Australia
60 Discovering LEGO Mindstorms/SPIKE Gyro Pitch Deadzone
Discovering LEGO Mindstorms/SPIKE Gyro Pitch Deadzone
Creator Academy Australia

Related Reads

Up next
Ultimate Offline Family Photo Vault (AI Searchable) | DH2300 Full Setup Guide Step-by-Step Tutorial
Matt Tutorials
Watch →