This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 2 voto(s) - 1.5 Media
  • 1
  • 2
  • 3
  • 4
  • 5
Crear color con Arduino + 4 leds?
#1
Hola a todos,

Queria saber si con el siguiente codigo puedo enviar un color en HEX via bluetooth al arduino y que este los encienda de forma que los cuatro leds lo representen de la forma mas aproximada. Hay algun error en el?


Código:
/*

*/

#define RED OCR1A
#define GREEN OCR1B
#define BLUE OCR1C
#define WHITE OCR4A

int whitevalue;


void setup() {
  // initialize serial:
 Serial.begin(9600);
 Serial.print("Arduino control RGB LEDs Connected OK ( Sent From Arduinno Board )");
 Serial.print('\n');
}

void loop() {
 // if there's any serial available, read it:
 while (Serial.available() > 0) {
   
   // look for the next valid integer in the incoming serial stream:
   int red = Serial.parseInt();
   // do it again:
   int green = Serial.parseInt();
   // do it again:
   int blue = Serial.parseInt();
   // do it again:
   int white = Serial.parseInt();
   
   // look for the newline. That's the end of your
   // sentence:
   if (Serial.read() == '\n') {

     // print the three numbers in one string as hexadecimal:
     Serial.print("Data Response : ");
     Serial.print(red, HEX);
     Serial.print(green, HEX);
     Serial.println(blue, HEX);
     Serial.println(white, HEX);
   }
 }
 
}
  Responder
#2
Prueba los rgb
  Responder


Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  [TUTO] Pantalla 150 Leds WS2812 cansi22 27 29,791 06-10-2019, 08:14 PM
Último mensaje: yomaker
  CONSULTA Controlar 3000 leds, ¿cual es la mejor opcion? the_feti 2 1,434 13-08-2018, 10:00 PM
Último mensaje: the_feti
  Controlar 8 leds 100 mA con Arduino y ULN2803 amjlopez 1 1,412 30-07-2018, 12:04 PM
Último mensaje: Bayaz
  Dimmer para tira de leds, problema ZeroCool 7 3,033 27-04-2016, 08:57 PM
Último mensaje: Bayaz
  Leds ws2801 y alimentar arduino uno joseab 1 4,252 27-07-2015, 08:53 AM
Último mensaje: biketrial981