Arduino mega with wifi built in

hi all
this is sooo emergency help
i have this Arduino
image
i dont now how to use wifi with and how to uploude my sketch to use wifi with it please help me
any sorses

It looks like you have Arduino - Web Server (Mega 2560 R3 built-in ESP8266). Would that be correct?

Next, if you want good help I suggest you take the time to read the forum guidelines. You have not described your project or provided any useable information. Post what code, using code tags, you have already developed and describe in detail what your goal is.

The provided link shows how to use the dip switches and gives you an overview.

Ron

You should also download and install the Arduino IDE. You can then connect the Mega to a USB port on your computer and the IDE should recognize it and some the LEDs may light and others blink. While you are doing this the best read for you would be the Arduino Cookbook, much better then the many good tutorials online.

after you make the WiFiEspAT library work with the tutorial linked above, you can try my ArduinoOTA library

yes you have all right
this is my first time to use this yes it is Arduino - Web Server (Mega 2560 R3 built-in ESP8266)
i am trying to control a four whell car for old pesrson so i chose this code

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

//SSID and Password to your ESP Access Point
const char* ssid = "Robot Wifi";
const char* password = "87654321";

#define ENA   4     // Enable/speed motors Right    GPIO4(D2)
#define IN_1  0     // L298N in1 motors Right       GPIO0(D3)
#define IN_2  2     // L298N in2 motors Right       GPIO2(D4)
#define IN_3  12    // L298N in3 motors Left        GPIO12(D6)
#define IN_4  13    // L298N in4 motors Left        GPIO13(D7)
#define ENB   15    // Enable/speed motors Left     GPIO15(D8)

#define Light  16 // Light  GPIO16(D0)

String command;             //String to store app command state.
int speedCar = 150; // 0 to 255
int speed_low = 60;

ESP8266WebServer server(80);

void setup() {
 
  Serial.begin(115200);

 pinMode(ENA, OUTPUT); 
 pinMode(IN_1, OUTPUT);
 pinMode(IN_2, OUTPUT);
 pinMode(IN_3, OUTPUT);
 pinMode(IN_4, OUTPUT);
 pinMode(ENB, OUTPUT); 

 pinMode(Light, OUTPUT); 
 
  
// Connecting WiFi

  WiFi.mode(WIFI_AP);           //Only Access point
  WiFi.softAP(ssid, password);  //Start HOTspot removing password will disable security

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
 
 // Starting WEB-server 
     server.on ( "/", HTTP_handleRoot );
     server.onNotFound ( HTTP_handleRoot );
     server.begin();    
}

void loop() {
    server.handleClient();
    
      command = server.arg("State");
           if (command == "F") goForword();
      else if (command == "B") goBack();
      else if (command == "L") goLeft();
      else if (command == "R") goRight();
      else if (command == "0") speedCar = 100;
      else if (command == "1") speedCar = 120;
      else if (command == "2") speedCar = 140;
      else if (command == "3") speedCar = 160;
      else if (command == "4") speedCar = 180;
      else if (command == "5") speedCar = 200;
      else if (command == "6") speedCar = 215;
      else if (command == "7") speedCar = 230;
      else if (command == "8") speedCar = 240;
      else if (command == "9") speedCar = 255;
      else if (command == "S") stopRobot();
}

void HTTP_handleRoot(void) {

if( server.hasArg("State") ){
       Serial.println(server.arg("State"));
  }
  server.send ( 200, "text/html", "" );
  delay(1);
}

void goForword(){ 

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
  }

void goBack(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goRight(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
  }

void goLeft(){

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goForwordRight(){
      
      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar-speed_low);
 
      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar);
   }

void goForwordLeft(){
      
      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(ENB, speedCar-speed_low);
  }

void goBackRight(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar-speed_low);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
  }

void goBackLeft(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar-speed_low);
  }

void stopRobot(){  

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, LOW);
      analogWrite(ENA, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, LOW);
      analogWrite(ENB, speedCar);
 }
// else if (command == "I") goForwordRight();
//      else if (command == "G") goForwordLeft();
//      else if (command == "J") goBackRight();
//      else if (command == "H") goBackLeft();
//      else if (command == "W")digitalWrite(Light, HIGH); // light is on
//      else if (command == "w")digitalWrite(Light, LOW);  // light is off

so i try to work like this tutorial but he gives me that it cant conect with wifi and didin't give me th ip addres

i wont to control by this app in this video

soo this is what i think about
in my car code there is also another ultrasonic and stepper motor i will put it down

#include <Stepper.h>//library for stepper motor
//#include <SoftwareSerial.h>//library for serial conection 
//SoftwareSerial BT(10,11);//RX TX pin 
//String state;//string to save the word
const int triggerPin1 = 2; // Trigger pin for the first distance sensor
const int echoPin1 = 14;    // Echo pin for the first distance sensor
const int triggerPin2 = 4; // Trigger pin for the second distance sensor
const int echoPin2 = 5;    // Echo pin for the second distance sensor
const int buzzerPin = 6;   // Pin connected to the buzzer
//pin to control car move and it is speed for car
#define motorspeed 9
#define IN1 3
#define IN2 11
#define IN3 12
#define IN4 13

const int stepsPerRevolution = 2048;  // Number of steps for 360 degrees rotation (can vary for different motors)
#define motorPin1  22              // Motor pin 1
#define motorPin2  24              // Motor pin 2
#define motorPin3  26             // Motor pin 3
#define motorPin4  28             // Motor pin 4
#define motoupp 30
#define motodown 32

