cleanup arduino directory
This commit is contained in:
parent
89e8eabde5
commit
086dba5856
@ -1,4 +0,0 @@
|
||||
ESP_ROOT = $(HOME)/esp8266
|
||||
BOARD = d1
|
||||
|
||||
include $(HOME)/makeEspArduino/makeEspArduino.mk
|
@ -1,118 +0,0 @@
|
||||
//libraries
|
||||
#include <ArduinoOSCWiFi.h>
|
||||
#include <Adafruit_MotorShield.h>
|
||||
|
||||
//motors
|
||||
const int C_HEAD = 1;
|
||||
const int C_FEED = 2;
|
||||
|
||||
int head_speed = 150;
|
||||
int feed_speed = 150;
|
||||
|
||||
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
|
||||
|
||||
Adafruit_DCMotor *headMotor = AFMS.getMotor(C_HEAD);
|
||||
Adafruit_DCMotor *feedMotor = AFMS.getMotor(C_FEED);
|
||||
|
||||
//OSCWiFi
|
||||
const char* ssid = "XPUB";
|
||||
const char* pwd = "5fff132d";
|
||||
const IPAddress esp_ip(192, 168, 1, 100);
|
||||
const IPAddress gateway(192, 168, 1, 1);
|
||||
const IPAddress subnet(255, 255, 255, 0);
|
||||
const String tidal = "192.168.1.202";
|
||||
const int recv_port = 7000;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, pwd);
|
||||
WiFi.config(esp_ip, gateway, subnet);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.print('.');
|
||||
delay(500);
|
||||
};
|
||||
|
||||
if (!AFMS.begin()) { // here for pwm
|
||||
Serial.println("Could not find Motor Shield. Check wiring.");
|
||||
while (1);
|
||||
};
|
||||
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected.");
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
Serial.print("ESP CPU Frequency in MHz: ");
|
||||
Serial.println(ESP.getCpuFreqMHz());
|
||||
|
||||
headMotor->setSpeed(head_speed);
|
||||
headMotor->run(RELEASE);
|
||||
feedMotor->setSpeed(feed_speed);
|
||||
feedMotor->run(RELEASE);
|
||||
|
||||
OscWiFi.subscribe(recv_port, "/stopall",
|
||||
[](const OscMessage& m) {
|
||||
feedMotor->run(RELEASE);
|
||||
headMotor->run(RELEASE);
|
||||
}
|
||||
);
|
||||
|
||||
OscWiFi.subscribe(recv_port, "/feed/direction",
|
||||
[&](const String& direction) {
|
||||
if (direction == "f" || direction == "forward" || direction == "forwards" || direction == "forth"){
|
||||
Serial.println("Feed motor direction: forward");
|
||||
feedMotor->run(FORWARD);
|
||||
} else if (direction == "b" || direction == "backward" || direction == "backwards" || direction == "back") {
|
||||
Serial.println("Feed motor direction: backward");
|
||||
feedMotor->run(BACKWARD);
|
||||
} else if (direction == "s" || direction == "stop" || direction == "r" || direction == "release" || direction == "rel") {
|
||||
Serial.println("Feed motor direction: release");
|
||||
feedMotor->run(RELEASE);
|
||||
} else {
|
||||
Serial.println("Don't know what to do with this OSC message.");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OscWiFi.subscribe(recv_port, "/feed/speed",
|
||||
[&](const int& speed) {
|
||||
feed_speed = speed;
|
||||
Serial.print("Feed motor speed: ");
|
||||
Serial.print(feed_speed);
|
||||
Serial.println();
|
||||
feedMotor->setSpeed(speed);
|
||||
}
|
||||
);
|
||||
|
||||
OscWiFi.subscribe(recv_port, "/head/direction",
|
||||
[&](const String& direction) {
|
||||
if (direction == "f" || direction == "forward" || direction == "forwards" || direction == "forth"){
|
||||
Serial.println("Head motor direction: forward");
|
||||
headMotor->run(FORWARD);
|
||||
} else if (direction == "b" || direction == "backward" || direction == "backwards" || direction == "back") {
|
||||
Serial.println("Head motor direction: backward");
|
||||
headMotor->run(BACKWARD);
|
||||
} else if (direction == "s" || direction == "stop" || direction == "r" || direction == "release" || direction == "rel") {
|
||||
Serial.println("Head motor direction: release");
|
||||
headMotor->run(RELEASE);
|
||||
} else {
|
||||
Serial.println("Don't know what to do with this OSC message.");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
OscWiFi.subscribe(recv_port, "/head/speed",
|
||||
[&](const int& speed) {
|
||||
head_speed = speed;
|
||||
Serial.print("Head motor speed: ");
|
||||
Serial.print(head_speed);
|
||||
Serial.println();
|
||||
headMotor->setSpeed(head_speed);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
OscWiFi.update();
|
||||
}
|
||||
|
15
arduino/secret.h
Normal file
15
arduino/secret.h
Normal file
@ -0,0 +1,15 @@
|
||||
#define VITRINE_SSID "Schuurneusiphone"
|
||||
#define VITRINE_WIFI_PASS "12345678"
|
||||
#define MQTT_ARDUINO_USERNAME "vitrinekast"
|
||||
#define MQTT_ARDUINO_PASS "cA8nngp8oNbG9Pxg"
|
||||
#define hasMotorshield false
|
||||
#define hasRelayShield true
|
||||
#define arduinoName "power-arduino"
|
||||
#define isESP true
|
||||
|
||||
// The digital pins on which your relay shield is connected.
|
||||
#define PIN_FAN1 1
|
||||
#define PIN_FAN2 2
|
||||
#define PIN_RADIO1 3
|
||||
#define PIN_LAMP1 4
|
||||
#define PIN_LAMP2 5
|
Loading…
Reference in New Issue
Block a user