I'v bin trying to making a heating auto heating system that turns the knob with a servo, I can change the var upload and it will change position but every time i try to set up commands thought serial I get nothing, not even printing the serial I just sent. I'v tried this over and over again in different variations and am starting to get sick of just having my arduino uno just hanging from my wall doing nothing. please help.
my code:
#include <Servo.h>
Servo officeHeat;
int heat40 = 800;
int heat45 = 950;
int heat50 = 1150;
int heat55 = 1325;
int heat60 = 1500;
int heat65 = 1700;
int heat70 = 1825;
int heat75 = 1975;
int heat80 = 2150;
int officeHeatSetTo = heat60;
void setup(){
Serial.begin(9600);
officeHeat.attach(9);
}
void loop(){
//check if serial is available
while(Serial.available() > 0){
//read serial and set var
int heatCommand = Serial.read();
//if the command is A then set heat to 65
if(heatCommand == 'A'){
officeHeatSetTo = heat65;
}
}
officeHeat.writeMicroseconds(officeHeatSetTo);
//tell computer the current set temp.
while(true){
if(officeHeatSetTo == 800){
Serial.println("40");
}
if(officeHeatSetTo == 950){
Serial.println("45");
}
if(officeHeatSetTo == 1150){
Serial.println("50");
}
if(officeHeatSetTo == 1325){
Serial.println("55");
}
if(officeHeatSetTo == 1500){
Serial.println("60");
}
if(officeHeatSetTo == 1700){
Serial.println("65");
}
if(officeHeatSetTo == 1825){
Serial.println("70");
}
if(officeHeatSetTo == 1975){
Serial.println("75");
}
if(officeHeatSetTo == 2150){
Serial.println("80");
}
delay(1000);
}
}