Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 9
61  Using Arduino / Project Guidance / Re: Control Remote Control Car with Arduino on: September 11, 2012, 01:54:43 am
Use a multimeter on continuity mode, one probe on the first wire you soldered to the board and the other probe on a ground point and see if the meter beeps. If not do that again for the other wire. Also maybe look on the pcb and see if you can work out where the copper tracks go.

Maybe you should have a look on google to see how switches can be used in circuits. You will probably find that one end of the switch is common to the rest of the switches.

Basically you should only need to solder one wire to the switch position for the Arduino not two.
62  Using Arduino / LEDs and Multiplexing / Re: Status LED function needed on: September 10, 2012, 03:45:46 pm
And here is the sketch that the flash rate can be changed for different function calls.
Code:
//Define pin names.
#define pin_Heartbeat_LED     13

//Setup globle variables.
byte HeartbeatLED = LOW;
int Interval = 500;
long HeartbeatOldMillis = 0;

void setup()
{
//Setup pin states.
pinMode(pin_Heartbeat_LED, OUTPUT);
}

void loop()
{
  Heartbeat(Interval);
}

//Heartbeat to show program is alive.
void Heartbeat(int Interval)
{
  long HeartbeatNewMillis = millis();
  if(HeartbeatNewMillis - HeartbeatOldMillis > Interval)
  {
    HeartbeatOldMillis = HeartbeatNewMillis;
    if(HeartbeatLED == LOW)
    {
      HeartbeatLED = HIGH;
    }
    else
    {
      HeartbeatLED = LOW;
    }
    digitalWrite(pin_Heartbeat_LED, HeartbeatLED);
  }
}
just change the interval time at the top of the scetch. Hope it useful.
63  Using Arduino / Programming Questions / Re: (SOLVED)Can any one help? on: September 10, 2012, 03:38:53 pm
It definitely is. I have a fully functioning sketch that reads serial data (from STN1110 OBD IC) and handles all errors that may happen so my sketch should never lock up and to top it of i learned something new smiley.
64  Using Arduino / LEDs and Multiplexing / Re: Status LED function needed on: September 10, 2012, 03:32:25 pm
This is my way and works great.
Code:
//Define pin names.
#define pin_Heartbeat_LED     13

//Setup globle variables.
byte HeartbeatLED = LOW;
long HeartbeatOldMillis = 0;

void setup()
{
//Setup pin states.
pinMode(pin_Heartbeat_LED, OUTPUT);
}

void loop()
{
  Heartbeat();
}

//Heartbeat to show program is alive.
void Heartbeat()
{
  long HeartbeatNewMillis = millis();
  if(HeartbeatNewMillis - HeartbeatOldMillis > 500)
  {
    HeartbeatOldMillis = HeartbeatNewMillis;
    if(HeartbeatLED == LOW)
    {
      HeartbeatLED = HIGH;
    }
    else
    {
      HeartbeatLED = LOW;
    }
    digitalWrite(pin_Heartbeat_LED, HeartbeatLED);
  }
}

If you want different flash rates then juat creat anouther globle variable for the high/low time and send the time to the fuction to replace to 500. Simple and will not lock up your sketch.
65  Using Arduino / Project Guidance / Re: Control Remote Control Car with Arduino on: September 10, 2012, 03:14:23 pm
That all depends on how the switch is used in the remote. Is one end of the switch being pulled to ground? Or is one end being pulled up to +volts?
66  Using Arduino / Programming Questions / Re: (SOLVED)Can any one help? on: September 10, 2012, 03:03:59 pm
My sketech is all working as i wanted it too now so many thanks to you all for the help.
67  Using Arduino / Programming Questions / Re: Can any one help? on: September 10, 2012, 10:46:26 am
Great, thanks alot for the guidance.
68  Using Arduino / Programming Questions / Re: Can any one help? on: September 10, 2012, 10:30:20 am
Think i get it now. I was under the impression that a 16byte array is 1 to 16 but it's not, it's 0 to 15 so the when the counter gets to 16 (as in my code) no such element exists so problems happen. Is this correct?
69  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 03:29:38 pm
Yes i can see that is the problem now but the way that am understanding it is that is that a string of 1234567891234567> the last 7 is placed into the 15th element then incremented to the 16th element (NULL is placed into that) and then the if stament of if(i == 16) should exit the loop and byte i goes back to 0 when the functhion is called again so at the min i can't see that "i" gets to the 17th. Hope you understand me. My understanding must be wrong.
70  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 02:45:41 pm
Ok i have better results now with strings under 16 bytes long but still can't work out what is going on when i type 1234567891234567> in the serial monitor. The sketch reboots with the code below. I thought that if i gets to 16 then the function is meant to exit with that if statment. Can you tell me what is going wrong? Am i correct in thinking that the last number in the string is placed into buffer location 16> Thank you.
Code:
//Reads data from the ELM IC.
//For example 41 0C 7B 7B>.
byte STN_Read(char *str)
{
  byte i = 0;
  char temp;
  
  while((temp = Serial.read()) != '>')
  {
    if(temp >= ' ' && temp <= '~')
    {
      str[i++] = temp;
      str[i] = '\0';
    }
    if(i == 16)
    {
      return 0;
    }
  }
  return 1; //Read is probably good.
}
71  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 02:33:19 pm
Thanks PaulS and yes i am. Am still learning how functions work but unfortunately it doesn't come over night. I will give that a try and see how i get on.
72  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 01:00:58 pm
Does anyone know a better way to collect data with error handling for what am trying to do?
Code:
//Reads data from the ELM IC.
//For example 41 0C 7B 7B>.
byte STN_Read(char *str)
{
  byte i = 0;
  char temp;
 
  while((temp = Serial.read()) != '>')
  {
    if(temp >= ' ' && temp <= '~')
    {
      str[i++] = temp;
    }
    if(i == 16)
    {
      return 0;
    }
  }
  str[i] = '\0';
  return 1; //No data to read or buffer full.
}

Am wanting it to terminate the read when the 16 byte buffer gets full if no '>' is found and then flush out out anydata remaining before it starts again.
73  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 06:45:48 am
I thought that 16th byte would be replaced with the null or am i wrong?
74  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 06:09:12 am
Yes thank you. The code below stops the skectch from crashing but when i type in the serial monitor 123456789123456789> (longer then 16 bytes) i then got the sketch to print out what it just received in the str and i get this 1234567891234567** (the * is garbage) but i think this tells me the code is still putting more then 16 bytes in the buffer.

Code:
//Reads data from the ELM IC.
//For example 41 0C 7B 7B>.
byte STN_Read(char *str)
{
  byte i = 0;
  char temp;
 
  while((temp = Serial.read()) != '>')
  {
    if(temp >= ' ' && temp <= '~')
    {
      Serial.println(i);
      Serial.println(temp);
      str[i++] = temp;
    }
    if(i == 16)
    {
      return 0;
    }
  }
  str[i] = '\0';
  return 1; //No data to read or buffer full.
}
75  Using Arduino / Programming Questions / Re: Can any one help? on: September 09, 2012, 05:49:44 am
Thats what am thinking. Am thinking that the code is putting more then 16 bytes in the str_rx buffer but am trying to get the code to only put 16 bytes in the buffer.
Pages: 1 ... 3 4 [5] 6 7 ... 9