Question: Can you modify this code in arduino app, output should show all 4 leds changing from light to dark; dark to light //Note:This code only
Can you modify this code in arduino app, output should show all 4 leds changing from light to dark; dark to light
//Note:This code only applies to 1 led that change from light to dark;dark to light
// set pin numbers: int ledPin = 5; // the number of the LED pin void setup() { Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); } void loop() { // call breath() cyclically breath(ledPin, 6); delay(1000); } void breath(int ledPin, int delayMs) { for (int i = 0; i = 0; i--) { // "i" change from 255 to 0 analogWrite(ledPin, i); // correspongding duty cycle change from 0%-100% delay(delayMs); // adjust the rate of change in brightness Serial.println(ledPin); }
}
- CET4711_Nicole_Lab3.1 | Arduino 1.8.13 File Edit Sketch Tools Help O CET4711_Nicole_Lab3.19 // set pin numbers: int ledPin = 5; // the number of the LED pin void setup() { Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); } void loop() ] // call breath() cyclically breath (ledPin, 6); delay(1000); void breath (int ledPin, int delayMs) { for (int i = 0; i = 0; i--) { // "i" change from 255 to o analogWrite(ledPin, i); // correspongding duty cycle change from 08-100% delay (delayMs); // adjust the rate of change in brightness Serial.println(ledPin); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
