From 20c181470d550e1c8b3681526f81f16599d46aab Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 14 Nov 2012 16:07:38 -0500 Subject: [PATCH] Fixed issue in Starter kit example number 4 --- .../p04_ColorMixingLamp.ino | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino b/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino index 5b5501c5a..c1908007d 100644 --- a/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino +++ b/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino @@ -10,9 +10,10 @@ three 10 kilohm resistors 3 220 ohm resistors 3 photoresistors - red green aand blue colored gels + red green and blue colored gels Created 13 September 2012 + Modified 14 November 2012 by Scott Fitzgerald Thanks to Federico Vanzati for improvements @@ -42,32 +43,32 @@ void setup() { Serial.begin(9600); // set the digital pins as outputs - pinMode(greenLedPin,OUTPUT); - pinMode(redLedPin,OUTPUT); - pinMode(blueLedPin,OUTPUT); + pinMode(greenLEDPin,OUTPUT); + pinMode(redLEDPin,OUTPUT); + pinMode(blueLEDPin,OUTPUT); } void loop() { // Read the sensors first: // read the value from the red-filtered photoresistor: - redsensorValue = analogRead(redsensorPin); + redSensorValue = analogRead(redSensorPin); // give the ADC a moment to settle delay(5); // read the value from the green-filtered photoresistor: - greensensorValue = analogRead(greensensorPin); + greenSensorValue = analogRead(greenSensorPin); // give the ADC a moment to settle delay(5); // read the value from the blue-filtered photoresistor: - bluesensorValue = analogRead(bluesensorPin); + blueSensorValue = analogRead(blueSensorPin); // print out the values to the serial monitor Serial.print("raw sensor Values \t red: "); - Serial.print(redsensorValue); + Serial.print(redSensorValue); Serial.print("\t green: "); - Serial.print(greensensorValue); + Serial.print(greenSensorValue); Serial.print("\t Blue: "); - Serial.println(bluesensorValue); + Serial.println(blueSensorValue); /* In order to use the values from the sensor for the LED, @@ -75,9 +76,9 @@ void loop() { but analogWrite() uses 8 bits. You'll want to divide your sensor readings by 4 to keep them in range of the output. */ - redValue = redsensorValue/4; - greenValue = greensensorValue/4; - blueValue = bluesensorValue/4; + redValue = redSensorValue/4; + greenValue = greenSensorValue/4; + blueValue = blueSensorValue/4; // print out the mapped values Serial.print("Mapped sensor Values \t red: "); @@ -90,8 +91,8 @@ void loop() { /* Now that you have a usable value, it's time to PWM the LED. */ - analogWrite(redLedPin, redValue); - analogWrite(greenLedPin, greenValue); - analogWrite(blueLedPin, blueValue); + analogWrite(redLEDPin, redValue); + analogWrite(greenLEDPin, greenValue); + analogWrite(blueLEDPin, blueValue); }