# Getting Sketch To Reset using MIDI

**URL:** <https://discourse.processing.org/t/getting-sketch-to-reset-using-midi/11078>\
**Category:** Libraries\
**Created:** [May 9, 2019, 6:50pm UTC](https://discourse.processing.org/t/getting-sketch-to-reset-using-midi/11078 "2019-05-09T18:50:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![djspoonzay](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@djspoonzay](https://discourse.processing.org/u/djspoonzay)\
**Post date:** [May 9, 2019, 6:50pm UTC](https://discourse.processing.org/t/getting-sketch-to-reset-using-midi/11078/1 "2019-05-09T18:50:33Z")

</div>

what i’m trying to do is I have a midi keyboard with the C,E and G keys assigned as int 255 each, to make a coloured ellipse, what I’d like is that when the keys are released to then remove that color value so the RGB values can be changed and not just ultimately create a white ellipse…?

> import themidibus.\*;  
> MidiBus myBus;
> 
> int Ckey;  
> int Ekey;  
> int Gkey;  
> boolean noteOn ;  
> boolean noteOff ;  
> int pitch;
> 
> void noteOn(int channel, int pitch, int velocity) {  
> if (channel == 0 && pitch == 60) {  
> Ckey = 255;  
> }  
> if (channel == 0 && pitch == 64) {  
> Ekey = 255;  
> }  
> if (channel == 0 && pitch == 67) {  
> Gkey = 255;  
> }
> 
> println("C: " + channel + " P: " + pitch + " V: " + velocity);  
> }
> 
> void setup () {  
> size (400, 400);  
> background (255);
> 
> MidiBus.list();  
> myBus = new MidiBus(this, 0, 3);  
> }
> 
> void draw () {
> 
> fill (Ckey, Ekey, Gkey);
> 
> ellipse (200, 200, 200, 200);  
> }

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 13, 2019, 6:46am UTC](https://discourse.processing.org/t/getting-sketch-to-reset-using-midi/11078/2 "2019-05-13T06:46:39Z")

</div>

Have you tried using either note off or keyReleased? I’m not quite clear on your goal from your description.
