Shop OBEX P1 Docs P2 Docs Learn Events
Activity bot - how to program to drive and play freqout() at same time? — Parallax Forums

Activity bot - how to program to drive and play freqout() at same time?

dsomashedsomashe Posts: 21
edited 2015-06-09 22:21 in General Discussion
Hello, I just got an activity bot and have gone through the tutorials as best as I can. However, I am unable to figure out how to have the robot drive in a set pattern (and repeat that pattern) with drive_goto (), while simultaneously playing a little song I made using the freqout () function. Since it is reading the code line by line, it will either play the music and THEN drive, or drive and THEN play the music. Is it possible to get it to loop the music and then do the drive function independent of that?

I screwed around with the while() function but again, it will only do one or the other, not both simultaneously.

Sorry, a beginner's question I know. Thank you so much for any help.

Comments

  • twm47099twm47099 Posts: 867
    edited 2015-06-09 08:20
    You can use one core (cog) to handle the driving and a second one to handle the music. They will work independently of each other once started.
    There are tutorials on using multi cores in functions in 2 areas of the Learn section of the parallax web site.
    The first link below shows one method (using older functions). The second link is the way that parallax currently recommends. Essentially, you define a function that plays the music, and in the main program start a new cog that runs that function (call the the drive function in main without you starting a new core after you start the music function.
    Give it a try and let us know how things work. If you have problems, I'm sure forum members can help.

    Tom

    http://learn.parallax.com/propeller-c-functions/multicore-example

    http://learn.parallax.com/multicore-approaches
  • dsomashedsomashe Posts: 21
    edited 2015-06-09 22:21
    Thank you so much! I tried it this evening and it worked. Thanks so much for the help, I really appreciate it!!
Sign In or Register to comment.