The Wood Leaves Wind Indicator prototype:
Code:
int analogInPin1 = A0;
int analogInPin2 = A1;
int analogInPin3 = A2;
int ledPin1 =9;
int ledPin2= 8;
int ledPin3= 7;
int sensorValue1 = 0;
int outputValue1 = 0;
int sensorValue2 = 0;
int outputValue2 = 0;
int sensorValue3 = 0;
int outputValue3 = 0;
void setup() {
Serial.begin(9600);
// nothing happens in setup
}
void loop() {
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=15) {
// fade in from min to max in increments of 5 points:
sensorValue1 = analogRead(analogInPin1);
outputValue1= map(sensorValue1, 0, 1000, 0, 255);
analogWrite(ledPin1, outputValue1);
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// fade in from min to max in increments of 5 points:
sensorValue2 = analogRead(analogInPin2);
outputValue2= map(sensorValue2, 0, 1000, 0, 255);
analogWrite(ledPin2, outputValue2);
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=15) {
// fade in from min to max in increments of 5 points:
sensorValue3 = analogRead(analogInPin3);
outputValue3= map(sensorValue3, 0, 1000, 0, 255);
analogWrite(ledPin3, outputValue3);
Serial.print(“sensor1 = ” );
Serial.print(sensorValue1);
Serial.print(“\t output1 = “);
Serial.println(outputValue1);
Serial.print(“sensor2 = ” );
Serial.print(sensorValue2);
Serial.print(“\t output2 = “);
Serial.println(outputValue2);
Serial.print(“sensor3 = ” );
Serial.print(sensorValue3);
Serial.print(“\t output3 = “);
Serial.println(outputValue3);
delay(400);
}}}}