Adafruit Motor / Stepper / Servo Shield para Arduino Kit v2

Our weekly LIVE video chat. Every Wednesday at 8pm ET!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by adafruit_support_bill »

In your code, you set the serial baud-rate to 115200

Code: Select all

Serial.begin(115200);
But your serial monitor is set to 9600 (lower right corner)
Image


If you change your serial monitor baud rate to 115200, you should see better results.

Ingeniero_Tijuana
 
Posts: 14
Joined: Tue Mar 18, 2014 7:21 pm

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by Ingeniero_Tijuana »

hello good morning, you know that my traducccion is not good, but I have problems with my project, first of all I'm basing this project, https://learn.adafruit.com/wifi-controlled-mobile-robot, I am using the components that makes me the picture, I would like if I can provide the connections that I connect them like the diagram says, but I am using the CC3000 shield, not the CC300 breakout, I wonder if they change the connections or what same. I send you some pictures of what I wear, to help me and tell me that is failing me, they are much appreciate, thank you for your attention.
Attachments
my project
my project
IMG008.jpg (851.03 KiB) Viewed 357 times
motor shield
motor shield
IMG007.jpg (851.26 KiB) Viewed 357 times
cc3000 shield
cc3000 shield
IMG006.jpg (882.84 KiB) Viewed 357 times

Ingeniero_Tijuana
 
Posts: 14
Joined: Tue Mar 18, 2014 7:21 pm

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by Ingeniero_Tijuana »

these are some pictures of the program running before entering and after some button.

this is the code I'm using

Code: Select all

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#include <stdlib.h>

String result;
int motorCommand[4];

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ   3
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10

// Motor pins
int speed_motor1 = 6;  
int speed_motor2 = 5;
int direction_motor1 = 7;
int direction_motor2 = 4;
 

const unsigned long
  dhcpTimeout     = 60L * 1000L, // Max time to wait for address from DHCP
  connectTimeout  = 15L * 1000L, // Max time to wait for server connection
  responseTimeout = 15L * 1000L; // Max time to wait for data from server



uint32_t t;

int resultLength;

// WiFi network (change with your settings !)
#define WLAN_SSID       "INFINITUMD5CBB4"        // cannot be longer than 32 characters!
#define WLAN_PASS       "71E27CEEC611"
#define WLAN_SECURITY   WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2

// What TCP port to listen on for connections.
#define LISTEN_PORT           5200    

// Create CC3000 instances
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIV2);                                
                                         
// Create server
Adafruit_CC3000_Server robotServer(LISTEN_PORT);


void setup() {
   
  Serial.begin(115200);
  
  result = "";
  
  for(int i=4;i<=7;i++)
  {  
    pinMode(i, OUTPUT);  //set pin 4,5,6,7 to output mode
  }
  
  /* Initialise the module */
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
   
  Serial.println(F("Connected!"));
  
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  

  /* Display the IP address DNS, Gateway, etc. */  
  while (! displayConnectionDetails()) {
    delay(1000);
  }
 
  // Start listening for connections
  robotServer.begin();
  
  Serial.println(F("Listening for connections..."));
 
}

void loop() {
  
  // Try to get a client which is connected.
  Adafruit_CC3000_ClientRef client = robotServer.available();
  if (client) {
     boolean currentLineIsBlank = true;
     // Check if there is data available to read.
     while (client.available()) {
     
       char c = client.read();
       result = result + c;
       Serial.write(c);
       
       // Delete HTTP headers
      if(result.endsWith("Content-Type: text/html"))
      {
        result="";
      }
       
       if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.0 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println();          
       }
       if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
       
     }
     // give the web browser time to receive the data
    delay(5);
    // close the connection:
    client.close();
    Serial.println("client disconnected");
    
    // Format result and extract the variables
    format_result(motorCommand,result);
 
    // Print received values
    Serial.println("Motor 1 speed: " + String(motorCommand[0]) + " and direction: " + String(motorCommand[2]));
    Serial.println("Motor 2 speed: " + String(motorCommand[1]) + " and direction: " + String(motorCommand[3]));

    // Send motor commands
    send_motor_command(speed_motor1,direction_motor1,motorCommand[0],motorCommand[2]);
    send_motor_command(speed_motor2,direction_motor2,motorCommand[1],motorCommand[3]);
 
    // Reset result variable
    result = "";
  }
           
}

void send_motor_command(int speed_pin, int direction_pin, int pwm, boolean reverse)
{
  analogWrite(speed_pin,pwm); // Set PWM control, 0 for stop, and 255 for maximum speed
  if(reverse)
  { 
    digitalWrite(direction_pin,HIGH);    
  }
  else
  {
    digitalWrite(direction_pin,LOW);    
  }
}

void format_result(int* array, String result) {
 
 result.trim();
 resultLength = result.length();
 Serial.println(result);
 
 int commaPosition;
 int i = 0;
 do
  {
      commaPosition = result.indexOf(',');
      if(commaPosition != -1)
      {
          Serial.println( result.substring(0,commaPosition));
          array[i] = result.substring(0,commaPosition).toInt();
          i = i+1;
          result = result.substring(commaPosition+1, result.length());
      }
      else
      {
         if(result.length() > 0) {
           Serial.println(result);
          }
      }
      
   }
   while(commaPosition >=0);  
} 

/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}
could tell me if there is an error
Attachments
Here is this by clicking on a button, it is observed that if the data is sent but disconnects the client, and the car does not move forward, be that the connections are not well
Here is this by clicking on a button, it is observed that if the data is sent but disconnects the client, and the car does not move forward, be that the connections are not well
Corriendo Prueba.PNG (181.9 KiB) Viewed 357 times
Here is the initializing program and charging to the arduino
Here is the initializing program and charging to the arduino
Prueba.PNG (180.19 KiB) Viewed 357 times
Last edited by adafruit_support_bill on Mon May 26, 2014 7:23 am, edited 1 time in total.
Reason: please use the </> button when submitting code. press </>, then paste your code between the [code] [/code] tags.

Ingeniero_Tijuana
 
Posts: 14
Joined: Tue Mar 18, 2014 7:21 pm

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by Ingeniero_Tijuana »

hello goodnight, and not received a response regarding my question earlier urged me hope you can help me thanks

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by adafruit_support_bill »

The pinouts for the shield are shown in the CC3000 tutorial here: https://learn.adafruit.com/adafruit-cc3 ... onnections
There are some differences from the wiring used for the breakout in the robot tutorial.

Ingeniero_Tijuana
 
Posts: 14
Joined: Tue Mar 18, 2014 7:21 pm

Re: Adafruit Motor / Stepper / Servo Shield para Arduino Kit

Post by Ingeniero_Tijuana »

good night and check the connections and are well, one of my concerns is that I'm using the shield and engine outputs m1 and m2 are to the engines, I would like to help me with elextronico diagram of all the connections that are used in example you say me, because if you looked at the dainty pictures where supposedly being tested sends the order but the motor does not move, need help with connections https://learn.adafruit.com/wifi-controlled-mobile- robot, I hope your answer thanks

Locked
Please be positive and constructive with your questions and comments.

Return to “Ask an Engineer! VIDEO CHAT (closed)”