Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Potentiometer Rg b Cycle

Potentiometer Rg b Cycle

Ratings: (0)|Views: 4|Likes:
Published by makersapprentice

More info:

Published by: makersapprentice on Jan 01, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

01/01/2013

pdf

text

original

 
//This sketch creates a rgb led which will cycle through the color spectrum when you twist apotentiometer. It combines SIK guide exercises 2 and 3//It takes the potentiometer circuit from #2 and the RGB LED circuit from #3//This sets up constants for the locations of each pinconst int RED_PIN = 9;const int GREEN_PIN = 10;const int BLUE_PIN = 11;const int sensorPin = 0;int DISPLAY_TIME = 100;void setup(){pinMode(RED_PIN, OUTPUT);pinMode(GREEN_PIN, OUTPUT);pinMode(BLUE_PIN, OUTPUT);}void loop(){showSpectrum(); //This function is defined below}void showSpectrum(){int sensorValue;int sensorValueNorm;sensorValue = analogRead(sensorPin);sensorValueNorm = sensorValue*0.75;//0.75 is an approximation of 766/1023. The reason for doing this is that the sensor valuereturns a value between 1023 while our showSpectrum() function only takes values between 1and 766. This basically takes a value between 1 and 1023 and maps it onto a value between 1and 766.showRGB(sensorValueNorm); // Call showRGB() with our new x. This function is definedbelow

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->