MIDI displayed onNote

Tried to create a basic parameter that goes from 0 to 1 when a note is played. I figured it would be easy but this is my first time writing code that isn’t addressing a parameter from the parameter list so I’m not completely sure how to do it. Can anyone assist with this? The goal is create the parameter so that the user can see it on my macro page.

function onNote(event)
  if noteOn then
      MIDIdisplay = 1
  else
      MIDIdisplay = 0
  end
end

defineParameter("MIDIdisplay", nil, 0,0,1,1, onNote)

Maybe try something like this:

function onNote(event)
  MIDIdisplay = 1
  postEvent(event)
  wait(100)
  MIDIdisplay = 0
end

defineParameter("MIDIdisplay", nil, 0,0,1,1)

Or if you want the animation parameter to be read only:

function onNote(event)
  MIDIdisplay = 1
  postEvent(event)
  wait(100)
  MIDIdisplay = 0
end

defineParameter{
  name = "MIDIdisplay",
  default = 0,
  min = 0,
  max = 1,
  increment = 1,
  readOnly = true
}

Oh nice! I didn’t know “wait” was a function. I looked into the references and found “waitForRelease”, which works even better for my purpose. Might be useful for you as well. Thank you!