RoboRemo Users' Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Wemos D1 and Motor Shield.

Go down

Wemos D1 and Motor Shield.  Empty Wemos D1 and Motor Shield.

Post by lxkev@hotmail.com Fri Sep 14, 2018 7:14 am

09.14.2018

Hello, First post here and fairly new to coding...

Using a Wemos D1 and a Wemos Motor Shield.

So I've put this together (with some help) this code, I want to change it from creating an access point to connecting to my home network.. Tried changing SSID and PW to the home network, but wemos doesn't receive anything.

Thanks in advance.


#include <WiFiClient.h>
#include <ESP8266WiFi.h>
#include "WEMOS_Motor.h"

int _speed = 25;
int led = 13;

// config:
const char *ssid = "test"; // You have to connect your phone to this Access Point
const char *pw = "test"; // and this is the password
IPAddress ip(192, 168, 0, Cool; // Part1 of the RoboRemo connection
IPAddress netmask(255, 255, 255, 0);
const int port = 1234; // Part2 of the RoboRemo connection => part 1+2 together => 192.168.0.1:1234

WiFiServer server(port);
WiFiClient client;

Motor M1(0x30,_MOTOR_A, 1000);//Motor A - Direction
Motor M2(0x30,_MOTOR_B, 1000);//Motor B - Propulsion


void setup() {

pinMode(led, OUTPUT);
//declare here the IO pins. Add more if necessary.

pinMode(BUILTIN_LED,OUTPUT); // builtin LED declaration Wemos MINI same as 2

for(int i=0; i<5;i++){ //builtin led flashes 5 times so you can control the operation
digitalWrite(BUILTIN_LED,HIGH);
delay(100);
digitalWrite(BUILTIN_LED,LOW);
delay(100);
}

Serial.begin(115200);

WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
WiFi.softAP(ssid, pw); // configure ssid and password for softAP

server.begin(); // start TCP server

Serial.println("ESP8266 RC receiver 1.1 powered by RoboRemo");
Serial.println((String)"SSID: " + ssid + " PASS: " + pw);
Serial.println((String)"RoboRemo app must connect to " + ip.toString() + ":" + port);
}

void loop() {
// continu lokong for client
if(!client.connected()) {
client = server.available();
return;
}

// If client connected
if(client.available()) {
Serial.println("connect client with code:"); //mesage to (Arduino) serial monitor
char c = (char)client.read(); // read char from client (RoboRemo app)
Serial.println(c);
//If Roboremo send 'A' then M1 on CW, with "1"
//RoboRemo can generate this characters with a button => "set press action" of "set release action".
//go left
if ( c=='A'){
M1.setmotor(_CW);
Serial.println("Going Left");
}
if (c=='1') {
M1.setmotor(_STOP);
}
//go right
if ( c=='B'){
M1.setmotor(_CCW);
Serial.println("Going Right");
}
if (c=='1') {
M1.setmotor(_STOP);
}
}




}

lxkev@hotmail.com

Posts : 1
Join date : 2018-09-13

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum