Mr robot Maker
Published

Control a RGB Led using Arduino and a smartphone's camera

Color detection with Arduino and smartphone - output on RGB LED using 1Sheeld color sensor.

BeginnerFull instructions provided5,451
Control a RGB Led using Arduino and a smartphone's camera

Things used in this project

Schematics

schematics

Code

Untitled file

Arduino
#define CUSTOM_SETTINGS
#define INCLUDE_COLOR_DETECTOR_SHIELD


#include <OneSheeld.h>


int redPin = 11;
int greenPin =10;
int bluePin = 9;

void setup() {
  OneSheeld.begin();
  pinMode(redPin, OUTPUT); 
  pinMode(greenPin, OUTPUT); 
  pinMode(bluePin, OUTPUT);
  ColorDetector.setPalette(_3_BIT_RGB_PALETTE);
}

void loop() {
  if(ColorDetector.isNewColorReceived())
  {
    Color readColor = ColorDetector.getLastColor();
    byte redValue = readColor.getRed();
    byte greenValue = readColor.getGreen();
    byte blueValue = readColor.getBlue();
   
    digitalWrite(redPin,redValue);
    digitalWrite(greenPin,greenValue);
    digitalWrite(bluePin,blueValue);    
  }
}

Codebender

Credits

Mr robot Maker

Mr robot Maker

1 project • 0 followers

Comments