/*-----( Import needed libraries )-----*/ #include //#include //#include #include "nRF24L01.h" #include "RF24.h" #include "printf.h" /*-----( Declare Constants and Pin Numbers )-----*/ #define CE_PIN 2 #define CSN_PIN 11 #define red 5 #define green 10 #define blue 9 #define white 6 // arduino shield #define DEBUG 1 #define TEST 0 byte idpins[8]={ 0, 4, 12, 8, 7, A1, A0, 13}; int i = 0; int row, col; int colNum = 5; // X -> Maximum of 10 cols. Maximun packet size 32 bytes int rowNum = 13; // Y float plusLight = 1. ; // NOTE: the "LL" at the end of the constant is "LongLong" type const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe /*-----( Declare objects )-----*/ RF24 radio(CE_PIN, CSN_PIN); // Create a Radio /*-----( Declare Variables )-----*/ uint8_t rgb[32]; // 2 element array holding Joystick readings float average(int anaPin) { int lecturas = 100; long total = 0; float average = 0; for(int i=0; i=0; i--) { analogWrite(red, i); delay(10); } for (int i=0; i<256; i++) { analogWrite(green, i); delay(10); } for (int i=254; i>=0; i--) { analogWrite(green, i); delay(10); } for (int i=0; i<256; i++) { analogWrite(blue, i); delay(10); } for (int i=254; i>=0; i--) { analogWrite(blue, i); delay(10); } // print out the value you read: float Vcc = (sensorValueInternal/sensorValueDefault)*2560; Serial.print("Vcc: "); Serial.print(Vcc); Serial.print(" Internal: "); Serial.print(sensorValueInternal*2*(2560/1023.)); Serial.print(" Default: "); Serial.println(sensorValueDefault*2*(3300/1023.)); delay(1); // delay in between reads for stability } else { if ( radio.available() ) { bool done = false; while (!done) { // Fetch the data payload done = radio.read( rgb, sizeof(rgb) ); if(rgb[0] == 1) //rgb[0] es el CMD, CMD = 1 => MODO STREAM { if(rgb[1] == row) // row from 0 to 9 { analogWrite(red, (byte)(rgb[2+col*3]*plusLight)); // Red analogWrite(green, (byte)(rgb[3+col*3]*plusLight)); // Green analogWrite(blue, (byte)(rgb[4+col*3]*plusLight)); // Blue } } else if(rgb[0] == 2) //CMD = 2 => plusLight CMD (apretar PWM de 127 hasta 250) -> CUIDADO!!! { if(rgb[1] > 250) rgb[1] = 250; plusLight = rgb[1] / 64. ; //Serial.println(plusLight); } if(DEBUG) { i = 0; for(i=0 ; i