program lightEventTest {
  sensor opto on 3
  opto is light as raw
  event black when opto.low
  main {
    start eye
  }
  watcher eye monitor black {sound 1}
}


program lightEventTest {
  sensor s on 3
  s is light as raw
  event blip when s.high
  main {
    start beep
  }
  watcher beep monitor blip {sound 1}
}


program lightEventTest {
  sensor s on 3
  s is light as raw
  event blip when s.click
  main {
    blip.time = 15  //150mS
    start beep
  }
  watcher beep monitor blip {sound 1}
}


program lightEventTest {
  sensor s on 3
  s is light as raw
  event blip when s.click
  main {
    blip.high = 900  //Scout specific values
    blip.low = 700
    blip.hysteresis = 30
    blip.time = 15  //150mS
    start beep
  }
  watcher beep monitor blip {sound 1}
}


program timerTest {
  timer t
  event blip when t = 10  //once per second
  main {
    clear t
    start blipper
  }

  watcher blipper monitor blip {clear t sound 1}
}


program timerTest {
  timer t
  event blip when t > 2
  main {
    blip.high = 10  //overrides timer limit (Scout specific)
    clear t
    start blipper
  }

  watcher blipper monitor blip {clear t sound 1}
}


program timerTest {
  timer t1
  timer t2
  event blip when t1 > 1
  event bleep when t2 = 10
  main {
    clear t1
    clear t2
    start blipper
    start bleeper
  }

  watcher blipper monitor blip {clear t1 sound 1}

  watcher bleeper monitor bleep {clear t2 sound 2}
}


program testMessage {
  event post when message

  main {
    start postbox
  }

  watcher postbox monitor post {sound 3}
}


program soundTest {
//Scout & RCX2 compatible - select appropriate headers
//  #include <RCX2.h>
//  #include <RCX2Sounds.h>
//
  #include <Scout.h>
  #include <ScoutSounds.h>
  sensor s1 on 1
  sensor s2 on 2
  s1 is switch as boolean
  s2 is switch as boolean
  event left when s1.pressed
  event right when s2.pressed
  event post when message
  var nEventSound

  main {
    nEventSound = 7
    start bumpers
    start postbox
  }

  watcher bumpers monitor left, right {
    if left
    {
      nEventSound += 1
      if nEventSound > 28 {nEventSound = 7}
    }
    else  //right
    {
      send nEventSound
      wait 10
    }
    clear sound
    start PlaySound
  }

  watcher postbox monitor post {
    nEventSound = message
    clear message
    clear sound
    start PlaySound
  }

  task PlaySound {
    select nEventSound {
      when 7 {sound_7}
      when 8 {sound_8}
      when 9 {sound_9}
      when 10 {sound_10}
      when 11 {sound_11}
      when 12 {sound_12}
      when 13 {sound_13}
      when 14 {sound_14}
      when 15 {sound_15}
      when 16 {sound_16}
      when 17 {sound_17}
      when 18 {sound_18}
      when 19 {sound_19}
      when 20 {sound_20}
      when 21 {sound_21}
      when 22 {sound_22}
      when 23 {sound_23}
      when 24 {sound_24}
      when 25 {sound_25}
      when 26 {sound_26}
      when 27 {sound_27}
      when 28 {sound_28}
    }
  }
}


program counterTest {
  sensor s on 1
  s is switch as boolean
  event up when s.pressed
  counter score = 0
  event win when score = 3
  main {
    start scorer
    start beeper
  }

  watcher scorer monitor up {sound 1 score += 1}

  watcher beeper monitor win {sound 3 clear score}
}
