Pages: [1]   Go Down
Author Topic: ask: communication arduino with tcp winsock!!!!!!!!  (Read 1464 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

all my dear friends
help me
i get code
Code:
// Arduino firmware for Andriod Robot Project
// Command:   X  F  B  L  R  FR    FL    BR   BL    H
// PORT_map:  -  1  2  4  8   9     5    10   6     16 (PORTB HEX)
// Received:  0  1  2  3  4   5     6    7    8     9  (from router)
// Pin        -  8  9  10 11  811   810  911  910   12

unsigned char port_map[10]={0,1,2,4,8,9,5,10,6,16};
unsigned int in_char;
unsigned long counter=0;
unsigned char in_byte=0;
unsigned int test=0;
void setup()
{
DDRB=B11111111; //PORTB as OUTPUT
Serial.begin(9600); //Start Serial
} char recv_char()
{
while (counter < 15000) //Pulse of command
{
counter++;
if (Serial.available() > 0)
{
in_byte = Serial.read();
test=(int)in_byte-48;
Serial.print(test);
counter = 0;
return test;
            }
}
counter=0;
return 0;
} void loop()
{
in_char=recv_char();
PORTB=port_map[in_char]; //Port map
}


my goal to communication arduino and tcp socket linksys ddwrt to control motor dc
looks like well .. but i can control device correct...
what is that corrcetlly code ... or .. i have some missing code .. to communication well drive motor dc
Logged

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

That code looks like something a bunch of monkeys playing with typewriters might have come up with.

While the compiler doesn't care about white space, people do. I don't think you are asking a compiler to read and comment on your code. Before you ask people to, you need to make it presentable. Each { goes on its own line. Functions do not go on the same line as }. Random indenting is a pain the derriere to read.
Logged

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

Code:
// Arduino firmware for Android Robot Project
// Command:   X  F  B  L  R  FR    FL    BR   BL    H
// PORT_map:  -  1  2  4  8   9     5    10   6     16 (PORTB HEX)
// Received:  0  1  2  3  4   5     6    7    8     9  (from router)
// Pin        -  8  9  10 11  811   810  911  910   12

unsigned char port_map[10]={0,1,2,4,8,9,5,10,6,16};
unsigned int in_char;
unsigned long counter=0;
unsigned char in_byte=0;
unsigned int test=0;

void setup()
{
  DDRB=B11111111; //PORTB as OUTPUT
  Serial.begin(9600); //Start Serial
}
char recv_char()
{
  while (counter < 15000) //Pulse of command
  {
    counter++;
    if (Serial.available() > 0)
    {
      in_byte = Serial.read();
      test=(int)in_byte-48;
      Serial.print(test);
      counter = 0;
      return test;
    }
  }
  counter=0;
  return 0;
}
void loop()
{
  in_char=recv_char();
  PORTB=port_map[in_char]; //Port map
}


just read the algoritme brother

i think it was clearly
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8913
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
looks like well .. but i can control device correct...
what is that corrcetlly code ... or .. i have some missing code .. to communication well drive motor dc

english please
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

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

I think he is trying to do the same thing i am. He is trying to control dc motors using an arduino interfaced with a router running dd-wrt via serial.

@Rhenfri - Follow these links. They will help

Serial communication with DD-wrt:
http://www.andrewhazelden.com/blog/2010/01/how-to-use-the-serial-ports-on-a-linksys-wrt54gs-with-dd-wrt-v24/

Jon Bennett's RC car setup:
http://www.jbprojects.net/projects/wifirobot/

The post I literally just did asking for help with the same thing (includes the code i am currently using)
http://arduino.cc/forum/index.php/topic,80474.0.html
Logged

Pages: [1]   Go Up
Jump to: