Hi!
I'm working on a project with a friend installing ultrasonic sensors into a shoe while using vibrating motors to alert the wearer of an obstacle. I'm experiencing an error message and I cannot seem to correct it. Please forgive my ignorance.... Im a bit of a nube at this...
Here is my program:
/*
//pin which triggers ultrasonic sound
const int pingPin = 17;
//pin which delivers time to receive echo using pulseIn()
int inPin = 19;
//range in cm which is considered safe to enter, anything
//coming within less than 31 cm triggers red LED
int safeZone = 7;
//LED pin numbers
int greenLed = 16;
int vibrator2=5;
int vibrator=11;
void setup() {
// initialize serial communication
Serial.begin(9600);
}
void loop()
{
//raw duration in milliseconds, cm is the
//converted amount into a distance
long duration, cm;
//initializing the pin states
pinMode(pingPin, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(vibrator2, OUTPUT);
pinMode(vibrator,OUTPUT);
//sending the signal, starting with LOW for a clean signal
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
//setting up the input pin, and receiving the duration in
//microseconds for the sound to bounce off the object infront
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);
// convert the time into a distance
cm = microsecondsToCentimeters(duration);
//printing the current readings to ther serial display
Serial.print(cm);
Serial.print("cm");
Serial.println();
//checking if anything is within the safezone, if not, keep
//green LED on if safezone violated, activate red LED instead
if (cm > safeZone)
{
digitalWrite(greenLed, LOW);
digitalWrite(vibrator2, LOW);
digitalWrite(vibrator, LOW);
}
else
{
digitalWrite(greenLed, HIGH);
digitalWrite(vibrator2, HIGH);
digitalWrite(vibrator, HIGH);
}
delay(1000);
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
*/
The error message I'm getting is:
core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'
Thanks a lot for any help!
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.