Introduction: Bentzi Led
this how it looks when its working
Step 1: Code for the Light
It might be a little choppy when you look at it from here
int greenled=9;// sets the color green for the light
int blueled=10;// sets the color blue for the light int redled=11;// sets the color red for the light int redval=0; // sets a value that can be changed for the color red int blueval=0;// sets a value that can be changed for the color blue int greenval=0;// sets a value that can be changed for the color green int potPin=A0; // sets a value for the pententiometer allows it to work void setup() { // put your setup code here, to run once: pinMode(potPin,INPUT); // by making it an INPUT you are telling the Potpin to read what the values are pinMode(A0, INPUT);// by making it an input it is telling it to read values the send it to the light pinMode(greenled,OUTPUT);// for all the lights by telling them to be OUTPUTs you are telling them to produce a color. pinMode(redled,OUTPUT); pinMode(blueled,OUTPUT); Serial.begin(9600);// this is telling the Serial to begin printing values }
void loop() { // put your main code here, to run repeatedly: redval= analogRead(potPin);// this is telling the value to read from the potpin greenval= analogRead(potPin);// this is telling the value to read from the potpin blueval= analogRead(potPin);// this is telling the value to read from the potpin redval= map(redval,0,1023,255,0);// this is telling the values to interput 0 to 1023 and 255 to zero blueval= map(blueval,0,1023,0,255);// same as above just different numbers greenval= map(greenval,0,1023,130,5);// same as two above just different numbers Serial.print(redval);// telling the Serial to print the redvalue same for blue and green Serial.print(blueval); Serial.println(greenval); analogWrite(redled, redval);// tells the light to act as the redvalue tells it to analogWrite(greenled, greenval); analogWrite(blueled, blueval);
}
Step 2: Setup
big leg for the light goes to five volts middle leg for pentameter goes to A0
Step 3: How It Looks When You Try It at the End
If you want to change the colors go back to the code set and adjust the numbers when redvalue or green or blue is reading from map essentially change numbers here this step redval= map(redval,0,1023,255,0);