Show Posts
Pages: 1 ... 7 8 [9]
121  Using Arduino / Programming Questions / Re: Help understanding (char *). on: May 11, 2012, 06:49:26 am
Ok thanks. Can you tell me why it needs the brackets?

Many thanks.

Sorry just noticed its #define ECT "0105".
122  Using Arduino / Programming Questions / Help understanding (char *). on: May 11, 2012, 06:43:20 am
Hi all.

Can anyone explain to me why the (char *) has to be in brackets in this line of code.

Code:
ELM_Transmit((char *)ECT);

(ECT is #define ECT "0105"

Many thanks.
123  Using Arduino / Programming Questions / Re: Pass a value to a function from a function on: May 02, 2012, 05:20:17 pm
Code:

I want to use the value i pass to ELM_Read() i.e 2 that means i should have received 2 bytes of data back and 1 for 1 byte back as a way of checking and sorting the bytes of data into the correct places.

Thanks.
124  Using Arduino / Programming Questions / Re: Pass a value to a function from a function on: May 02, 2012, 05:11:28 pm
Many thanks for your replys.

Ok i see now but what if i want to replace the number 2 with a name like "rlengh"?

Thanks.
125  Using Arduino / Programming Questions / Re: Pass a value to a function from a function on: May 02, 2012, 04:21:43 pm
I might not have been clear enough lol. I have this block of code,

Code:
int getERPM()                                    //Engine RPM.
{
  int result;                                    //Variable to store calculation result.
  Serial.print(ENGINE_RPM);
  if (ELM_Read() == 1)                           //Calls the ELM_Read block.
  {
    result = ((Byte_AH * 256) + Byte_BH) / 4;    //Function calculation.
    return result;
  }
  return 0;
}

that is being called from my main loop. So inside this block i have,

Code:
if (ELM_Read() == 1)                           //Calls the ELM_Read block.
.

I want to pass the value of 2 to the ELM_Read() function. Is that possible?

Many thanks.
126  Using Arduino / Programming Questions / Pass a value to a function from a function on: May 02, 2012, 04:01:52 pm
As the title says, is it possible?

I have this line of code,

Code:
if (ELM_Read() == 1)                           //Calls the ELM_Read block.

so am returning a value from ELM_Read but i all so want to pass a vaule of 2 to the ELM_Read function todo some checks.

Each block that calls the ELM_Read function will be a little different so the value 2 may change to 1.

Thanks.
127  Using Arduino / Displays / Re: Powertip PC1602F -Warning :Doesnt seem to work under 4 bits, so not the best LCD on: April 10, 2012, 02:40:54 pm
I have a few of these LCD's and use them with no problem on the standard library with Arduino/4bit. The pins are in a different position to what some images show on here for other 16x2's but the Powertip datasheet helps with that.
128  Using Arduino / Programming Questions / Re: Help with strtoul() function. on: April 06, 2012, 06:40:45 am
Thanks for the replies an will have a look at them. From searching around i came up with the below, whould that not work do you think?

#define NULL '\0'

char serialrx[16];
char buffer[8];

void setup() {
  Serial.begin(9600);
  Serial.flush();
}

void loop() {
  byte i = 6;
  serialrx[6];                                                     //start conversion from the 6th byte
  while(serialrx != NULL)
  buffer[i++] = strtoul (serialrx, NULL, 16);
  i = 6;

}
129  Using Arduino / Programming Questions / Help with strtoul() function. on: April 06, 2012, 05:26:33 am
Hello all.

New to world of Arduino and as a electronic hardwear engineer this programing side is all new to me but learning fast thanks to the forums  smiley.

Ok, i would like to use the function strtoul() but i don't fully understand how to use it so would like your help in understanding how to use the function correctly.

I have a ASCII string for example,

"41 05 1C 7B" (received over the serial)

but i'm only interested in the "1C 7B" and would like to convert it to HEX to get something like "0x1C7B" stored to a unsigned long. So if anyone could show/explain this to me it will be a great help.

Look forward to your replies, thanks.
Pages: 1 ... 7 8 [9]