Arduino Mega 2560

RGB LEDs contain a Red, Green and Blue LED. You can mix any color by using the correct scale of the 3 basic colors. If you grow brightness and keep scale at the same time, you can show the same color even brighter. The brightness of basic colors can be set from 0 to 255. Brightness in Ozeki can be adjusted in absolute numbers or as a percentage. An RGB LED is a perfect tool to show desired colors.

arduino with rgb led
Figure 1 - Arduino Mega 2560 with RGB Led

Required hardware

  • Arduino Mega 2560
  • RGB Led
  • Resistors: (2) 100Ω, (1) 220Ω

Source code to install on controller


Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h>
#include <OzRGBLedController.h>

// global pointers
OzIDManager* manager;
OzRGBLedController* rgbController;

// please select PWM pins
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;
const int pwm = 9;

void setup()
{
  // wait for serial port
  Serial.begin(115200);

  // instantiate objects
  manager = new OzIDManager;
  manager->_sendACK = true;
  manager->_checksum = true;

  OzCommunication::setIDManager(manager);

  rgbController = new OzRGBLedController(redPin, greenPin, bluePin);
  rgbController->setPWM(pwm);

  int x=1;
  manager->sendLinkSetup();
  manager->PrintWelcomeLine(rgbController, x++, "MyRGBLed");
}

void loop()
{
   OzCommunication::communicate();
}