Hallo Leute,
ich möchte über die iOs App "iOt Remote" einen DC Motor steuern. Dafür habe ich den Driver BTS7960 und einen 24V Motor. Ich brauche nur 2 Pins für den Driver da der Motor nur in eine Richtung drehen soll. 1 Pin für enableMotor und 1 Pin für Speed. Ich habe in der Cloud nun alles soweit eingerichtet und ein Dashboard erstellt und den Code soweit angepasst. Ich habe keine Ahnung ob der Speed Pin funktioniert aber ich bekomme nicht mal den enablePin zum laufen. Egal ob an oder aus, es liegen 0V an dem Pin an. Vielleicht könnt ihr mir helfen das problem zu lösen.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/25f48493-76c7-493c-84e3-11d1bc3aa301
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int speed;
bool enableMotor;
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"
#define enableMotor 2
#define speed 4
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);
pinMode(enableMotor, OUTPUT);
pinMode(speed, OUTPUT);
// 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();
}
void loop() {
ArduinoCloud.update();
// Your code here
}
/*
Since EnableMotor is READ_WRITE variable, onEnableMotorChange() is
executed every time a new value is received from IoT Cloud.
*/
void onEnableMotorChange() {
// Add your code here to act upon EnableMotor change
}
/*
Since Speed is READ_WRITE variable, onSpeedChange() is
executed every time a new value is received from IoT Cloud.
*/
void onSpeedChange() {
// Add your code here to act upon Speed change
}
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char DEVICE_LOGIN_NAME[] = "aabd441e-152e-46ca-af58-dc8b2190edca";
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password
void onSpeedChange();
void onEnableMotorChange();
int speed;
bool enableMotor;
void initProperties(){
ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(speed, READWRITE, ON_CHANGE, onSpeedChange);
ArduinoCloud.addProperty(enableMotor, READWRITE, ON_CHANGE, onEnableMotorChange);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);