tag:blogger.com,1999:blog-23217409.post2013523898848893984..comments2024-03-15T15:10:58.249+10:30Comments on little-scale: Teensy 3.6 Basics - Receiving MIDI CCSebastian Tomczakhttp://www.blogger.com/profile/12712567577323498804noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-23217409.post-33679391229517087152019-03-12T11:49:06.469+10:302019-03-12T11:49:06.469+10:30Hi JohnDavidLloyd,
Do you mean use a MIDI CC valu...Hi JohnDavidLloyd, <br />Do you mean use a MIDI CC value sent from a computer to then control the PWM duty of an LED? <br /><br />If so - please have a look at this example: <br /><br />int LED = 13; // variable for LED pin<br />int LED_PWM_pin = 2; <br /><br />void setup() {<br /> usbMIDI.setHandleControlChange(OnCC); // set handle for MIDI continuous controller messages<br /> pinMode(LED, OUTPUT); // set LED pin to output<br />}<br /><br />void loop() {<br /> usbMIDI.read(); // read the USB MIDI bus every loop<br />}<br /><br /><br /><br />// this function is called whenever a MIDI continuous controller messahe is received<br />// the function is executed using the received message bytes of channel, controller and value corresponding to the variable names below<br />// for example, a modulation wheel message the first channel with a half value will be called with OnCC(1, 1, 64);<br />// messaged can be filtered by controller value<br /><br />void OnCC(byte channel, byte controller, byte value) {<br /> if(controller == 1) {<br /> analogWrite(LED_PWM_pin, value);<br /> }<br />}Sebastian Tomczakhttps://www.blogger.com/profile/12712567577323498804noreply@blogger.comtag:blogger.com,1999:blog-23217409.post-36688264327567874712019-03-12T11:43:54.768+10:302019-03-12T11:43:54.768+10:30Hey! This is so great, your other blog post helped...Hey! This is so great, your other blog post helped me figure out the midi output to midi. Now I have a problem,<br /><br />How would I be able to make the CC values change with PWM?<br />0-127 as 0 is no light, and 127 is maximum brightness.<br /><br />Would love to know how to do this! My research so far has got me lost. Thank you for any help!JohnDavidLloydhttps://www.blogger.com/profile/16323744707396341071noreply@blogger.com