Skip to content

Create an LED Class #2

@theDataSmith

Description

@theDataSmith

This class represents an RGB (red-green-blue) LED. An RGB LED is a light emitting diode that has three channels, one for each color. By varying the brightness of each of the three channels, an RGB LED can create any color.

It will send a voltage to each of three pins to control the brightness of each channel. The constructor should take the three pins as arguments and store them.

Needed Arduino Functions:
pinMode()
analogWrite()

The class should have the following public functions:

  • void setRGB(int r, int g, int b)
    • Takes three ints between 0-255 and sets the color accordingly.
  • void setRGB(float r, float g, float b)
    • Takes three floats between 0-1 and sets the color accordingly.
  • void setHSV(float h, float s, float v)
    • Takes three floats between 0-1. It will need to convert the hue, saturation, and value into red, green, and blue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions