Hello guys, I have a problem with Arduino IoT Cloud, i wanted to make a simple Servo controller but it doesnt really work.
First of, I am using a Arduino Nano Esp32 and the Servo is a 180° Servo motor and it only stays stays at 0 if it starts even if the Variable for controlling is at a different angle
Here is the Script that I am using
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/42e63d9c-89b3-4c25-877c-81a6aac0aba4
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int servo1;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <ESP32Servo.h>
Servo myservo1;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
myservo1.attach(13);
}
void loop() {
ArduinoCloud.update();
// Your code here
myservo1.write(servo1);
}
/*
Since Servo1 is READ_WRITE variable, onServo1Change() is
executed every time a new value is received from IoT Cloud.
*/
void onServo1Change() {
// Add your code here to act upon Servo1 change
}
Edit:
I managed now to find the issue, i didnt replaced these here, after i replaced them, they worked perfectly