Paso 3: Programar el chip
Color RGB ATtiny85 descoloramiento luz del humor ahora con capacidades de detección de luz!!!!!!
const int redPin = 2;
const int grnPin = 1;
const int bluPin = 0;
const int sensor = 3;
void setup()
{
pinMode (redPin, salida);
pinMode (grnPin, salida);
pinMode (bluPin, salida);
pinMode (sensor de entrada);
}
void loop() {}
Si (analogRead(sensor) < = 200)
{
redtoyellow();
yellowtogreen();
greentocyan();
cyantoblue();
bluetomagenta();
magentatored();
}
else if (analogRead(sensor) > = 201)
{
digitalWrite (redPin, LOW);
digitalWrite (grnPin, bajo);
digitalWrite (bluPin, LOW);
}
}
void redtoyellow()
{
digitalWrite (redPin, HIGH);
digitalWrite (bluPin, LOW);
se desvanecen en verde
para (byte i = 1; i < 100; i ++) {}
byte por = i;
byte de = 100-a;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (grnPin, HIGH);
delayMicroseconds(on);
digitalWrite (grnPin, bajo);
delayMicroseconds(off);
}
}
}
void yellowtogreen()
{
digitalWrite (grnPin, HIGH);
digitalWrite (bluPin, LOW);
se descolora abajo rojo
para (byte i = 1; i < 100; i ++) {}
byte a = 100-i;
byte de = i;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (redPin, HIGH);
delayMicroseconds(on);
digitalWrite (redPin, LOW);
delayMicroseconds(off);
}
}
}
void greentocyan()
{
digitalWrite (grnPin, HIGH);
digitalWrite (redPin, LOW);
aumentará la intensidad azul
para (byte i = 1; i < 100; i ++) {}
byte por = i;
byte de = 100-a;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (bluPin, HIGH);
delayMicroseconds(on);
digitalWrite (bluPin, LOW);
delayMicroseconds(off);
}
}
}
void cyantoblue()
{
digitalWrite (bluPin, HIGH);
digitalWrite (redPin, LOW);
descolorarse hacia abajo verde
para (byte i = 1; i < 100; i ++) {}
byte a = 100-i;
byte de = i;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (grnPin, HIGH);
delayMicroseconds(on);
digitalWrite (grnPin, bajo);
delayMicroseconds(off);
}
}
}
void bluetomagenta()
{
digitalWrite (bluPin, HIGH);
digitalWrite (grnPin, bajo);
se desvanecen en rojo
para (byte i = 1; i < 100; i ++) {}
byte por = i;
byte de = 100-a;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (redPin, HIGH);
delayMicroseconds(on);
digitalWrite (redPin, LOW);
delayMicroseconds(off);
}
}
}
void magentatored()
{
digitalWrite (redPin, HIGH);
digitalWrite (grnPin, bajo);
se descolora abajo azul
para (byte i = 1; i < 100; i ++) {}
byte a = 100-i;
byte de = i;
para (byte a = 0; a < 100; a ++) {}
digitalWrite (bluPin, HIGH);
delayMicroseconds(on);
digitalWrite (bluPin, LOW);
delayMicroseconds(off);
}
}
}