Halo project compile errors

Hi everyone. I joined this forum today. I am working on Halo project at instrucatables.com

The ultrasonic sensor on this subject has 3 pins. Mine are 4 pins.

1- Vcc
2-Trigger
3-Echo
4-GND

Therefore i changed some codes. Even the project writer send me some new code. But i encountred many errors. I fixed mostly. But i cant 2 errors. I couldnt add all codes caused of 9500 characters limit.

Errors:

Ping3.cpp:46: error: expected initializer before 'Ping3'
Ping3.cpp:56: error: function definition does not declare parameters

ping3.cpp:

/*

Hacking up to make US-100 like Parallax ping))) library
Steve Struebing
Steve@polymythic.com
Jan 26, 2013

http://www.e-gizmo.com/KIT/images/gizDuino%20X/gizDuino%20X%20hardware%20manual.pdf

http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic%20sonar%20module%201r0.pdf

Ping3.cpp - Library for using Ping2))) Sensors with Arduino - Version 2
Copyright (c) 2009 Caleb Zulawski. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "Arduino.h"
#include "Ping3.h"

Ping3::Ping3(int triggerPin, int echoPin)
{
pinMode(triggerPin , OUTPUT);
pinMode(echoPin, INPUT);

_triggerPin = triggerPin;
_echoPin = echoPin;
_in = 0;
_cm = 0;
_duration = -1;
}

Ping3:: Ping3(int triggerPin, int echoPin)
Ping3:: Ping3(int pin, double in, double cm)

{
pinMode(pin, OUTPUT);
_pin = pin;
_in = in;
_cm = cm;
_duration = -1;
}

void Ping3:fire()
{
// Trigger US-100 to start measurement

// Set up trigger
digitalWrite(triggerPin,LOW);
delayMicroseconds(5);

// Start Measurement
digitalWrite(triggerPin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin,LOW);

// Acquire and convert to mtrs
_m_distance=pulseIn(echoPin,HIGH);
_m_distance=distance*0.0001

}

int Ping3::microseconds()
{
// Run the math backwards to generate what would have
// been the parallax duration

return (_m_distance *2 * (29 + _cm));
}

double Ping3::inches()
{
// We're native meters, so do the conversion
return (_m_distance /100) * 0.3937;

}

double Ping3::centimeters()
{
return (_m_distance /100);
}

ping3.h

/*
 Ping 3 library.  Hacking up to make equivalent to Caleb's Ping library.
Steve Struebing
Steve@polymythic.com
Jan 26, 2013

 Ping2.cpp - Library for using Ping2))) Sensors with Arduino - Version 2
 Copyright (c) 2009 Caleb Zulawski.  All right reserved.
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#ifndef Ping3_h
#define Ping3_h

#include "Arduino.h"

class Ping3
{
  public:
    Ping3(int triggerPin, int echoPin);
    Ping3(int pin, double in, double cm);
    void fire();
    int microseconds();
    double inches();
    double centimeters();
    int triggerPin;
    int echoPin;
    int distance;
    
  private:
    int _triggerPin;
    int _echoPin;
    double _in;
    double _cm;
    long _duration;
    long _m_distance;
};

#endif

I cant add here caused of 9500 characters limit,

Mainsketch : Microsoft OneDrive

Appreciate for helping

You have an extra line in there for no reason, after the definition of the first function in your file.
Remove it

michinyon:
You have an extra line in there for no reason, after the definition of the first function in your file.
Remove it

Thanks michinyon.. Which? I couldt find.

#include <Ping3.h>
#include <Ping3.h> // Modified library for the UT-100
//#include <Ping.h>

// ****************************************** 
// CALIBRATION VARIABLES
// INTERPULSE_LANTENCY (milliseconds) - Defines the period of time between when one ping
// fires and the next fires.  This should allow for the sound to travel to
// its furthest detectable echo distance so that the next sensors RX will not
// pick up splash from the previous ping's TX.  This may/will result in 
// a lower than real distance result from the next sensor.
#define INTERPULSE_LATENCY_DURATION 25

// MOTOR_PULSE_DURATION (milliseconds) - Defines the duration that the motor will pulse
// This is a constant at the moment, and the MOTOR_VIBRATION_FACTOR will
// shorte between the pulses of the motor
#define MOTOR_PULSE_DURATION 250

// RESCHEDULE_THRESHOLD_CONSTANT - Note: This may be replaced by "debouncing?" the motor
// This is the threshold over which the distance is large enough to trigger a 
// reschedule event.  If too small, there may be a lot of rescheduling, and if
// it is too large, then there may not be enough granularity.
#define RESCHEDULE_THRESHOLD_CONSTANT 20.83

// MAXIMUM_DISTANCE_CONSTANT (inches) - This is is the range over which we will
// not schedule any events.  If the range is greater than this value, we will not even
// bother with it.
#define MAXIMUM_DISTANCE_CONSTANT 48

//#define INTENSITY_STEP 63

// MOTOR_DISTANCE_GAP_FACTOR (millis per inch) - 1000 milis / MAXIMUM_DISTANCE_CONSTANT = milis per inch
// NOTE: This is an important constant.  If the value is too low, then 
// the motors will constantly be firing and rescheduling the next start
// which may elapse before any motor stop happens.  This will result
// in always on motors.
// This was calculated at distance of 48 inches (1000 / 48)
// @todo- this should be derived from the MAXIMUM_DISTANCE_CONSTANT
//#define MOTOR_DISTANCE_GAP_FACTOR 20.83
#define MOTOR_DISTANCE_GAP_FACTOR 250

#define MAX_GAP ((MAXIMUM_DISTANCE_CONSTANT/12) * MOTOR_DISTANCE_GAP_FACTOR)

// PING_MS_DELAY - THIS HAS BEEN MOVED INTO THE PING2 LIBRARY
// Note: This caused some debugging because the pulseIn() command used in the normal
// library defaults to 1 second.  This is way outside what we can handle.  According
// to the PING)) datasheet, the maximum time to wait (tIN_MAX) == 115us.  We will use
// 150 just for some buffer.
//#define PING_MS_DELAY 150

// ****************************************** 
// INPUT PINS - This sketch is set up for a 4 pin 
// ultrasonic rangefinder
// http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic%20sonar%20module%201r0.pdf

// - PING Input Sensors 
#define INPUT_LEFT_SENSOR_TRIGGER_PIN         30
#define INPUT_LEFT_SENSOR_ECHO_PIN            31

#define INPUT_LEFT_CENTER_SENSOR_TRIGGER_PIN  32
#define INPUT_LEFT_CENTER_SENSOR_ECHO_PIN     33

#define INPUT_CENTER_SENSOR_TRIGGER_PIN              34
#define INPUT_CENTER_SENSOR_ECHO_PIN                 35

#define INPUT_RIGHT_CENTER_SENSOR_TRIGGER_PIN        36
#define INPUT_RIGHT_CENTER_SENSOR_ECHO_PIN           37

#define INPUT_RIGHT_SENSOR_TRIGGER_PIN                38
#define INPUT_RIGHT_SENSOR_ECHO_PIN                39


// Enumeration for sensor input array
enum sensor_input {
  left_sensor,
  left_center_sensor,
  center_sensor,
  right_center_sensor,
  right_sensor,
  max_sensor_index
};

// ****************************************** 
// OUTPUT PINS
// - MOTOR Output Pins (PWM)
#define OUTPUT_LEFT_MOTOR_PIN         12
#define OUTPUT_LEFT_CENTER_MOTOR_PIN  11         
#define OUTPUT_CENTER_MOTOR_PIN       10
#define OUTPUT_RIGHT_CENTER_MOTOR_PIN 9
#define OUTPUT_RIGHT_MOTOR_PIN        8
#define OUTPUT_DEBUG_PIN              13
/*
// - DEBUG Output Pin (LED)
#define OUTPUT_CENTER_MOTOR_PIN       13
*/
// Enumeration for motor output array
enum motor_output {
  left_motor,
  left_center_motor,
  center_motor,
  right_center_motor,
  right_motor,
  max_motor_index
};

