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, 2013http://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 durationreturn (_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