Quantcast
Channel: Learn with BlocklyProp — Parallax Forums
Viewing all articles
Browse latest Browse all 293

Please help with optimizing function and identifying strange issue

$
0
0
Hi guys,
First post :) I'm currently enrolled in a Intro. Robotics class as part of my degree program and this was last week's homework assignment. I've already submitted it to make sure I'd be in the clear, and it does everything that my teacher wanted it to do, but I'm not happy with how un-optimized that the blink function works. This is an entry level class with no coding experience required, but I do have some C/C++ and robotics experience from CS/Elec. Engi classes I've worked on in the past.
http://pastebin.com/EecQhT3V

So basically, LED 27 is supposed to continuously blink while the servo rotates to it's 90 degree position, and then stop blinking when the servo blinks. The way that it should work in my mind is much different than the way that I was able to get it working. I THINK there should be a way to tell it to blink while that servo is in motion to the 90 degree position, rather than how I did it, which was trial and error with delay values and high/lows till I was able to match it almost perfectly. The problem with the way I did it is a few things, the function is long, for just a blinking light for less than a second. Then, if the servo was ramped down or up, the blinking wouldn't match up. It's just bugging me that I'm sure it could've been written better. The assignment has already been submitted and I'm sure since it does what it was supposed to do, I'll get full credit...but I'm not one for "good enough".

edit:Forgot the strange issue, on that servo to 0 degrees on line 8, I was trying to get a 1 second pause right after it hit 0 degrees, well even when I add a pause(1000); on line 9, it would immediately proceed to the next servo movement with no pause. The workaround that I was able to get working was adding a second pause(1000); right underneath the first. That does in fact pause for the 1 second that I was going for but only if there's a second pause command. The only thing I could think of was maybe the first pause was being used up during line 8's rotation?

Viewing all articles
Browse latest Browse all 293

Trending Articles