GLOBAL SITE AUSTRALIAN SITE

Loop question | EdWare graphical programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
Loop question
December 8, 2017
4:58 am
Texas
Member
Members
Forum Posts: 26
Member Since:
November 10, 2017
sp_UserOfflineSmall Offline

I want the edison to find Easter eggs (electrical tape).  Each time it finds an egg, it stops and waits for me to pick up the egg and press the circle button.  After Eddy has found four eggs it’s finished and should play a happy song.

I got the program to work, but I am confused about the happy song after finding four eggs.  If I put the play music after the main loop, it won’t play.  If I put the play music inside an if-memory loop inside the if-line loop, it won’t work.  But if I have the play music in both of these locations at the same time, it works.  What is going on?

Also, can you tell me what colors the edison will detect?  I’d like prettier eggs than black.  😉

http://www.edwareapp.com/share/UyOvj

Thanks

December 11, 2017
3:58 pm
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOnlineSmall Online

Hi

The line tracker uses red light reflected off the surface to detect lines.

As such white, red and some orange surfaces are “reflective” all other colours should be “non-reflective” however any surface that is glossy or shiny will be “reflective” regardless of colour

In regards to the loop and music, The loop only checks the condition at the start of the loop, so the program needs to make it to the start of the loop before it breaks out and plays the music at the end.

So in your original program without the IF statement at the end, you would have needed to press the round button after finding the 4th egg before the music starts to play

December 12, 2017
3:41 am
Texas
Member
Members
Forum Posts: 26
Member Since:
November 10, 2017
sp_UserOfflineSmall Offline

I’m still confused about the loops.  Keep in mind that I’m not a programmer – just a mom who volunteered to teach a homeschool co-op class.  I really appreciate all your help.  The advice offered in this forum weighed heavily in my decision to go with Edison.  And the price, of course.  😉

After Edison finds the first three “eggs” the counter value is 3. Then:

1.  It enters the main loop again, because counter is not > 3

2.  It finds the fourth egg, and adds one to the counter value.  Counter now = 4.

3.  Since counter = 4, it takes the top path of the IF counter = 4 loop and plays music.

4.  It goes back to the main loop, but counter is now > 3, so it kicks out of the loop and goes to the end of the program.

5.  Plays music and ends.

Why doesn’t the music play twice? 

Please help my Ben, you are my only hope.

December 12, 2017
10:54 am
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOnlineSmall Online

You are doing really well!

The step by step is exactly what programmers do at every level to try and find bugs in code and it’s definitely something I would recommend teaching to the children. When I have taught programming in the past and a student has encountered a bug I sit down with them and step them through the code, asking them to read what each block is actually doing rather then what they think it should be doing, 90% of the time this technique finds a block with the wrong settings or a block in the wrong spot.

In regards to your program, your step by step is correct, I cant see any difference between your logic and your code, So it is possibly to do with robot speed, the time between Edison finish the music at step 3 and starting the music at step 5 is something like 100th of a second, which is not long enough for the human ear to detect, so it would sound like 1 longer set of notes as opposed to two shorter sets

To test this we can add a few extra blocks to the code to double check. I would add a “Flash LED” block to turn the left LED on after the “wait event” in the IF statement from step 3 then add a “Flash LED” block to turn the left LED off and a “wait event” set to one second to the end of the program.

If Edison is playing both sets of notes (which it should be from your step by step), Edison should play a few notes then turn the light on and play a few more, this will still happen quite quickly and you may not hear a stop when Edison turns on the light, it may appear to just turn on halfway through the song. If it does that’s great! it means the code is working and Edison is playing both sets of notes

December 14, 2017
7:19 am
Texas
Member
Members
Forum Posts: 26
Member Since:
November 10, 2017
sp_UserOfflineSmall Offline

It was a timing issue.  I removed the first music and replaced it with an event wait for 0.3 s and it works perfectly now. 

Thanks for your help.

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This