How would I go about setting macros in VEX Blockly? (At least I’m pretty sure that’s what it’s called, its the one with snap together code)
I am looking to press 1 button to spin my motor driven wings out and 1 button to bring them back in.
Make a Boolean in the orange section. Make when button 1 pressed set Boolean to true and when button two pressed Boolean false. Make it so that when Boolean is true wings go out and motor spins and when false wings go in and motor stops
Use an “if else”, with else being the close
If (boolean) then:
(Wing open)
Else:
(Wing close)
Would I be able to do this with variables? We also want to be able to spin the wings to be facing in front of the robot (which means spinning it forward 180 degrees) while also having a button for it to go forward 90 degrees. Or is there a way with Boolean?
@Nathan_technado used a boolen
For your 3 setting (0, 90, and 180 degrees), you can have something like this pseudocode:
if (controller button pressed) then [
__if (variable <180) [
____variable ++ 90 = variable
____motor spinToPosistion (variable, degrees)
__]
//when variable is 180
__else [
___variable = 0
___motor spinToPosition (variable, degrees)
__]
]
https://en.m.wikipedia.org/wiki/Macro_(computer_science)
A macros is basically a function that you call that does a process. In VexCode, it would basically be a custom block (under “My Blocks”) that you create yourself. In text-based programming, a function (python) or method would be similar to a macros.
I believe that what you were looking for instead was a control block/loop (if something, do this else do that, repeat c times until, etc).
Most of the time though, macros usually refers to a function in a spreadsheet or on your computer, for example you could create or bind a macros to Ctrl+Shift+Y to copy text and search it in a new window (hypothetical example—yes I know that’s Ctrl+Shift+E. Another place macros is used are in spreadsheets. A macros in that context is a function or set of command that you can execute. Some spreadsheet applications will let you record a macros and run it later, translating your actions into code (VBA for excel and app script for google sheets). Macros are generally seen as powerful tools (they are) that can be annoying to use (I occasionally agree, I’ve frozen my Chromebook before while implementing one incorrectly).
Yeah, I know what a macro is. With what I am trying to do a macro is the best way to define it
How would I get the “variable ++ 90” as a block?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.