Me and my team have been trying this beam breaker code, but it just stops spinning after 1 second. We have tried it with and with light shining on the other side, and every time it spins for 1 second then stops. Pls help
I would have it print the brightness to the screen then have the arm run through the motion. Find the average of the high and low numbers for your cutoff.
Also, all of the teams I work with just use the motor rotations to set the level of the catapult. They have one button to manually set the location and then another one that will fire and reset the arm. It’s very consistent.
I would do what @sankeydd said and also If I were you I’d use a repeat until block so it spins the motor until it meets the requirements ie brightness < 50.
Ever heard of debugging?
Let’s follow the robot’s brain for a minute before I explain what debugging is.
- You push
R Down
. - The brain says,
R Down pressed. Executing R Down hat block.
- It sets the
Catapult
tospin forward
. - The catapult spins forward.
- It goes on to the next line.
wait 1 second
. Waiting 1 second...
- One second is up. Next line.
-
keep checking until Color12 brightness < 50
.
And now we’re stuck. Since we don’t know when Color12 brightness
is < 50
, we don’t know when to expect the catapult to stop. Judging by your description, though, “It just stops spinning after 1 second,” it would seem reasonable to assume that Color12 brightness < 50
the first time the brain checks.
Now for the debugging part.
To test our hypothesis, we need to know what the color brightness is at all times, so we write some code.
when started:
forever:
clear screen;
set cursor to row 1 column 1;
/* Column is the character number.
If you print "123" on the brain, your
cursor will be at 4 and "3" will be printed at column 3. */
print Color12 brightness in % on Brain;
Watch the numbers and you’ll be able to see what the brain sees. If that doesn’t help you understand enough that you can solve it, report back here in what range the number usually was while the catapult was in the air and in what range it usually was when the catapult was down.
Also, you will probably want to add a wait after the wait until
, like so:
...
wait until Color12 brightness < 50
wait 0.125 seconds
stop catapult
Then you turn that number up and down until the catapult stops where you want it to.
Thank you, thats rlly all it was
Also thank you, i think i will be using this debugging process, and printing the brightnesss was all we had to do
You could even have your robot do this automatically when you start the bot in case of different ambient lighting conditions.
Don’t you need that in a forever loop?
no… its for driver so it happens everytime r down is pressed
I’ve got something that may help. After the detecting block (aka wait until color12 brightness < 50) try adding a wait block there for maybe .2 or .5 seconds. I think your problem is that it detects the brightness level below 50 immediately once it starts moving, because it can’t wait.
(and also I don’t know if you have two light sensors on your robot, because you need two for it to work. A detector, and one that emits the light.)
They already have a 1 second wait after the catapult starts moving. I think that’s not the issue.
I mean after the detector block. The one before it stops.
I know. I don’t know what you mean by
Try replacing all your pronouns with the actual name of the noun and further explaining your diagnosis. For example:
Also, I’m not sure why that would be the problem; I think that’s the goal: to have the color sensor detect that the catapult is blocking the light from the other color sensor and stop the catapult.
@ROBOTEER, since you seem to have solved your problem, would you please mark something as the solution, so people will stop offering suggestions?
u dont, we currently use one, however two could be better