This doesn't look good:

Ping3:: Ping3(int triggerPin, int echoPin)
Ping3:: Ping3(int pin, double in, double cm)

As michinyon said, remove the first one.

wildbill:
This doesn't look good:

Ping3:: Ping3(int triggerPin, int echoPin)

Ping3:: Ping3(int pin, double in, double cm)





As michinyon said, remove the first one.

Thanks wildbill , I did. These errors appeared:

Ping3.cpp: In constructor 'Ping3::Ping3(int, double, double)':
Ping3.cpp:48: error: '_pin' was not declared in this scope
Ping3.cpp: At global scope:
Ping3.cpp:54: error: function definition does not declare parameters

I add " int _pin; " to ping3.h . Now one error:

Ping3.cpp:54: error: function definition does not declare parameters

Guessing.. try:

void Ping3:fire(void)

wildbill:
Guessing.. try:

void Ping3:fire(void)
Unfortunately it didnt fix..

same error

Oops. There's a colon missing.

Sorry, i am newby.. What is colon error?

This:

void Ping3:fire()

should be this:

void Ping3::fire()

Unfortunately. Error:

Ping3.cpp: In member function 'void Ping3::fire()':
Ping3.cpp:71: error: expected `;' before '}' token
  _m_distance=pulseIn(echoPin,HIGH);
  _m_distance=distance*0.0001
 
}

Well, well. What do you know. The compiler is right. A ; IS expected before the }.

PaulS:

  _m_distance=pulseIn(echoPin,HIGH);

_m_distance=distance*0.0001

}



Well, well. What do you know. The compiler is right. A ; IS expected before the }.

Thanks..

if i edit such below:

// Acquire and convert to mtrs

_m_distance=pulseIn(echoPin,HIGH);
_m_distance=distance*0.0001;

}

It gives many errors..

It gives many errors..

Well, give them back. Or give them to us. Quit hogging them.

Thanks Paul. But i cant understand clearly.. Please be more clear... I turned back.. Do you know that, what can do?

void Ping3:fire()
{
  // Trigger US-100 to start measurement

  // Set up trigger
  digitalWrite(triggerPin,LOW);
  delayMicroseconds(5);

  // Start Measurement
  digitalWrite(triggerPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin,LOW);

  // Acquire and convert to mtrs
  _m_distance=distance*0.0001
  _m_distance=pulseIn(echoPin,HIGH);

}

Error:

Ping3.cpp:54: error: function definition does not declare parameters

Like simple error, but i am triying fix it for 1 week...

  // Acquire and convert to mtrs
  _m_distance=distance*0.0001
  _m_distance=pulseIn(echoPin,HIGH);

The first line after the comment still needs a semicolon on the end.

I'm not sure what you are trying to do. You are assigning a value to _m_distance and then assigning another new value to it. The first line is going to accomplish nothing.

Look back at reply #9. The fact that you found additional errors after fixing it doesn't invalidate the fix.

Thanks Paul and WildBill.. I can't do. I will continue trying... If you want look the attach...

sketch_apr06a.rar (6.76 KB)

I downloaded your rar file, and extracted the three files from it. I put them is a folder called HALO, and renamed the sketch to HALO.ino. The IDE didn't like your name.

I changed the include statement to "Ping3.h" (was <Ping3.h>) because I have the Ping3 library in the sketch folder.

I added the ; to the line that is missing one, which you were told to fix.
I changed Ping3:fire() to Ping3::fire(), which you were told to do.

I clicked Verify, and got just one "error" message:

Binary sketch size: 7,528 bytes (of a 30,720 byte maximum)

I can't do.

You could have done the same things.