Menu

Multiple things at once

Help
2007-08-15
2013-05-30
  • Nobody/Anonymous

    I want to have two separate audio channel playing at the same time (stereo headphones). Not for music, but for a binaural brain machine.

    The device will pulse an audio signal into each speaker, as well as pulse two LEDs at the same frequency. The inspiration for this device came from a MAKE zine article, where the author used two timers on an AVR chip to pulse the speakers and a do while loop to pulse the LEDs.

    Any ideas on how I can run two separate audio channels as well as 2 LEDs at once? (synced up)

     
    • Hugh Considine

      Hugh Considine - 2007-08-16

      I haven't seen the article you mention, but this code here (or something similar) should do the trick:

      #define Time1 100
      #define Pin1 PORTB.0
      Dim TimeLoop1 As Word

      'Add any more ports/timers here

      TimeLoop1 = 0
      Do
      'Wait some amount of time, then increment timers
      Wait 1 ms
      TimeLoop1 += 1

      'Toggle Pin1 if Time1 has elapsed since it was last toggled
      if TimeLoop1 > Time1 Then
        if Pin1 = On Then
         Pin1 = Off
        Else
         Pin1 = On
        End If
        TimeLoop1 = 0
      end if

      'Any more time checking goes here

      Loop

      For extra ports, add an extra counter variable (ie. TimeLoop2) and duplicate the other code sections with new variable/constant names.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.