#include #include #include #include const char * networkName = "SSID"; const char * networkPswd = "PASS"; const char * udpAddress = "192.168.1.76"; const int udpPort = 6000; SFEVL53L1X distanceSensor; WiFiUDP udp; boolean connected = false; #define MOTOR_PHASE_A 26 #define MOTOR_PHASE_B 25 #define MOTOR_PHASE_C 33 #define MOTOR_PHASE_D 32 #define HOMING_PIN 35 unsigned long starttime; unsigned long endtime; float rotationtime; int count = 0; int flag = 0; int circle = 2048 * 3.25; char *buffer1; char buffer2[20]; int distance; int angle; int step(); void setup() { Wire.begin(); if (distanceSensor.begin() == 0) //Begin returns 0 on a good init { Serial.println("Sensor online!"); } connectToWiFi(networkName, networkPswd); Serial2.begin(9600); Serial.begin(9600); Serial.println("Setup"); pinMode(MOTOR_PHASE_A, OUTPUT); pinMode(MOTOR_PHASE_B, OUTPUT); pinMode(MOTOR_PHASE_C, OUTPUT); pinMode(MOTOR_PHASE_D, OUTPUT); pinMode(HOMING_PIN, INPUT); starttime = millis(); buffer1 = (char*) malloc((sizeof(char) + sizeof(unsigned long)) * sizeof(char) + 1); while (digitalRead(HOMING_PIN) == HIGH)step(); while (digitalRead(HOMING_PIN) == LOW) { step(); } delay(2000); } void loop() { //if(count%circle==0)delay(5000); for(count=0;count