Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tum_yil_icin_arduino_mufredati_34
int rgb_r=9; //bağlantı yapılan pinler
int rgb_g=10;
int rgb_b=11;
int pot=0;
int digital_pot,digital_mapr,digital_mapg,digital_mapb,digital_mapm;
void setup() {
Serial.begin(9600);
pinMode(rgb_r, OUTPUT);
pinMode(rgb_g, OUTPUT);
pinMode(rgb_b, OUTPUT);
}
void loop() {
digital_pot=analogRead(pot);
Serial.println(digital_pot);
digital_mapr=map(digital_pot,0,255,0,255);
digital_mapg=map(digital_pot,256,510,0,255);
digital_mapb=map(digital_pot,511,765,0,255);
digital_mapm=map(digital_pot,766,1023,0,255);
if(digital_pot<=255) // kırmızı
{
analogWrite(rgb_r,255-digital_mapr);
digitalWrite(rgb_b,HIGH);
digitalWrite(rgb_g,HIGH);
}
else if(digital_pot>=256 && digital_pot<510) // kırmızı yeşil
{
analogWrite(rgb_r,digital_mapg);
digitalWrite(rgb_b,HIGH);
analogWrite(rgb_g,255-digital_mapg);
}
else if(digital_pot>=511 && digital_pot<765) // yeşil mavi
{
analogWrite(rgb_g,digital_mapb);
analogWrite(rgb_b,255-digital_mapb);
digitalWrite(rgb_r,HIGH);
}
else if(digital_pot>=766 && digital_pot<1023) // yeşil mavi
{
analogWrite(rgb_r,255-digital_mapm);
analogWrite(rgb_b,digital_mapm);
digitalWrite(rgb_g,HIGH);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.