// Run a motor at full speed then continuously reduce its speed until it is off. // Fade an LED in consonance with the motor's speed int motorInputPin = 6; int ledPin = 10; int delay2 = 5000; int delay3 = 50; void setup() { pinMode(motorInputPin, OUTPUT); pinMode(ledPin, OUTPUT); } void loop() { // Turn motor on for delay2/1000 seconds digitalWrite(ledPin, HIGH); digitalWrite(motorInputPin, HIGH); delay(delay2); // Continuously slow motor down for (int i = 255; i >= 1; i = i - 2) { analogWrite(motorInputPin, i); analogWrite(ledPin, i); // Delay delay3/1000 seconds between changes in motor speed delay(delay3); } // Pause for delay2/1000 seconds delay(delay2); }