Thank you so much guys!! The final solution was to use a long instead of an unsigned int, you guys are amazing without your help i would never have succeeded, BUT i'm not there yet...
i stil get just this:
Setup was succesfull
mySwitch is available
This is mySwitch.getReceivedValue, it should contain 6 numbers:222222
This is value, it should contain 6 numbers:222222
This is data, it should contain 6 numbers:222222
This is blue, it is an char and should contain 2 numbers:22
This is Fblue, it is an int and should contain 2 numbers:22
22
Available is reseted
when sending these three codes:
pi@Willems ~ $ sudo ./codesend 222222
sending code[222222]
pi@Willems ~ $ sudo ./codesend 222221
sending code[222221]
pi@Willems ~ $ sudo ./codesend 111111
sending code[111111]
shouldn't it go trough the if statement again since blue and Pblue are not the same value?
here is my entire code:
#include <RCSwitch.h>
#include <sstream.h> // std::istringstream
#include <iostream.h>
#include <string.h>
RCSwitch mySwitch = RCSwitch();
int ledPinR = 9;
int ledPinG = 10;
int ledPinB = 11;
int Fblue;
char red [3] = {0,0,0};
char blue [3] = {0,0,0};
char green [3] = {0,0,0};
char Pred [3] = {0,0,0};
char Pblue [3] = {0,0,0};
char Pgreen [3] = {0,0,0};
String str;
void setup() {
pinMode(ledPinR, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinB, OUTPUT);
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
Serial.println("Setup was succesfull");
}
void loop() {
if (mySwitch.available()) {
Serial.println("mySwitch is available");
long value = mySwitch.getReceivedValue();
Serial.print("This is mySwitch.getReceivedValue, it should contain 6 numbers:");
Serial.println( mySwitch.getReceivedValue() );
Serial.print("This is value, it should contain 6 numbers:");
Serial.println(value);
char data [7];
sprintf(data,"%ld",value); //convert 'value' to a string which is padded with 0's to 6 characters.
Serial.print("This is data, it should contain 6 numbers:");
Serial.println(data);
memcpy(red,data+0,2); //copy 2 bytes starting from data[0]
memcpy(blue,data+2,2); //copy 2 bytes starting from data[2]
memcpy(green,data+4,2); //copy 2 bytes starting from data[4]
if (blue !=Pblue) != 0) {
Serial.print("This is blue, it is an char and should contain 2 numbers:");
Serial.println(blue);
Fblue = atoi(blue);
Serial.print("This is Fblue, it is an int and should contain 2 numbers:");
Serial.println(Fblue);
analogWrite(ledPinB, Fblue);
// Pblue = Fblue incompatible types in assignment of 'int' to 'char [3]
strcpy (Pblue,blue);
Serial.println(Pblue);
}
mySwitch.resetAvailable();
Serial.println("Available is reseted");
}
}
and again AWOL, Brad Burleson and especially Tom Carpenter thank you so much!!