Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 4 A: Changing Brightness in Steps of 5 0 ( Create a new project: so you have a separate copy of your code. )

Exercise 4A: Changing Brightness in Steps of 50
(Create a new project: so you have a separate copy of your code.)
Now change the program so that the first LED shows red, the second one green, and the third one blue. We want all three to have a light intensity of 0, then after a second, all three change intensity to 50, then 100,150,200,250, and back to 0.(VERY STRONG HINT: Do not use the pixel.setBrightness() function. It is not intended for this purpose and very likely will break and/or confuse you later.)
#include "Particle.h"
#include "neopixel.h"
#define PIXEL_PIN D4
#define PIXEL_COUNT 3
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup(){
strip.begin();
strip.show();
}
void loop(){
for (int brightness =0; brightness <=250; brightness +=50){
strip.setPixelColor(0, strip.Color(brightness,0,0));
strip.setPixelColor(1, strip.Color(0, brightness, 0));
strip.setPixelColor(2, strip.Color(0,0, brightness));
strip.show();
delay(1000);
}
strip.setPixelColor(0, strip.Color(0,0,0));
strip.setPixelColor(1, strip.Color(0,0,0));
strip.setPixelColor(2, strip.Color(0,0,0));
strip.show();
delay(1000);
}
Is this code correct?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sql++ For Sql Users A Tutorial

Authors: Don Chamberlin

1st Edition

0692184503, 978-0692184509

More Books

Students also viewed these Databases questions