X-Git-Url: http://git.piffa.net/web?p=sketchbook_andrea;a=blobdiff_plain;f=libraries%2Fcommon%2Fcommon.cpp;h=4a886b26cc95186a358d0cd66af4abc5a5c27052;hp=e99f202804a45134155d354388719b26f8b1d0de;hb=c5a3dc4a9cc7eea224814fee4b00575e726105fa;hpb=0662b12752ee761efee7077b63c77f294e98deda diff --git a/libraries/common/common.cpp b/libraries/common/common.cpp index e99f202..4a886b2 100644 --- a/libraries/common/common.cpp +++ b/libraries/common/common.cpp @@ -21,7 +21,7 @@ RGBLed::RGBLed(byte pinR, byte pinG, byte pinB) { redPin = pinR ; greenPin = pinG ; bluePin = pinB ; - common = 255 ; + common = 0 ; // Equvalente del Setup() per inizializzare i PIN pinMode(redPin, OUTPUT); @@ -44,17 +44,24 @@ RGBLed::RGBLed(byte pinR, byte pinG, byte pinB, byte com) { void RGBLed::SetColor (byte r, byte g, byte b) { // Imposta il colore di un LED RGB - analogWrite(redPin, common - r); - analogWrite(greenPin, common - g); - analogWrite(bluePin, common - b); + if (common == 0) { + analogWrite(redPin, r); + analogWrite(greenPin, g); + analogWrite(bluePin, b); + } else { + analogWrite(redPin, 255 - r); + analogWrite(greenPin, 255 - g); + analogWrite(bluePin, 255 - b); + } + // Debug #ifdef DEBUG - Serial.print(common - r); + Serial.print(r); Serial.print("-"); - Serial.print(common - g); + Serial.print(g); Serial.print("-"); - Serial.print(common - b); + Serial.print(b); while(1); #endif