Page 1 of 1

I can't make the pid_speed work..

Unread postPosted:Wed Jan 15, 2014 3:10 am
by AleEscalanteH
hi stanley
i wrote this code but i doesn't work… and its only blink the led… after i want to print the speed in kph in some java program… i will very grateful if you can help me.. thanks
(the rpm pid works fine).


#include <Arduino.h>
#include <OBD.h>
#include <Wire.h>

COBD obd;

void setup()
{
  pinMode(13, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
 
  obd.begin();

  while (!obd.init()); 
}

void loop()
{
  int value;
  int vel;
 
    if (obd.read(PID_SPEED, kph)){
    digitalWrite(13, vel = 0 ? HIGH : LOW);
    digitalWrite(A0, vel >= 100 ? HIGH : LOW);
    }
  if (obd.read(PID_RPM, value)) {
    digitalWrite(A1, value > 900 ? HIGH : LOW);
  }
}

Re: I can't make the pid_speed work..

Unread postPosted:Wed Jan 15, 2014 5:07 pm
by AleEscalanteH
damm.... :(
well but whats wrong in the code.. the pid_speed don´t work

Re: I can't make the pid_speed work..

Unread postPosted:Thu Jan 16, 2014 12:46 am
by r0tor
if (obd.read(PID_SPEED, [b]kph[/b])){ digitalWrite(13, [b]vel[/b] = 0 ? HIGH : LOW); digitalWrite(A0, [b]vel[/b] >= 100 ? HIGH : LOW);


Gotta pick either kph or vel as your variable