Show Posts
Pages: 1 [2] 3 4 ... 19
16  Using Arduino / Programming Questions / Re: How does define work? on: March 04, 2013, 06:41:22 am
thx a lot to all of you explaining me the problem and the difference among the const and define statement!!!

Andy
17  Using Arduino / Programming Questions / Re: How does define work? on: March 04, 2013, 05:44:37 am
wow thx a lot

so const is similair to define you still can't change the value after it is "defined" in the code?

Andy
18  Using Arduino / Programming Questions / How does define work? on: March 04, 2013, 05:13:18 am
Hy

I got a strange behaviour when I use this code:

Code:
#define alt  10000


void setup(){
  Serial.begin(115200);

  Serial.println(alt);

  if (55000 >= (alt * 100)){
    Serial.println("Yes");
  }
  else{
    Serial.println("no");
  }
}


void loop(){ }


Why Is the Output yes? Since 10000 * 100 is greater then 5500??

Whe I use following code it works:
Instead of *100 I use *100.


Code:
#define alt  10000


void setup(){
  Serial.begin(115200);

  Serial.println(alt);

  if (55000 >= (alt * 100.0)){
    Serial.println("Yes");
  }
  else{
    Serial.println("no");
  }
}


void loop(){ }



I don't get it!!

Andy
19  Using Arduino / Networking, Protocols, and Devices / Re: 3-wire Serial Configuration Interface on: December 12, 2012, 08:49:46 am
ok.. I have to look at this forst since I don't get right know...
Thx for the answers...
20  Using Arduino / Networking, Protocols, and Devices / Re: 3-wire Serial Configuration Interface on: December 12, 2012, 07:22:06 am
hmm but SPI looks like:


And this interface from the data sheet:
21  Using Arduino / Networking, Protocols, and Devices / 3-wire Serial Configuration Interface on: December 12, 2012, 05:05:21 am
Hy

I try to get the CC1050 working which is a little Very Low Power RF Transmitter.
I tried to set it up with the datasheet http://www.ti.com/lit/ds/swrs044/swrs044.pdf

On page 12 it is described but I haven't used yet this 3 wire serial interface. I'm used to
I2C, UART so could someone help me getting this chip to work...

I barely found any info about this interface so is it not that common?

Thx
Andy
22  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 25, 2012, 10:09:39 am
the value returned was wrong compared to what was expected there fore I wrote it doesn't work...
23  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 24, 2012, 11:29:28 am
wow you were right hmm this union thing is quite strong have to dig deeper what else it can deliver....

Thx
Andy
24  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 24, 2012, 05:41:58 am
Hi,
if you are trying to convert from byte array to long integer, simply use the union in the opposite way:

Code:
   Number Out;

   Out.barray[0] = b0;
   Out.barray[1] = b1;
   Out.barray[2] = b2;
   Out.barray[3] = b3;

   unsigned long val = Out.num

Wow thx the union thing worked just great!

Finally I do need to send float numbers separated in a 4 byte array with the IEEE-754 Standard.
Converting form the bytes to float was easy but the other way round seems harder...


25  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 11:15:51 am
so maybe 24 hmmmm smiley

But still no success or is it still wrong (24)?

26  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 10:59:20 am
Why do your buffer subscripts start at 1?

Since in the first ([0]) is the adress where the message came from...

is 1 << 0 not the same as pow(256,0).

Or how can I do it differently?
27  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 09:56:07 am
yes I tried bit shifts with:

Code:
  unsigned long b1 = buffer[1] * 1 << 32;
  unsigned long b2 = buffer[2] * 1 << 16;
  unsigned long b3 = buffer[3] * 1 << 8;
  unsigned long b4 = buffer[4] * 1 << 0;
  unsigned long val = b1 + b2 +b3 + b4;

but didn't worked therefore i switched to pow....
28  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 09:25:40 am
I don't recommend that you use "pow" for integer work.

So how do you suggest to decode a 32bit value?
29  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 08:50:18 am
It was suggested to add an 'L' behind my long number however it is also working without since I'm not
sure how I can add an 'L' behind a long variable....
30  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 08:42:12 am
hmmm

Code:
void in32bit(long number){


  union Number{
    long num;
    byte barray[4];
  }
  NN;

  NN.num = number;
  byte b0 = NN.barray[0];
  byte b1 = NN.barray[1];
  byte b2 = NN.barray[2];
  byte b3 = NN.barray[3];


  Serial.println(b3, DEC);
  Serial.println(b2, DEC);
  Serial.println(b1, DEC);
  Serial.println(b0, DEC);




  int buffer[5];
  buffer[1] = b3;
  buffer[2] = b2;
  buffer[3] = b1;
  buffer[4] = b0;

  unsigned long b11 = buffer[1] * long(pow(256,3));
  unsigned long b22 = buffer[2] * long(pow(256,2));
  unsigned long b33 = buffer[3] * long(pow(256,1));
  unsigned long b44 = buffer[4] * long(pow(256,0));
  unsigned long val = b11 + b22 +b33 + b44;
  Serial.println();
  Serial.println(val);
}

I got now this code.
Why is it working without an 'L'???

Pages: 1 [2] 3 4 ... 19