Pages: [1]   Go Down
Author Topic: Arduino WifiShield not Working?  (Read 678 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there people , i have 2 issues :S
im trying to start with the arduino Wifi Shield, but when i run the WebServer or WebClient from the examples it throw me ERROR.
but with the NetworkScan or the ConnectionWEP its green light.

and second, can anybody help me? im trying to run this code

/*
 * Socket App
 *
 * A simple socket application example using the WiShield 1.0
 */

#include <WiShield.h>

#define WIRELESS_MODE_INFRA   1
#define WIRELESS_MODE_ADHOC   2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,0,25};   // IP address of WiShield
unsigned char gateway_ip[] = {192,168,0,1};   // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};   // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"ROUTER ID"};      // max 32 bytes

unsigned char security_type = 3;   // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"WPA PASS"};   // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,   // Key 0
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 1
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 2
              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // Key 3
            };


// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
char buffer[20];
//---------------------------------------------------------------------------

void setup()
{
        Car_Setup();
   WiFi.init();
        Serial.begin(9600);
}

void loop()
{
   WiFi.run();
      if (buffer[0] == 'A') { // Control specific pin
        //PSOCK_SEND_STR(&s->p, "LED Command: ");
        if (buffer[1] >= 3 && buffer[1] <= 12) {
          //PSOCK_SEND_STR(&s->p, "Correct, LED");
          //PSOCK_SEND(&s->p, &s->inputbuffer[1], 1);
          //PSOCK_SEND(&s->p, "=", 1); 
          if (buffer[2] == 0) {
            pinMode(buffer[1], OUTPUT); // define as output
            digitalWrite(buffer[1], LOW);
            //PSOCK_SEND_STR(&s->p, "OFF");
          } else {
            pinMode(buffer[1], OUTPUT); // define as output
            digitalWrite(buffer[1], HIGH);
            //PSOCK_SEND_STR(&s->p, "ON");
          }
        } else {
          //PSOCK_SEND_STR(&s->p, "Wrong!");
        }
      }     
      if (buffer[0] == 'D') { // Control specific pin
        Serial.print("Drive ");
        if (buffer[1] == 'F') {
          Serial.print("forward: ");
          if (buffer[2] > 127) {
            Car_Drive(127);
            Serial.println(127, DEC);
          } else {
            Car_Drive(buffer[2]);
            Serial.println(buffer[2], DEC);
          }
        } else if (buffer[1] == 'B') {
          Serial.println("backward: ");
          if (buffer[2] > 127) {
            Car_Drive(-127);
            Serial.println(-127, DEC);
          } else {
            Car_Drive(-1 * buffer[2]);
            Serial.println(-1 * buffer[2], DEC);
          }
        }
      }
      if (buffer[0] == 'T') { // Control specific pin
        Serial.print("Turn ");
        if (buffer[1] == 'R') { // Right
          Serial.println("right");
          Car_Turn(1);
        } else if (buffer[1] == 'L') { // Left
          Serial.println("left");
          Car_Turn(-1);
        } else if (buffer[1] == 'N') { // None
          Serial.println("none");
          Car_Turn(0);       
        }
      }     
      memset(buffer, 0x00, sizeof(buffer)); // Empty buffer
}

void Car_Setup()
{
  pinMode(3, OUTPUT); // Turn Right Pin
  digitalWrite(3, LOW);
  pinMode(4, OUTPUT); // Turn Left Pin
  digitalWrite(4, LOW);
  analogWrite(5, 0); // Go Forward PWM
  analogWrite(6, 0); // Go Backward PWM
}

void Car_Drive(signed char Direction) // Forward/Backward speed
{
  if (Direction > 0) {
    analogWrite(5, 2 * Direction); // Go Forward PWM
    analogWrite(6, 0);         // Go Backward PWM
  } else if (Direction < 0) {
    analogWrite(5, 0); // Go Backward PWM
    analogWrite(6, -2 * Direction);         // Go Forward PWM   
  } else {
    analogWrite(5, 0);         // Go Forward PWM
    analogWrite(6, 0);         // Go Backward PWM     
  }
}

void Car_Turn(signed char Direction) // Positive=Right, Negative=Left
{
  if (Direction > 0) {
    digitalWrite(3, HIGH);  // Turn Right Pin
    digitalWrite(4, LOW);  // Turn Left Pin
  } else if (Direction < 0) {   
    digitalWrite(3, LOW);  // Turn Right Pin
    digitalWrite(4, HIGH);  // Turn Left Pin   
  } else {
    digitalWrite(3, LOW);  // Turn Right Pin
    digitalWrite(4, LOW);  // Turn Left Pin   
  }
}

but it doesnt connect with the NET APP from visual Studio, its a problem with the PORT or something, im kindda new on this wifi thing
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
im trying to start with the arduino Wifi Shield, but when i run the WebServer or WebClient from the examples it throw me ERROR.
What does this mean? Don't you think you should resolve this BEFORE trying more complex examples?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there's the problem, it connects to the web running the connection program, but when i run the Client or Server it sends ERROR.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which wifi shield are you using? I have arduino official wifi shield bought from sparkfun. It needs library download. Anyway, my shield needs wifi.h not wishield.h
Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but when i run the Client or Server it sends ERROR.
You get an e-mail? The postman brings you a letter? The Arduino explodes, scream error? Just what EXACTLY happens? If you can't (or won't) explain what happens we can't (or won't) help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

its the Wifi Shield from Arduino, it uses the Wifi.h
the wishield.h its a library i download in order to run the application, but when i run the .NET app on VB the port connection doesnt work.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but when i run the Client or Server it sends ERROR.
You get an e-mail? The postman brings you a letter? The Arduino explodes, scream error? Just what EXACTLY happens? If you can't (or won't) explain what happens we can't (or won't) help.

I suspected the OP may be using example code from Arduino's wifi library on a third-party wifi shield or else. I hope the Arduino didn't explode. What a waste if it does explode? I guess OP clarified it while I was typing. If you can't run the wifi shield example (Webclient), tell us what error you got. I don't know nothing about some application you downloaded off the net that does .NET on VB ports.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.mediafire.com/?9a8mg9188odo8yg

here's the entire APP and Code im using, hope it helps for understanding this :S

P.D. did i need a router to run it? its just a question :S
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm at the starting line in terms of wifi shield so may not be able to offer much beyond initial checking a few simple things off a mental list. Not to pick on you but I hate mediafire! I have hosted some files there for some time until they started claiming some of those files have copyrights belong to someone else. Did I have an evil twin? The site is spammy.
Logged


Pages: [1]   Go Up
Jump to: