Temperature sensors with rgb led question.

I've been having the same error for a while and I need help with this code. Its purpose is to move a small car while using a temperature sensor to detect the temperature, which then shows on the serial monitor and there is an Rgb led that changes when the temperature changes. I am doing this on an Arduino nano and a small breadboard. If anyone can help me, that would be great!

#define LEDPin 2
#define PushButtonPin 5
#define motorDirectionPinX 3
#define motorDirectionPinY 4
#define motorSpeedControlPin 11
#define servoPin 9
#define servoStraight 90
#define servoRight 65
#define servoLeft 115
#define TempPin 7

const int RED_PIN = 9;
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;
const int temperaturePin = 0;

#include <Servo.h>
Servo TurnServo;

void setup() {
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
pinMode(PushButtonPin, INPUT);
pinMode(motorDirectionPinX, OUTPUT);
pinMode(motorDirectionPinY, OUTPUT);
pinMode(motorSpeedControlPin, OUTPUT);
TurnServo.attach(servoPin);
digitalWrite(motorSpeedControlPin, LOW);
TurnServo.write(servoLeft);
delay(1);
TurnServo.write(servoRight);
delay(800);
TurnServo.write(servoStraight);
}

void loop() {

float voltage, degreesC, degreesF;//get numbers with decimals
voltage = analogRead(TempPin) * 0.004882814;
float getVoltage(int pin);

voltage = getVoltage(temperaturePin);//get voltage from the temperature pin
degreesC = (voltage - 0.5) * 100.0;//calculate the celcius degree
degreesF = degreesC * (9.0/5.0) + 32.0;// calculate the Fahrenheit degree

Serial.print("voltage: ");//print volrage in serial monitor
Serial.print(voltage);
Serial.print(" deg C: ");//print the celcious degree in serial monitor
Serial.print(degreesC);
Serial.print(" deg F: ");//print the farenheit degree in serial monitor
Serial.println(degreesF);

delay(1000);

if (degreesC < 16) {
digitalWrite(BLUE_PIN, HIGH);
} else if (degreesC < 20) {
digitalWrite (GREEN_PIN, HIGH);
} else if (degreesC < 24) {
digitalWrite (BLUE_PIN, LOW);
} else if (degreesC < 28) {
digitalWrite (RED_PIN, HIGH);
} else if (degreesC < 31) {
digitalWrite (BLUE_PIN, HIGH);
digitalWrite (GREEN_PIN, LOW);
digitalWrite (RED_PIN, HIGH);
} else {
digitalWrite (BLUE_PIN, LOW);

}

int sensor = analogRead(A2);

float tempC = (voltage - .5) * 100;
float tempF = (tempC * 1.8) + 32;

voltage = analogRead(TempPin) * 0.004882814;
degreesC = (voltage - 0.5) * 100.0;
degreesF = degreesC * (9.0/5.0) +32.0;
Serial.print("Voltage =");
Serial.print(voltage);
Serial.print(" DegreesC =");
Serial.print(degreesC);
Serial.print(" DegreesF =");
Serial.println(degreesF);

delay(500);

int PushButtonState;
#define motorSpeed 225
#define motorturnTime 2000
#define startFinishTime 500

PushButtonState = digitalRead(PushButtonPin);
Serial.print("Push Button Value = ");
Serial.println(PushButtonState);
delay(50);

if (PushButtonState == LOW)
{
digitalWrite(LEDPin, HIGH);
delay(startFinishTime);

//Set motor Direction forward
digitalWrite(motorDirectionPinX, HIGH);
digitalWrite(motorDirectionPinY, LOW);

analogWrite(motorSpeedControlPin, motorSpeed);
TurnServo.write(servoStraight);
delay(motorturnTime);

TurnServo.write(servoLeft);
delay(motorturnTime);

TurnServo.write(servoRight);
delay(motorturnTime);

TurnServo.write(servoLeft);
delay(motorturnTime);

TurnServo.write(servoStraight);
delay(motorturnTime);

digitalWrite(motorSpeedControlPin, LOW);
delay(startFinishTime);
digitalWrite(LEDPin, LOW);
}
}

Please edit your post to add code tags, as described in the "How to use this forum" post.

Please explain what you expect to happen, and what happens instead.

For starters, pins 9 and 11 each seem to be wired to 2 different things:

#define motorSpeedControlPin 11
const int BLUE_PIN = 11;

//and

#define servoPin 9
const int RED_PIN = 9;

.... so the wiring diagram would be interesting to see.

It seems that you're trying to cobble two (or more) existing sketches together?

I've been having the same error for a while

What is your error?

I'm getting this compile error.

undefined reference to `getVoltage(int)'

This line here:

 voltage = getVoltage(temperaturePin);//get voltage from the temperature pin

.... requires there to be a function called getVoltage, taking temperaturePin as its input.

Perhaps that's what the line above that one:

 float getVoltage(int pin);

... is trying to be?

Maybe look again at the sketches you're trying to join together, and there may be such a function in one of them?


jremington:
Please edit your post to add code tags, as described in the "How to use this forum" post.

Please explain what you expect to happen, and what happens instead.

All that seen in the code with no tags and without the originator telling us anything. Just goes to show.

moireekoni:
All that seen in the code with no tags and without the originator telling us anything. Just goes to show.

You're clearly new here.

Most of the regulars are not going to waste their time doing other people's homework. So we don't. OP obviously didn't even bother to read the forum sticky!