redPin = pinR ;
greenPin = pinG ;
bluePin = pinB ;
- common = 255 ;
+ common = 0 ;
// Equvalente del Setup() per inizializzare i PIN
pinMode(redPin, OUTPUT);
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
/////////////////////////////////////
// Lampeggiatore
// Constructor
+//
+// Esempi incrementali: https://lab.piffa.net/sketchbook_andrea/multitasking/
Lampeggiatore::Lampeggiatore(int pin)
{
ledPin = pin;
void Lampeggiatore::High() {
// Accende il LED
-
digitalWrite(ledPin, HIGH);
}
void Lampeggiatore::Low() {
// Spegne il LED
-
digitalWrite(ledPin, LOW);
}
void Lampeggiatore::Swap() {
// Inverte lo stato del LED
-
digitalWrite(ledPin, !digitalRead(ledPin));
}
Serial.println(middle / 10 + 10);
Serial.flush() ;
#endif
- return(middle / 10 + 10) ;
+ return(middle / 10 ) ;
// END calibrazione
};