0% found this document useful (0 votes)
16 views1 page

LED Color Control with Rotation Dial

Uploaded by

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

LED Color Control with Rotation Dial

Uploaded by

navneetbatth906
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

int redPin = 9; // define the pin of the Red LED

int greenPin = 10;// define the pin of the Green LED


int bluePin = 11;// define the pin of the Blue LED
int rotationDialPin = A0;

void setup() {
pinMode(redPin, OUTPUT);//Will Turn LIght REd
pinMode(greenPin, OUTPUT);//Will Turn Light Green
pinMode(bluePin, OUTPUT);//Will Turn Light Blue
}

void loop() {
int rotationSpeed = map(analogRead(rotationDialPin), 0, 1023, 100, 1000);

setColor(255, 0, 0); // Red Colour Will be Shown.


delay(rotationSpeed);

setColor(0, 255, 0); // Green Colour Will be Shown.


delay(rotationSpeed);

setColor(0, 0, 255); // Blue Colour Will Be shown.


delay(rotationSpeed);
}

void setColor(int red, int green, int blue) {


analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

You might also like