top of page

Create Your First Project

Start adding your projects to your portfolio. Click on "Manage Projects" to get started

Third exercise

LED bulb that changes its shades

CODE :

const int Rpin = 9;
const int Gpin = 10;
const int Bpin = 11;



void setup() {
// put your setup code here, to run once:
pinMode(Rpin,OUTPUT);
pinMode(Gpin,OUTPUT);
pinMode(Bpin,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
for(int i = 0; i<=255; i++){
analogWrite(Rpin, 255);
analogWrite(Gpin, 0);
analogWrite(Bpin, i);
delay(5);
}
for(int i = 255; i>=0; i--){
analogWrite(Rpin, 255);
analogWrite(Gpin, 0);
analogWrite(Bpin, i);
delay(5);
}
}

bottom of page