Show Posts
Pages: [1] 2
1  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 02, 2013, 11:12:53 am
well thanx for your support...when i searched in stackoverflow.com i got a solution perfectly working...problem was the part where i configured baudrate..
i used
Quote
stty -F /dev/ttyACM0 sane raw pass8 -echo -hupcl clocal 9600

this works well
source:http://stackoverflow.com/questions/11677639/two-way-c-communication-over-serial-connection
2  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 01, 2013, 09:24:15 pm
so what do u suggest??
3  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 01, 2013, 10:16:53 am
i programmed cpp file as when it gets input "1",it shows output from uno,still the program stopes  in 2 sec.. smiley-sad
4  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 01, 2013, 10:07:25 am
i use g++ compiler...i compiled through terminal...lemme try about what you told...

5  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 01, 2013, 09:45:55 am
well i changed the c++ program as
Quote
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char ch;
ifstream f;
f.open("/dev/ttyACM0");

   while (f.get(ch))
   {
      cout << ch;
   }
return 0;
}
when i compile the program i get
Quote
naaeemuzz@naaeemuzz-Satellite-L655:~/project/samples$ ./samplesled
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
led
naaeemuzz@naaeemuzz-Satellite-L655:~/project/samples$
and this happens in split of a  second and stops.i actually wanted an output similar to that of serial monitor..ie whenever the led blinks and shows out:"led" and else it does not....so what should i do??
6  Using Arduino / Interfacing w/ Software on the Computer / Re: usb communication with c++ on: September 01, 2013, 09:19:48 am
ok..thanks for the help smiley..i have tried the following..
configured baudrate in terminal by
Quote
stty -F /dev/ttyACM0 9600
then i created a c++ program(exp.cpp) in my computer
Quote
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
string str;
fstream f;
f.open("/dev/ttyACM0");
while(1)
{
   while (f >> str)
   {
      cout << str;
   }
}
return 0;
}

and uploaded this program into arduino uno
Quote
int led = 13;
void setup()

  Serial.begin(9600); 
  pinMode(led, OUTPUT);     
}

void loop()
{
  digitalWrite(led, HIGH);
  Serial.write("led");
  delay(1000);         
  digitalWrite(led, LOW);
  delay(1000);           
}
finally compiled the exp.cpp and got nothing...please consider me as newbie to usb communication
7  Using Arduino / Interfacing w/ Software on the Computer / usb communication with c++ on: August 28, 2013, 09:48:22 am
kindly help me to get data from the uno to my lap working on ubuntu 12.04. i am creating a program interfacing a camera in c++. i want to include a segment ie to get data from uno and use it manipulate the configurations of camera.kindly help...
8  Using Arduino / Networking, Protocols, and Devices / Re: dont know where to start with... on: August 09, 2013, 12:54:39 am
as per the data sheet xbee wifi module connects with 802.11 b/g/n..with data with max 72Mbps...so this will not alow??else please refer me a good one...
9  Using Arduino / Networking, Protocols, and Devices / dont know where to start with... on: August 08, 2013, 10:46:18 am
i have got an xbee wifi and arduino due...arduino due is on a remote system with a cam,19 servos,3motors accelerometer ,on board battery monitor and a ultra sound ranging meter . i can interface  these things to due. problem is i want to extract the these signal and sent to my computer through wifi.. ie control signal for servos and motor are to be transmitted and video signals,range,battery monitoring data have to be received at my computer...show me a path please..

