Show Posts
Pages: [1]
1  International / Portugues / [Artigo]Arduino, SDL e Perl on: September 24, 2011, 09:34:24 pm
Olá, escrevi um artigo e estou compartilhando.

Artigo demonstrando como utilizar Perl, Arduino e SDL em conjunto. Vamos construir um Piano de Luz, quando você apertar uma tecla do seu teclado uma luz vai acender, permitindo que várias luzes sejam acesas simultaneamente. Nesse artigo utilizaremos alguns truques que só são possíveis com o nível de interface com o teclado que o SDL oferece. É apenas uma demonstração, mas o objetivo é mostrar o conceito que pode ser aplicado para qualquer coisa que a sua imaginação possa pensar.


http://sao-paulo.pm.org/equinocio/2011/set/23
2  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Xbee communication (explorer to shield) on: September 18, 2011, 12:31:13 pm
with defaults configs with xbee
3  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Xbee communication (explorer to shield) on: September 16, 2011, 05:32:19 pm
I'm using this code to move my Rover 5

Code:
//Standard PWM DC control

int E1 = 5;     //M1 Speed Control
int E2 = 6;     //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

///For previous Romeo, please use these pins.
//int E1 = 6;     //M1 Speed Control
//int E2 = 9;     //M2 Speed Control
//int M1 = 7;    //M1 Direction Control
//int M2 = 8;    //M1 Direction Control


void stop(void)                    //Stop
        {
          digitalWrite(E1,LOW);  
          digitalWrite(E2,LOW);      
        }  
void advance(char a,char b)          //Move forward
        {
          analogWrite (E1,a);      //PWM Speed Control
          digitalWrite(M1,HIGH);    
          analogWrite (E2,b);    
          digitalWrite(M2,HIGH);
        }  
void back_off (char a,char b)          //Move backward
        {
          analogWrite (E1,a);
          digitalWrite(M1,LOW);  
          analogWrite (E2,b);    
          digitalWrite(M2,LOW);
}
void turn_L (char a,char b)             //Turn Left
        {
          analogWrite (E1,a);
          digitalWrite(M1,LOW);    
          analogWrite (E2,b);    
          digitalWrite(M2,HIGH);
        }
void turn_R (char a,char b)             //Turn Right
        {
          analogWrite (E1,a);
          digitalWrite(M1,HIGH);    
          analogWrite (E2,b);    
          digitalWrite(M2,LOW);
        }
void setup(void)
{
    int i;
    for(i=6;i<=9;i++)
    pinMode(i, OUTPUT);  
    Serial.begin(9600);      //Set Baud Rate
}
void loop(void)
{
     char val = Serial.read();
     if(val!=-1)
       {
          switch(val)
           {
             case 'w'://Move Forward
                     advance (100,100);   //PWM Speed Control
                     break;
             case 's'://Move Backward
                     back_off (100,100);
                     break;
             case 'a'://Turn Left
                     turn_L (100,100);
                     break;      
             case 'd'://Turn Right
                     turn_R (100,100);
                     break;          
            }    
          delay(40);
       }
      else stop();  
}


I also did a code using Perl language, so i execute my Perl code and press 'w','a',s', and 'd,' and I move my Rover 5 is like video game.
Code:
#!/usr/bin/perl

use strict;
use warnings;

use Device::SerialPort;
use Term::ReadKey;
ReadMode 4;    # Turn off controls keys
$| = 1;
my $port = Device::SerialPort->new("/dev/ttyUSB0");

# 19200, 81N on the USB ftdi driver
$port->baudrate(9200);
$port->databits(8);
$port->parity("none");
$port->stopbits(0);

sub get_key {
    my $key;
    while ( not defined( $key = ReadKey(-1) ) ) {
    }
    return $key;
}

while (1) {

    my $char = $port->lookfor();

    my $key = get_key();
    if ($key) {
        exit(0) if $key !~ /w|a|s|d|t/i;
        $port->write($key);
    }
    if ($char) {
        print "Recieved character: $char \n";
    }

    # Uncomment the following lines, for slower reading,
    # but lower CPU usage, and to avoid
    # buffer overflow due to sleep function.
    #  $port->lookclear;

    # sleep (1);
    sleep(0.1);

}

To use it,
Code:
perl this_file.pl

and press the keyboard w,a,s and d.
4  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Xbee communication (explorer to shield) on: September 16, 2011, 05:27:40 pm
Yes I did. Dude, your code have to have the same serial speedy of the xbee(9600). Use the program code which the guy wrote in the tutorial.(just do test)


I can send and receive commands. Restore the defaults of your xbee and follow the tutorial.

Do that, restore the default values of your xbee's and try the tutorial again.

X-CTU -> Modem Configuration -> Parameter Views -> Show defaults -> Write

After that, try the tutorial again.

5  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Xbee communication (explorer to shield) on: September 15, 2011, 11:14:43 pm
DUDE I DID AND WORKED I LOVE YOU SO MUCH NOW I"LL TRY SEND COMMANDS, SORRY FOR UPPER CASE BUT I"M REALLY procreating HAPPY
6  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Xbee communication (explorer to shield) on: September 15, 2011, 09:56:42 pm
I didn't try it how you did, can you expain step by step so I can try too ?
7  Using Arduino / Networking, Protocols, and Devices / Arduino Xbee communication (explorer to shield) on: September 15, 2011, 04:10:38 pm
Hi, I bought this kit here,
http://www.dfrobot.com/index.php?route=product/product&filter_name=rover%205&product_id=420

So everything works unless the xbee, this is configuration of the xbee

My configurations,

Sender(my computer)
Ch=C
ID=3332
DH=15
DL=10
My=20

Receiver(arduino)
CH=C
ID=3332
Dh=15
DL=20
my=10





Modem Type= XB24
Firmeware Version = 10EC
Function Set = XBEE 802.15.4

^(for both)

How can I send serial commands ?
Pages: [1]