Pages: [1]   Go Down
Author Topic: Arduino UNO Vs Arduino UNO R3  (Read 795 times)
0 Members and 1 Guest are viewing this topic.
Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear All,

I am having some difficulty in using new Arduino UNO R3 shield. Previously I was using Arduino UNO to get sensor's data through SPI and transmitting it through WiFi Shield through and I was able to do it successfully. However then I ordered some more Arduino UNO Shields and now I am trying to use them for the same purpose. But I can't transmit data through WiFi shield when I use these new Arduino UNO R3 shields. Do I need to do some modification in the code? Please suggest appropriate solution. I have pasted my code which is working fine with my Old Arduino UNO Shield.

Code:
#include <SPI.h>
#include <WiShield.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

// Wireless configuration parameters ----------------------------------------
byte local_ip[]    = {192,168,1,203}; // IP address of WiShield
byte gateway_ip[]  = {192,168,1,1}; // router or gateway IP address
byte subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
prog_char ssid[] PROGMEM    = {"SOLID"}; // max 32 bytes
unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

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

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = {
  0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, // 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_ADHOC;
int CS_sensor = 7;
unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------


Server server(6000);
Client client_a;

void setup()
{
  Serial.begin(9600);
  pinMode(CS_sensor, OUTPUT);
  digitalWrite(CS_sensor, HIGH);

  // Serial.println("Starting Wifi ...");
  WiFi.begin(local_ip, gateway_ip, subnet_mask);
  // Serial.println("Wifi started.");

  server.begin();
  // Serial.println("server ready.");

  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV8);
}


void loop()
{
  // Serial.println("Start again.");
  while(!client_a.connected()){
    server.available(&client_a);
   // Serial.println("Hello ");
  }

  while(client_a.connected()){   
    client_a.println("Hello !");
    // Serial.println("It's connected.");
    client_a.sendnow();
  }
  // Serial.println("Disconnected.");
  client_a.flush();
  server.begin();
}

Logged

Pages: [1]   Go Up
Jump to: