0% found this document useful (0 votes)
6 views2 pages

SensorRGB C

The document declares integer variables for red, green and blue pins and sets their pin modes to output. It uses for loops to fade the LEDs from full brightness to off and back again, writing analog values to the pins and adding a delay.

Uploaded by

Charly Leon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

SensorRGB C

The document declares integer variables for red, green and blue pins and sets their pin modes to output. It uses for loops to fade the LEDs from full brightness to off and back again, writing analog values to the pins and adding a delay.

Uploaded by

Charly Leon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

int redpin = 11;

int greenpin =10;

int bluepin =9;

int val;
void setup(){

pinMode(redpin, OUTPUT);
pinMode(bluepin, OUTPUT);
pinMode(greenpin, OUTPUT);
Serial.begin(9600);
}
void loop(){
for(val=255; val>0; val--)
{analogWrite(11, val);
analogWrite(10, 255-val);
analogWrite(9, 128-val);
delay(10);
}
for(val=0; val<255; val++)
{
analogWrite(11, val);
analogWrite(10, 255-val);
analogWrite(9, 128-val);
delay(10);
}
Serial.println(val, DEC);
}

You might also like