Motor Not Spinning (V5 Blocks)

cnuaudjdsfntytyhyh
does anyone know why this script wont move the motor? (It is connected to the correct port, and both blocks are running when driver mode is on. Every other script is working fine.)

I think that it may have something to do with that nestled if statement in the first block chain. Maybe try this?
image

If this doesn’t work, it may be because the code only looks to see if button b is pressed ONCE, then permanently sets Movering to 1. You could fix this by changing the if statement to “Controler1 B pressing”

1 Like

The problem lies in the use of this block:
image
This block sets the internal motor encoder (IME) value to the input value, but does not actually rotate the motor. It has essentially the same function as:
image
although IMEs and v5 rotation sensors behave slightly differently.

Opinion

Putting the “set position to” block for smart motors under the “Smart Motor” heading in the “Sensing” category may make this clearer to newer users. Because the heading for “Smart Motor” under “Sensing” already exists, it could be implemented like the rotation sensor:
image


The block you would want to use would be
image
because it would actually cause the motor to rotate.


Although I do not know what your goal is by using the custom blocks, it may be more intuitive to combine both functions into a single thread (topped with a “when started/driver control/autonomous” block) in a forever loop. Unless “The epic bloq” is called in a loop, your program will not check for the controller buttons because it only checks once (when that function is called). The same goes for the other function, the code will only check and tell the motor to move when you call “The epic bloq 2”.

Both the nested “if” statements and @Ghostly’s suggestion will work, although the latter can cause unintended effects if both B and X are being pressed (“myVariable” will cycle back and forth between 1 and 2 every time the program loops). Vexcode v5 Blocks does have a block called “if/else if” that would replace the nested if statements (it evaluates the first condition; if false, it moves to the second condition; and so on), and would make your code easier to expand in the future.

"if/else if" block

image
use the “help” window by pressing the “?” if you are confused by its use

6 Likes