ARDUINO RGB LED CHANGE

#include <SoftwareSerial.h> // libreria comunicacion serial const int REDPIN = 4; const int GREENPIN = 5; const int BLUEPIN = 6; SoftwareSerial BT(10,11); // tx,rx Inicializa bluetooth void setup() { // initialize serial: BT.begin(9600); // inciamos comunicacion bluetooth BT.flush(); Serial.begin(9600); Serial.println("Ready"); // make the pins outputs: pinMode(REDPIN, OUTPUT); pinMode(GREENPIN, OUTPUT); pinMode(BLUEPIN, OUTPUT); } void loop() { while (BT.available() > 0) { int red = BT.parseInt(); int green = BT.parseInt(); int blue = BT.parseInt(); if (BT.read() == '\n') { setColor(red,green,blue); Serial.println("colores:"); Serial.println(red); Serial.println(green); Serial.println(blue); } } } void setColor(int red, int green, int blue) { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif analogWrite(REDPIN, red); analogWrite(GREENPIN, green); analogWrite(BLUEPIN, blue); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.