and kindly consider me as a beginner... smiley-fat
10  Using Arduino / Project Guidance / video over wifi on: July 31, 2013, 09:24:53 am
is it possible to get video stream from web cam through xbee wifi module by using arduino due as interface between the cam and xbee?
11  Using Arduino / Project Guidance / Re: interface a cam and computer over air on: July 30, 2013, 09:05:19 am
how much range can IP cameras provide?
12  Using Arduino / Project Guidance / interface a cam and computer over air on: July 30, 2013, 07:47:40 am
well,i have an arduino due,2nos of xbee pro and CCD camera(CCTV surveillance) and a webcam...how can i get the live video feed to computer???
i thought like the cam data can be decoded using MAX9526 circuit...take the i2c interface to due..and put it in xbee...and sent it...or else is there any easiest way??using web cam...i heard the web cam transfer data at 480mbps..while xbee is 250kbps!:(...so i need a better way to begin with...
13  Using Arduino / Programming Questions / Re: error in programing?? on: March 29, 2013, 01:40:41 pm
@ JimboZA:well thanx...i edited the "else" with "if(b==0 && g==0)"...the problem is solved...smileysmiley
14  Using Arduino / Programming Questions / Re: error in programing?? on: March 29, 2013, 01:34:12 pm
@ JimboZA: so what do you suggest??how will change the programm??
15  Using Arduino / Programming Questions / error in programing?? on: March 29, 2013, 01:25:59 am
hi...
i got a program from net for interfacing dualshock controller with the arduino uno board..well...i edited the program such that i can use it drive the small 4 wheeled vehicle...i programed such that the arduino gives following outputs for my instruction(via controller)..ther are 4 o/p...r1 r2 l1 l2...these are connected to the l293d motor drivers for driving the mini-motors...
i/p                         r1  r2  l1  l2   function
X                           1    0   1   0   forward
triangle                   0   1   0   1    backward
X(or)triangle +left     0   1   1   0    left
X(or)triangle+right    1   0   0   1    right
read the 2 sticks

now the problem is just for simulation purpose i connected these pins with leds....i checked it with led i found all functions except the forward function works very well...but in forward function the led dims...and i get a max voltage of 1.2v...the same led is provided with 3.3v by the board when other functions are performed...
..i cant find any mistakes in programming or circuits....i have uploaded the program here....

there is also another problem such that the pin 2 gives high always...i tried to make it low using the edited BLINK program...well that is not working..its always high..

Quote
#include <PS2X_lib.h>
PS2X ps2x;
/* restart your Arduino after you conect the controller or call config_gamepad(pins) again after connecting the controller.*/
/*
pins   functions
13  clock
12  data
11  command
10  attension(enable)
7  r1
6  r2
5  l1
4  l2
*/
int error = 0;
byte type = 0;
byte vibrate = 0;
int led=9,r1=7,r2=6,l1=5,l2=4;
void setup()
{
   Serial.begin(57600);  
   pinMode(r1,OUTPUT);
   pinMode(r2,OUTPUT);
   pinMode(l1,OUTPUT);
   pinMode(l2,OUTPUT);
   error = ps2x.config_gamepad(13,11,10,12, true, true);
   if(error == 0)
   {
     Serial.println("Found Controller, configured successful");
     Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
    Serial.println("holding L1 or R1 will print out the analog stick values.");
   }  
   else if(error == 1)
   Serial.println("No controller found, check wiring");  
   else if(error == 2)
   Serial.println("Controller found but not accepting commands.");  
   else if(error == 3)
   Serial.println("Controller refusing to enter Pressures mode, may not support it. ");  
   //Serial.print(ps2x.Analog(1), HEX);  
   type = ps2x.readType();
   switch(type)
   {
       case 0:
              Serial.println("Unknown Controller type");
              break;
       case 1:
        {
              Serial.println("DualShock Controller Found");
              pinMode(led, OUTPUT);
              digitalWrite(led,HIGH);
              break;
        }
   }
}
int b=0,g=0;
char d='s';
void loop()
{  
 if(error == 1) //skip loop if no controller found
   return;  
 if(error!=2)//DualShock Controller
 {
    ps2x.read_gamepad(false, vibrate);
    if(b==1 || g==1)
    {    //read controller and set large motor to spin at 'vibrate' speed    
      if(ps2x.Button(PSB_PAD_RIGHT))
      {
        Serial.print("Right held this hard: ");
        Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC);
        d='r';
      }
      if(ps2x.Button(PSB_PAD_LEFT))
      {
        Serial.print("LEFT held this hard: ");
        Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC);
        d='l';
      }
     if(ps2x.Analog(PSAB_PAD_RIGHT)==0 && ps2x.Analog(PSAB_PAD_LEFT)==0)
      {
         Serial.println("Both r off");
         d='s';
      }
    }
    vibrate = ps2x.Analog(PSAB_BLUE);        //this will set the large motor vibrate speed based on,how hard you press the blue (X) button                                                
    if (ps2x.NewButtonState())               //will be TRUE if any button changes state (on to off, or off to on)
    {        
      if(ps2x.Button(PSB_GREEN))
      {
          Serial.println("Triangle pressed");
          g=1;  
      }
      if(ps2x.Button(PSB_BLUE))
      {  
           Serial.println("x pressed");
           b=1;  
      }        
     }                
    if(ps2x.ButtonReleased(PSB_GREEN))
    {
        Serial.println("tri just released");
        g=0;
        d='s';
    }
    if(ps2x.ButtonReleased(PSB_BLUE))             //will be TRUE if button was JUST released
    {
           Serial.println("x just released");        
           b=0;
           d='s';
    }
    if(d=='s')
    {
        if(b==1)
        {
            Serial.println("forward");
            digitalWrite(r1,HIGH);
            digitalWrite(r2,LOW);
            digitalWrite(l1,HIGH);
            digitalWrite(l2,LOW);
        }
        if(g==1)
        {
          Serial.println("backward");
          digitalWrite(r1,LOW);
          digitalWrite(r2,HIGH);
          digitalWrite(l1,LOW);
          digitalWrite(l2,HIGH);
        }
        else
        {
          Serial.println("stop");
          digitalWrite(r1,LOW);
          digitalWrite(r2,LOW);
          digitalWrite(l1,LOW);
          digitalWrite(l2,LOW);
        }
    }
    if(d=='r')
    {
          Serial.println("right");
          digitalWrite(r1,HIGH);
          digitalWrite(r2,LOW);
          digitalWrite(l1,LOW);
          digitalWrite(l2,HIGH);
    }
    if(d=='l')
    {
          Serial.println("left");
          digitalWrite(r1,LOW);
          digitalWrite(r2,HIGH);
          digitalWrite(l1,HIGH);
          digitalWrite(l2,LOW);
    }

    if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) // print stick values if either is TRUE
    {
        Serial.print("Stick Values:");
        Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX  
        Serial.print(",");
        Serial.print(ps2x.Analog(PSS_LX), DEC);
        Serial.print(",");
        Serial.print(ps2x.Analog(PSS_RY), DEC);
        Serial.print(",");
        Serial.println(ps2x.Analog(PSS_RX), DEC);
    }
 }
 delay(50);  
}
Pages: [1] 2