| Arduino Forum ::  Members :: Rustie0125
 Show Posts Pages: 1 2 [3] 4 5 6
 31 Using Arduino / Sensors / Re: Mapping Values from Joystick. need help. on: November 09, 2013, 12:32:49 pm See quick pic attached for a visual if what i need to achieve.
 32 Using Arduino / Sensors / Re: Mapping Values from Joystick. need help. on: November 09, 2013, 12:25:00 pm correct yes
 33 Using Arduino / Sensors / Re: Mapping Values from Joystick. need help. on: November 09, 2013, 12:03:08 pm yes but this still leaves me with two values,tel me try and explain again. when looking at the values from the joystick, if the joystick is center i get a value of 503 on both ThrottleValue and  DirValue when i push forward the value changes from 503 to 1023 when pulling towards me the value changes from 503 to 0. this is the case for all directions. I need only one value that is a combination of both DirValue and ThrottleValue that ranges from 0 -255 , this number can not/maynot be negative.
 34 Using Arduino / Sensors / Re: Mapping Values from Joystick. need help. on: November 09, 2013, 11:44:04 am Thank you for the quick reply.i have thought of that but my problem is i need a single value that creates two values. so if i go that direction how do i combine the values
 35 Using Arduino / Sensors / Mapping Values from Joystick. need help. on: November 09, 2013, 11:36:15 am Hi Guys I am busy building a rover but want to use only n joystick and to do this the joystick has to determine direction and throttle value.Direction I have worked out , but mapping the movement of the joystick to always give a positive of between 0 and 255 in any direction is difficult. the joystick center on the Y and X axial around 504(range 0-1023).and my general approach was as follows.Code:const int Throttle_Direct_Y = A1;// The pins were sensor are attachedconst int Direct_Left_Right_X = A2;const int TxRxPin = 13;int    DirFinal;int    DirValue;int    SpdValue;int    ThrottleMap;int    ThrottleValue;void setup()     {    Serial.begin(9600); // buttons    pinMode(TxRxPin,OUTPUT); // Sensor(s)    pinMode(Throttle_Direct_Y,INPUT);    pinMode(Direct_Left_Right_X,INPUT);    } void loop()    {  //Speed reading and mapping   ThrottleValue = analogRead(Throttle_Direct_Y);   DirValue = analogRead(Direct_Left_Right_X);      Serial.print(ThrottleValue );   Serial.print(",");   Serial.println(DirValue);    // throttle code reading and mapping  if (ThrottleValue > 513)  { ThrottleMap = map(ThrottleValue, 513, 1023, 0, 255);}  else   { ThrottleMap = map(ThrottleValue, 513, 0, 0, 255);}     if (DirValue > 513)  { ThrottleMap = map(DirValue, 513, 1023, 0, 255);}  else   { ThrottleMap = map(DirValue, 513, 0, 0, 255);}    Serial.println(ThrottleMap);  //Direction reading and mapping   }this does work on the Y axial but not the X axial or other way round if I play with the code. can any one help me in getting the joystick to output a signal between 0-255 doesnt matter in what direction you push the stick.thank you
 36 Topics / Robotics / Re: Dagu Rover 5 chassis robot demo on: November 06, 2013, 08:09:59 am and other question I have is how would I handle it when n joystick is held between 12 o clock and 9 oclock . what code would run ?
 37 Topics / Robotics / Re: Dagu Rover 5 chassis robot demo on: November 06, 2013, 06:51:21 am Quote from: moemzn on April 14, 2013, 02:09:41 amHey nick, i bought the same motor drive shield but im running a 4WD robot, im receiving a command throught a TCP server to move the robot in any direction, i wrote this code and want your opinion (Mind my low programing skills), this code is a test code.Code:#define motorpin0 2 // Direction ch1 front right motor#define motorpin1 3 // Direction ch2 front left motor#define motorpin2 4 // Direction ch3 back right motor#define motorpin3 7 // Direction ch4 back left motor#define speedpin0 5 //Speed Ch1#define speedpin1 6 //Speed Ch2#define speedpin2 9 //Speed Ch3#define speedpin3 10 //Speed Ch4int count=0;void setup() {//the motor control wires are outputspinMode (motorpin0, OUTPUT);pinMode(motorpin1, OUTPUT);pinMode(motorpin2, OUTPUT);pinMode(motorpin3, OUTPUT);//PWM Pins are outputspinMode(speedpin0, OUTPUT);pinMode(speedpin1, OUTPUT);pinMode(speedpin2, OUTPUT);pinMode(speedpin3, OUTPUT);}void loop() {      analogWrite(speedpin0,255);    analogWrite(speedpin1,255);    analogWrite(speedpin2,255);    analogWrite(speedpin3,255);      switch (count)  {    case 0: //forward    digitalWrite(motorpin0,1);    digitalWrite(motorpin1,1);    digitalWrite(motorpin2,1);    digitalWrite(motorpin3,1);    delay(10000);    count++;    break;         case 1: //Turn right        analogWrite(speedpin0,50);    analogWrite(speedpin2,50);        digitalWrite(motorpin0,1);    digitalWrite(motorpin1,1);    digitalWrite(motorpin2,1);    digitalWrite(motorpin3,1);    delay(1200);    count++;    break;        case 2: //backward        digitalWrite(motorpin0,0);    digitalWrite(motorpin1,0);    digitalWrite(motorpin2,0);    digitalWrite(motorpin3,0);    delay (5000);    count++;    break;           case 3: //Turn left        analogWrite(speedpin1,50);    analogWrite(speedpin3,50);        digitalWrite(motorpin0,1);    digitalWrite(motorpin1,1);    digitalWrite(motorpin2,1);    digitalWrite(motorpin3,1);    delay(1200);    count++;    break;}}Ill replace the count with the incoming command to move the vehicle as requested, im not using any encoders, also to rotate the vehicle i used the PWM, by reducing the cycle from 255 to 50 on right motoros to move it right, vice versa for the left.I Like your idea of how to handle the direction of the rover, I am doing the same , but I need to find out how I can use my joystick ( diy remote) as a double use I want to control the speed of my rover by the amount you push on the joystick, so when you press it forward 1mm it gives you very slow speed , but full and it gives you high speed but at the same time it needs to take direction into account.
 38 Using Arduino / Networking, Protocols, and Devices / Re: RF 433Mhz link "virtualwire" howto send multiple sensorvalue's on: September 20, 2013, 08:57:07 am I would like to do the same , but can some one tel me which pins are you using on the arduino uno ?
 39 Using Arduino / Programming Questions / Re: Voice Recognition Module programming issue on: October 14, 2012, 08:25:06 am Next step with the VR module I am now moving on and trying to get a setup menu going to teach the VR module new words via Arduino and not TTL converter, but this is proving difficult. I normally short GND to reset pin on the arduino and use the TX RX pins of the arduino to connect to the VR module and teach it new words. but im using software serial to connect to my VR module i need the Arduino to be running to convert from software to real Serial so i can see it in the terminal . here is the void function code im trying to use. Code: void learn() */{   Serial.println("learn mode");  while(mySerial.available())  {     learnState = mySerial.read();    Serial.println(learnState,HEX);    mySerial.write(0xAA);    mySerial.write(0x36); // Switch module into compact mode     delay(1000);    mySerial.write(0xAA);    mySerial.write(0x04);    delay(1000);    mySerial.write(0xAA);    mySerial.write(0x11);    if (learnState == 0x46)    {      Serial.println("Group 1 recorder succesfully");      Serial.println("Start of Group 2");      mySerial.write(0xAA);      mySerial.write(0x12);      delay(1000);      if (learnState == 0x47)      {         Serial.println("Group 2 recorder succesfully");        Serial.println("Start of Group 3");        mySerial.write(0xAA);        mySerial.write(0x12);        delay(1000);        if (learnState == 0x47)        {           Serial.println("Group 3 recorder succesfully");          Serial.println("Importing Groups");          mySerial.write(0xAA);          mySerial.write(0x21);          delay(1000);          mySerial.write(0xAA);          mySerial.write(0x22);          delay(1000);          mySerial.write(0xAA);          mySerial.write(0x23);          delay(1000);          mySerial.write(0xAA);          delay(1000);          if (learnState == 0xCC)          {             Serial.println("Programming succesfully");          }        }      }    }  }}the problem is when i view the terminal the result is printed one character at a time as the loop cycles instead of words printing for example.when i learn new words via hyper terminal i get a message "START" then i say the first word it will respond "AGAIN" or "DIFFERENT" if i didnt speak clearly. but when i run my learn void it prints the hex for the word "START" one character at a time under in println format and not print.like so S// 1 cycle T// 2 cycleA// 3 cycleR// 4 cycle T// 5 cycle any idea how i can make it work ?