Hi everybody,
I hope that's the right section of the forum to post my question.
Starting by saying that I'm a total newbie for what concerns programming, coding and electronics, I try to dive as much as I can in this (for me) new and interesting world.
I've started couple of months ago with the Arduino Starting Kit, which I find really helpful.
After completing Project 05 (Mood Cue), I tried to figure out how I could write a program that control and move the servo motor according to the temperatures measured by the sensor which come with the Starter Kit.
Below you'll find my guess - obviously wrong ![]()
I admit I was trying to figure out what's wrong there, but I could spot so many flaws and uncertainty that I really don't know where to start.
One of my main doubts is how to translate temperature's reading to servo output. I guess the function map() is missing something
#include <Servo.h>
Servo myServo;
int const Temp = A0;
const float baselineTemp = 19.0;
int angle;
void setup () {
myServo.attach(9);
Serial.begin(9600);
}
void loop () {
int sensorVal = analogRead(A0);
Temp = analogRead(Temp);
Serial.print("Temp: ");
Serial.print(A0);
float temperature = (voltage - .5) * 100; //conversion
Serial.println(temperature);
if(temperature < baselineTemp){
angle = map(potVal, 0, 1023, 0, 179);
myServo.write(angle);
Serial.print(", angle: ");
Serial.println(angle);
}else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
angle = map(potVal, 0, 1023, 0, 179);
myServo.write(angle);
Serial.print(", angle: ");
Serial.println(angle)
}else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
angle = map(potVal, 0, 1023, 0, 179);
myServo.write(angle);
Serial.print(", angle: ");
Serial.println(angle)
}else if(temperature >= baselineTemp+6){
angle = map(potVal, 0, 1023, 0, 179);
myServo.write(angle);
Serial.print(", angle: ");
Serial.println(angle)
}
delay(15);
}
Attached you can also find the schemes of the circuit - which i still didn't build but just design (apologize to all the experts here to have used "design" for such a basic sketch...)
Any help would be very much appreciated!
Thanks!