Stepper motor(stepsPerRevolution, motorPin1, motorPin3, motorPin2, motorPin4);
//Stepper bedstepper(2048,22,26,24,28);
//bool rotait=true;

//variable for LDR code
#define ldr A0
#define LDRout 33
float vldr=0;
unsigned long res=0;
const int res1=1000;  

int speedCar = 150; // 0 to 255
int speed_low = 60;
void setup() {
  pinMode(motoupp,INPUT_PULLUP);
  pinMode(motodown,INPUT_PULLUP);

  
  pinMode(triggerPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(triggerPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  pinMode(buzzerPin, OUTPUT);

 pinMode(motorspeed,OUTPUT);
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(IN3,OUTPUT);
 pinMode(IN4,OUTPUT); 
 pinMode(LDRout,OUTPUT);

 motor.setSpeed(17);
 Serial.begin(9600);
}

void loop() {
  //analogWrite(motorspeed,77);//car motor speed



//LDR code to control flash when it is dark start***************
    vldr=(analogRead(ldr)/1023)*5;
  res=(vldr*res1)/(5-vldr);

if(res>=2000){
    digitalWrite(LDRout,HIGH);
  }else{

    digitalWrite(LDRout,LOW);
    }
//LDR code to control flash when it is dark end ***************
  
  //stepper  motor code start*************************************
  //to move stepper motor clockwise 
   if(!digitalRead(motoupp)){
    while(!digitalRead(motoupp)){
  motor.step(-3); }
 }
 //to move stepper motor  prev clockwise
 if(!digitalRead(motodown)){
  while(!digitalRead(motodown)){
  motor.step(3); }
 }
 //stepper code end************************************



//ultrasonic to read distance code  start********************
 
  long duration1, distance1, duration2, distance2;
  
  // Measure distance from the first sensor
  digitalWrite(triggerPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(triggerPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin1, LOW);
  
  duration1 = pulseIn(echoPin1, HIGH);
  distance1 = duration1 * 0.034 / 2;

  // Measure distance from the second sensor
  digitalWrite(triggerPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(triggerPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin2, LOW);
  
  duration2 = pulseIn(echoPin2, HIGH);
  distance2 = duration2 * 0.034 / 2;
  Serial.println(" far");
//  Serial.print("Distance Sensor 1: ");
//  Serial.print(distance1);
//  Serial.println(" cm");
//  
//  Serial.print("Distance Sensor 2: ");
//  Serial.print(distance2);
//  Serial.println(" cm");

  if (distance1 < 10&distance1 >= 5) {
    // turn on the buzzer
  Serial.print("Distance Sensor 1: ");
  Serial.print(distance1);
  Serial.println(" cm");
    tone(buzzerPin, 1000);
  } else if( distance1 < 5){
  Serial.print("Distance Sensor 1: ");
  Serial.print(distance1);
  Serial.println(" cm");
    tone(buzzerPin, 3000);
    stopRobot();
  }
  else {
    // turn off the buzzer
    noTone(buzzerPin);
  }

  // wait for a short period before taking the next reading
  delay(100);
    if (distance2 < 10&distance2 >= 5) {
    // turn on the buzzer
  Serial.print("Distance Sensor 2: ");
  Serial.print(distance2);
  Serial.println(" cm");
    tone(buzzerPin, 6000);
  } else if( distance2 < 5){
  Serial.print("Distance Sensor 2: ");
  Serial.print(distance2);
  Serial.println(" cm");
    tone(buzzerPin, 7000);
    stopRobot();
  }
  else {
    // turn off the buzzer
    noTone(buzzerPin);
  }
  //delay(200); // Delay between measurements
//ultrasonic to read distance code  end********************

  
  
}
void goRight(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(motorspeed, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, LOW);
      analogWrite(motorspeed, speedCar);
  }
void goLeft(){

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, LOW);
      analogWrite(motorspeed, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(motorspeed, speedCar);
  }

void goForword(){ 

      digitalWrite(IN_1, HIGH);
      digitalWrite(IN_2, LOW);
      analogWrite(motorspeed, speedCar);

      digitalWrite(IN_3, HIGH);
      digitalWrite(IN_4, LOW);
      analogWrite(motorspeed, speedCar);
  }
void goBack(){ 

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, HIGH);
      analogWrite(motorspeed, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, HIGH);
      analogWrite(motorspeed, speedCar);
  }

void stopRobot(){  

      digitalWrite(IN_1, LOW);
      digitalWrite(IN_2, LOW);
      analogWrite(motorspeed, speedCar);

      digitalWrite(IN_3, LOW);
      digitalWrite(IN_4, LOW);
      analogWrite(motorspeed, speedCar);
 }






//delay(100);
//  if (distance1 < 10) {
//    // If distance from sensor 1 is less than 10 cm, produce a sound
//    Serial.println("less 1 ");
//    digitalWrite(buzzerPin, HIGH);
//    delay(1000);
//    digitalWrite(buzzerPin, LOW);
//    delay(1000);
//  }
//  
//  if (distance2 < 10) {
//    // If distance from sensor 2 is less than 10 cm, produce a sound
//    Serial.println("less 2 ");
//    digitalWrite(buzzerPin, HIGH);
//    delay(1000);
//    digitalWrite(buzzerPin, LOW);
//    delay(1000);
//  }
//  

and that is all

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.