Flashing Button Help!!

Josh Wright

2017-02-17 17:52:48

Hi Everyone!!

Im hoping to get some help with getting a button to flash! Yeah I know rudimentary at best, but this is just a project that Im using to get to know the program. Anyway, Im trying to press one button, and have a second button flash its led 4 times. Im getting a flash... but its sporadic at best, and not consistent at all. Below is the code Im using... If someone could tell me where Im going wrong, I would be most appreciative. Thanks so much in advance!

 

[x] Translator 14.0: LIGHT ON INPUT Options: swallow Incoming: Note On on ch. 11 with note:8 (0x08) and velocity:127 (0x7F), on port X-Touch Alias Outgoing: Timer 4 times "LIGHT ON TIMER": 500 ms (initial delay: 0 ms)

[x] Translator 14.1: LIGHT ON OUTPUT Incoming: On timer "LIGHT ON TIMER" Outgoing: Note On on ch. 11 with note:16 (0x10) and velocity:127 (0x7F), to port X-TOUCH MINI 1

[x] Translator 14.2: LIGHT OFF INPUT Incoming: On timer "LIGHT ON TIMER" Outgoing: Timer 4 times "LIGHT OFF TIMER": 250 ms (initial delay: 250 ms)

[x] Translator 14.3: LIGHT OFF OUTPUT Incoming: On timer "LIGHT OFF TIMER" Outgoing: Note Off on ch. 11 with note:16 (0x10) and velocity:0 (0x00), to port X-TOUCH MINI 1

Steve

2017-02-17 18:24:32

It looks like your timers may be getting out of sync. To keep things more steady I would  have a single translator for incoming action Light ON Timer and then use raw midi output to either turn light on or off toggling a variable.

So say global variable ga is your toggle

rules would be

ga=ga^1

The above would toggle the value of ga between 1 and 0 (assuming you initialized the value of ga t0 zero when you start the project

then the following rules

//Note on channel 11

if ga==1 then pp=0x9a

//Note off channel 11

if ga==1 then pp=0x8a

Your midi output would then be

pp 10 64

Typically I set a variable for the channel as well (say gb) at project start

//set channel to midi 11

gb=10

then another rule to or the value of the channel number with the status message

// note on

pp=gb|0x90

// note off

pp=gb|0x80

Edit: If you use this method and you want the light to flash on and off 4 times you would need to set the timer repetition to 8

Steve

2017-02-18 02:50:57

Here is a working example I set up for My LaunchControl. It goes a bit beyond my original description but I documented each variable I used. I also added an Init translator to reset global variables when keyboard escape is pressed.

 


Attachments:

Flashing_Button-2017-02-17.bmtp