| Arduino Forum ::  Members :: Xenon69
 Show Posts Pages: [1] 2
 1 Using Arduino / Programming Questions / Re: HEX String to unsigned long on: March 15, 2013, 05:25:53 pm Perfect!!! Thank you "guix" !!That is that what i want! Looks so easy but i never would do this without your help!
 2 Using Arduino / Programming Questions / Re: HEX String to unsigned long on: March 15, 2013, 05:02:20 pm i just want 3 different hex values stick together and send as one code and in receiver i was split them again and asign to variablesTRANSMITTERvariable1 = 1;   //hex 1variable2 = 10; //hex Avariable3 = 12; //hex Ci want stick them together and send as0x1ACRECEIVERreceive = 1ACsplit this received code and asign to variable:variable1 = 1;  // hex 1variable2 = 10; // hex Avariable3 = 12; // hex C
 3 Using Arduino / Programming Questions / Re: HEX String to unsigned long on: March 15, 2013, 04:49:29 pm ok, now i understand about HEX, OCTAL, DEC ... but how i can string convert to unsigned long to make IR library understand that i wand send 0x1AC code?
 4 Using Arduino / Programming Questions / HEX String to unsigned long on: March 15, 2013, 04:40:54 pm I need to send hex string by IR but at firs i need to combine it from 3 variables. So i use string function to merge HEX (1+A+C= 1AC) but problem is that i can't to send string -----> irsend.sendSony(string, 12);  IRSend library need to send unsigned long or int. So then i need to convert string to unsigned long code but i don't know how Code:#include IRsend irsend; String stringOne; String stringTwo; String stringThree; String string;unsigned long code;void setup(){  Serial.begin(9600);}void loop() {    int Team = 1;     //in HEX = 1  int Player = 10;  //in HEX = A  int Weapon = 12;  //in HEX = C    stringOne =  String(Team, HEX);     //HEX = 1  stringTwo =  String(Player, HEX);   //HEX = A  stringThree =  String(Weapon, HEX); //HEX = C   string =  String(stringOne + stringTwo + stringThree); //1 + A + C = 1AC  Serial.println(string); // i get 1AC    //need convert it like this to send it, but i can't   code = string; //????????????    //Because "irsend.sendSony" accept just (unsigned long or int) i can't send string directly     irsend.sendSony(code, 12); // need to send it like this irsend.sendSony(0x1AC, 12);   delay(25);}
 5 Using Arduino / Programming Questions / Re: HEX Split on: March 11, 2013, 07:05:51 am BIG THANKS to Nick Gammon!Using Code which post Nick Gammon + I figure out how to use BUF and i get result by myself about what I all time asking from start of this post!!! Check this out!!!Code:void setup ()  {  Serial.begin (115200);  unsigned long hexString = 0x1FD3DC;  unsigned int buf[8];  int Variable0;  int Variable1;  int Variable2;  int Variable3;  int Variable4;  int Variable5;    for (byte i = 0; i < 8; i++)      {       byte nibble = hexString & 0xF;       (buf[i]) = nibble;           hexString >>= 4;       }          Variable0 = (buf[5]);    Variable1 = (buf[4]);    Variable2 = (buf[3]);    Variable3 = (buf[2]);    Variable4 = (buf[1]);    Variable5 = (buf[0]);        Serial.print("V0= ");    Serial.println (Variable0,HEX);    Serial.print("V1= ");    Serial.println (Variable1,HEX);    Serial.print("V2= ");    Serial.println (Variable2,HEX);    Serial.print("V3= ");    Serial.println (Variable3,HEX);    Serial.print("V4= ");    Serial.println (Variable4,HEX);    Serial.print("V5= ");    Serial.println (Variable5,HEX);      } void loop () { }
 6 Using Arduino / Programming Questions / Re: HEX Split on: March 11, 2013, 03:36:31 am Thank you for code! That is almost what i wantGreate is that it works. But it is not exactly what I want. Nibble just search an character in hex string, but i need to seperate every char as unique data    carrier.I will try to explain for what i want it. I using Infra red to send data using IrRemote library. I am trying to use it for Laser TagFor example sender is gun with IR, when gun shoot it send IR hex or dec string to another players receiver.That code what is sended, need contains data about in which team is that player, what is player number, what gun mode it use, ....for example 35AACF HEX code is sendedso in hex we know that hex 0x1 =1hex 0x2 =2...hex 0xE=14            hex 0xF=15(First Char)    ---> 3   (it will means in which team player is (0x3)third team)(Second Char) ---> 5   (it will means which player by number it is (0x5)fifth player)(Third Char)   ---> A   (it will means what gun it use - pistol which subtract (0x5) 5% of lives, or blaster who subtract(0xA) 10%)(Fourth Char) ---> A   (it will means - something else).....so on receiver i need to seperate the code for use it every char as uniqueexampleFirstChar = (First char of sended code 35AACF)SecondChar = (Second char of sended code 35AACF)ThirdChar = (Third char of sended code 35AACF)....if (SecondChar == 0x5)   then    add 1 score to player with number 5 and Show on display which player was kill me;if (ThirdChar == 0xA)   then    then it is blaster and subtract 10% lives from players lives;
 7 Using Arduino / Programming Questions / Re: sprintf() function on: March 10, 2013, 01:48:08 pm Variable can be integerActualy it is does not matter, I just would like that this code was work.
 8 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 01:42:19 pm PaulS - Seems the sprintf() function is that what i want, but i can't find no one good example! UKHeliBob  - Yes at this moment i just experimenting, and i have transmitting code. Where is conected 4 buttons and i can send 4 diferent codes with it.But my general what i need is to seperate receiver incoming data.For example if in transmitter i change first char, second char and third char (example - 486) then transmit it to receiverthen on receiver i need to seperate it and asign to variable.received code = 486asigning to variable Variable1 = (First character = 4)Variable2 = (Second character = Variable3 = (Third character = 6)Looks very simple but no one can help me, yet!
 9 Using Arduino / Programming Questions / sprintf() function on: March 10, 2013, 12:17:59 pm Someone can help with sprintf(); ?I need seperate numbers and asign them to Variables.Code:int number = 123456;void setup(){  Serial.begin(9600);}void loop(){int buff[5];sprintf(buff, "%.6u", testNumber);int Variable[5];Variable1 = buff[0];Variable2 = buff[1];Variable3 = buff[2];Variable4 = buff[3];Variable5 = buff[4];Variable6 = buff[5];Serial.println(Variable);}Can someone repair my code?
 10 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 10:50:14 am I wnat something like this but on Infra redhttp://www.pjrc.com/teensy/td_libs_VirtualWire.htmlIf it is send "Hello"Then it receive Hello but splitedusing buffor example if it will be a remote control car, where every character has something meaning. First sended char is changed tepend of joistic value 0-255 for speedIf joistic is at midl the value is 127, if full forward 255, if full backward then 0.Second sended char is changed tepend of joistic value 0-255 for steeringleft 0, midl 127, right 255then receiver need to receive every char seperately for control of speed by first char (forward speed and backwardspeed)Second char (Steering Left and steering right)Code:    if (vw_get_message(buf, &buflen)) // Non-blocking    { int i;        digitalWrite(13, true); // Flash a light to show received good message // Message with a good checksum received, dump it.// Serial.print("Got: "); for (i = 0; i < buflen; i++) {                  c = (buf[i]); }      joystic_y= (buf[0]);      joystic_x = (buf[1]);      light_1 = (buf[3]);I want the same but in IRRemote Idon't know how to make buf of my received char or dec or hex to asign it to Variable, this is my major problem.
 11 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 09:35:50 am My major wjat i need is split HEX to peacesfor example i receive  AC5D7A HEX codei need to asign every leter like uniqueSo, if i receive for example code AC5D7Athen i want use every peace of it seperatelyValue1 = A Value2 = CValue3 = 5Value4 = DValue5 = 7Value6 = Aok, it's doesn't metter or it is HEX or DECMay be i can use a DECif i receive 123976then asign this values as seperatedValue1 = 1 Value2 = 2Value3 = 3Value4 = 9Value5 = 7Value6 = 6
 12 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 09:16:53 am So i don't understand where i need to put thisuint8_t read_nibble(uint32_t data, uint8_t ix){  return ((data >> (ix * 4)) & 0xf);}may be you can stisk your solution with my code what i post? I would like all code sticked together not only peace of code. I am simply a newbie. May be there is some easier way without uint8 .... I think all that could be done with Array[] function, or may be i wronk?
 13 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 08:51:05 am I am not a very good programmer.Can you please show in my example where i need to put your solution?But i still doesn't understand how this will asign my HEX every char to Variable?May be you can place all code, please?
 14 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 07:55:05 am There is a code, it is IRRemoteThis example just turn on and off led if is received by IR right HEX and it is 0x111ABC in my exampleBut i would like to seperate this HEX to asign every character to variable for to do something with it1_Value = (firs hex number of my code      --> 1)2_Value = (second hex number of my code --> 1)3_Value = (third hex number of my code    --> 1)4_Value = (fourth hex number of my code  --> A)5_Value = (fifth hex number of my code    --> B)6_Value = (sixth hex number of my code   --> C)example what does do every value:if(1_Value == '1')  ----> turn ON the LEDif(1_Value == 'A')  ----> turn OFF the LED  ....if(6_Value == '1')  ----> turn ON the ...if(6_Value == 'A')  ----> turn OFF the ...Code:#include int RECV_PIN = 11;int OUTPUT_PIN = 13;IRrecv irrecv(RECV_PIN);decode_results results;void setup(){  Serial.begin(9600);  pinMode(OUTPUT_PIN, OUTPUT);  irrecv.enableIRIn(); // Start the receiver}int on = 0;unsigned long last = millis();void loop() {if (irrecv.decode(&results)) {  Serial.println(results.value, HEX);        if (results.value == 0x111ABC) {              if (millis() - last > 100) {        on = !on;        digitalWrite(OUTPUT_PIN, on ? HIGH : LOW);      }      last = millis();    }        irrecv.resume(); // Receive the next value  }}
 15 Using Arduino / Programming Questions / Re: HEX Split on: March 10, 2013, 07:08:33 am Because I want to do something depend from values.if i have HEX ----> 123ABCAsign each HEX number to valueString1 = '1'String2 = '2'String3 = '3'String4 = 'A'String5 = 'B'String6 = 'C'then i can use every sended HEX number to do somethingif(String1 == '1') -----> turn on a RED ledif(String1 == '2') -----> turn on a GREEN ledif(String1 == '3') -----> turn on a BLUE led.... if(String2 == '1')  ----> turn on a motor  if(String2 == '2')  ----> turn off a motor   if(String2 == '3')  ----> turn ..... ....
 Pages: [1] 2