From 59591d7a2b490adab36ab29a332ddfc841114ebb Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Sat, 22 May 2021 14:24:09 -0400 Subject: [PATCH] updated burner controller changes made for new servo type --- ...oT_WiFi_copy.ino => burner-controller.ino} | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) rename Arduino/{AWS_IoT_WiFi_copy.ino => burner-controller.ino} (91%) diff --git a/Arduino/AWS_IoT_WiFi_copy.ino b/Arduino/burner-controller.ino similarity index 91% rename from Arduino/AWS_IoT_WiFi_copy.ino rename to Arduino/burner-controller.ino index 36eaf33..7f2503d 100644 --- a/Arduino/AWS_IoT_WiFi_copy.ino +++ b/Arduino/burner-controller.ino @@ -28,8 +28,6 @@ #include Servo myservo; // create a servo object -int angle = 0; // variable to hold the angle for the servo motor -int pos; int burner_status = 1; //assume on for safety float burner_range = 170.0; /////// Enter your sensitive data in arduino_secrets.h @@ -72,7 +70,7 @@ void setup() { // called when the MQTTClient receives a message mqttClient.onMessage(onMessageReceived); myservo.attach(5); // attaches the servo on pin 9 to the servo object - myservo.write(0); //set servo to starting position + myservo.write(179); //set servo to starting position burner_status = 0; //should be off now } @@ -179,16 +177,16 @@ void onMessageReceived(int messageSize) { Serial.println(); } void off(){ - myservo.write(0); + myservo.write(179); burner_status = 0; Serial.println("ALL CLEAR ALL CLEAR ALL CLEAR!!!"); } void ignite(){ if(!burner_status){ - myservo.write(burner_range); //full open to ignite space + myservo.write(10); //full open to ignite space delay(3000);//wait for ignition - myservo.write(burner_range-20.0);//bring back from ignite space to HIGH + myservo.write(20.0);//bring back from ignite space to HIGH burner_status = 1; Serial.println("BURNER IS ON BE CAREFUL!!!"); } @@ -196,13 +194,13 @@ void ignite(){ void set_to_percent(int percent){ //percent should be 0 to 100 aka 50% is 50 - float percent_f = percent/100.0; + float percent_f = 1.0 - percent/100.0; Serial.print("setting position to: "); - Serial.println(burner_range*percent_f); + Serial.println((int)(burner_range*percent_f)); if(!burner_status){ ignite(); } - myservo.write(burner_range * percent_f); //naivly assume range is 180 for now it's not actually 180 + myservo.write((int)(burner_range * percent_f)); //naivly assume range is 180 for now it's not actually 180 } void set_to_preset(String preset){ @@ -211,10 +209,10 @@ void set_to_preset(String preset){ Serial.println("Turning off"); off(); }else if(preset.equalsIgnoreCase("low")){ - set_to_percent(20); + set_to_percent(10); }else if(preset.equalsIgnoreCase("medium")){ - set_to_percent(50); + set_to_percent(35); }else if(preset.equalsIgnoreCase("high")){ - set_to_percent(90); + set_to_percent(60); } }