Sauce
1
What is wrong with this it is saying that controller_1 is not a thing yet I have it in port selection.
def controller_1.buttonL1.pressed()
CONVEYER.spin(FORWARD)
def controller_1.buttonL1.released()
CONVEYER.stop
def controller_1.buttonL2.pressed()
CONVEYER.spin(REVERSE)
def controller_1.buttonL2.released()
CONVEYER.stop
1 Like
Sauce
2
Ok that changed but now it is saying buttonL1 is an error
StuartV
3
It might be missing the point, but you need a colon at the end of each def
line. (And indented CONVEYER
lines). Unless that works?
What sort of error is it giving?
1 Like
StuartV
5
Yeah… I believe you need a colon at the end of each function line.
def controller_1.buttonL1.pressed():
CONVEYER.spin(FORWARD)
Sauce
6
The only error is on the buttonL1 code
What is weirder is that in the next line buttonL1 is not an error
ok, too much misinformation.
pressed needs a callback function just like C++
def pressed_callback():
brain.screen.print_at("pressed", x=10, y=40 )
def release_callback():
brain.screen.print_at("release", x=10, y=40 )
controller_1.buttonL1.pressed(pressed_callback)
controller_1.buttonL1.released(release_callback)
5 Likes
StuartV
8
Not too sure. Can you send a screenshot of more of the window in case it’s something else. (By the way, :
at the end of the line, you have a .
).
Sauce
9
I put colons in and it did not help
Do what jpearman told you to do.
4 Likes
StuartV
12
It didn’t help the current problem, (which @jpearman has a solution for), but it will solve later problems.
Sauce
13

Still says buttonL1 is an invalid syntax
You didn’t copy the code.
you cannot do this (assuming controller_1 is defined as a controller)
def controller_1.buttonL1.pressed():
do this.
def pressed_callback():
CONVEYER.spin(FORWARD)
def release_callback():
CONVEYER.stop()
controller_1.buttonL1.pressed(pressed_callback)
controller_1.buttonL1.released(release_callback)
3 Likes
Sauce
15
It is defined as controller one. The only error is that it says buttonL1 is not a thing
yes, because you keep putting “def” in front of it which is invalid Python
1 Like
Sauce
17
I took it out and the error is off of L1 but it is on CONVEYOR
Sauce
18
That happened after I deleted the colons which the error was on after L1 but before conveyer
based on your screenshot, you need something like this.
def conveyer_forward():
CONVEYER.spin(FORWARD)
def conveyer_reverse():
CONVEYER.spin(REVERSE)
def conveyer_stop():
CONVEYER.stop()
controller_1.buttonL1.pressed(conveyer_forward)
controller_1.buttonL1.released(conveyer_stop)
controller_1.buttonL2.pressed(conveyer_reverse)
controller_1.buttonL2.released(conveyer_stop)
3 Likes
Sauce
20
Thank you so much. This works perfectly