mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-23 19:21:59 +03:00
Fixed issue in Starter kit example number 4
This commit is contained in:
@ -10,9 +10,10 @@
|
|||||||
three 10 kilohm resistors
|
three 10 kilohm resistors
|
||||||
3 220 ohm resistors
|
3 220 ohm resistors
|
||||||
3 photoresistors
|
3 photoresistors
|
||||||
red green aand blue colored gels
|
red green and blue colored gels
|
||||||
|
|
||||||
Created 13 September 2012
|
Created 13 September 2012
|
||||||
|
Modified 14 November 2012
|
||||||
by Scott Fitzgerald
|
by Scott Fitzgerald
|
||||||
Thanks to Federico Vanzati for improvements
|
Thanks to Federico Vanzati for improvements
|
||||||
|
|
||||||
@ -42,32 +43,32 @@ void setup() {
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// set the digital pins as outputs
|
// set the digital pins as outputs
|
||||||
pinMode(greenLedPin,OUTPUT);
|
pinMode(greenLEDPin,OUTPUT);
|
||||||
pinMode(redLedPin,OUTPUT);
|
pinMode(redLEDPin,OUTPUT);
|
||||||
pinMode(blueLedPin,OUTPUT);
|
pinMode(blueLEDPin,OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Read the sensors first:
|
// Read the sensors first:
|
||||||
|
|
||||||
// read the value from the red-filtered photoresistor:
|
// read the value from the red-filtered photoresistor:
|
||||||
redsensorValue = analogRead(redsensorPin);
|
redSensorValue = analogRead(redSensorPin);
|
||||||
// give the ADC a moment to settle
|
// give the ADC a moment to settle
|
||||||
delay(5);
|
delay(5);
|
||||||
// read the value from the green-filtered photoresistor:
|
// read the value from the green-filtered photoresistor:
|
||||||
greensensorValue = analogRead(greensensorPin);
|
greenSensorValue = analogRead(greenSensorPin);
|
||||||
// give the ADC a moment to settle
|
// give the ADC a moment to settle
|
||||||
delay(5);
|
delay(5);
|
||||||
// read the value from the blue-filtered photoresistor:
|
// read the value from the blue-filtered photoresistor:
|
||||||
bluesensorValue = analogRead(bluesensorPin);
|
blueSensorValue = analogRead(blueSensorPin);
|
||||||
|
|
||||||
// print out the values to the serial monitor
|
// print out the values to the serial monitor
|
||||||
Serial.print("raw sensor Values \t red: ");
|
Serial.print("raw sensor Values \t red: ");
|
||||||
Serial.print(redsensorValue);
|
Serial.print(redSensorValue);
|
||||||
Serial.print("\t green: ");
|
Serial.print("\t green: ");
|
||||||
Serial.print(greensensorValue);
|
Serial.print(greenSensorValue);
|
||||||
Serial.print("\t Blue: ");
|
Serial.print("\t Blue: ");
|
||||||
Serial.println(bluesensorValue);
|
Serial.println(blueSensorValue);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
In order to use the values from the sensor for the LED,
|
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
|
but analogWrite() uses 8 bits. You'll want to divide your
|
||||||
sensor readings by 4 to keep them in range of the output.
|
sensor readings by 4 to keep them in range of the output.
|
||||||
*/
|
*/
|
||||||
redValue = redsensorValue/4;
|
redValue = redSensorValue/4;
|
||||||
greenValue = greensensorValue/4;
|
greenValue = greenSensorValue/4;
|
||||||
blueValue = bluesensorValue/4;
|
blueValue = blueSensorValue/4;
|
||||||
|
|
||||||
// print out the mapped values
|
// print out the mapped values
|
||||||
Serial.print("Mapped sensor Values \t red: ");
|
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.
|
Now that you have a usable value, it's time to PWM the LED.
|
||||||
*/
|
*/
|
||||||
analogWrite(redLedPin, redValue);
|
analogWrite(redLEDPin, redValue);
|
||||||
analogWrite(greenLedPin, greenValue);
|
analogWrite(greenLEDPin, greenValue);
|
||||||
analogWrite(blueLedPin, blueValue);
|
analogWrite(blueLEDPin, blueValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user