Show Posts
Pages: 1 ... 14 15 [16] 17 18 ... 228
226  Using Arduino / Project Guidance / Re: Bluetoothcommunication - modify input string on: June 16, 2014, 02:49:43 pm
Look into strtok() and atoi()
227  Using Arduino / Displays / Re: displaying time on LCD on: June 16, 2014, 02:48:10 pm
This is not the place to be asking this type of question, but for a quick answer, you need to set the cursor. lcd.setCursor(0,0); or wherever you want to show the numbers.
228  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 02:39:29 pm
Exactly and if you want to have different deadzones for both F/B, L/R, then you can have,
Code:
void move(int z, int y, int DZx, int DZy)// DZx = left/right, DZy = forward/reverse like a graph

  //Movement varibles
  int DRV2 = map(z, 0, 512 - DZy, 255, 0);
  int DRV1 = map(z, 512 + DZy, 1023, 0, 255);
  int STRL = map(y, 0, 512 - DZx, 255, 0);
  int STRR = map(y, 512+ DZx, 1023, 0, 255);
229  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 01:46:51 pm
Quote
void move(int z, int y, int DZ)// z = analog_1, y = analog_2, DZ = dead/neutral zone factor.

void loop(){
  move(analogRead(joy1),analogRead(joy2),6);
}



  //Movement varibles

Spacing is important, try this.

Code:
void loop()
{
  move(analogRead(joy1),analogRead(joy2),6);
}

void move(int z, int y, int DZ)// z = analog_1, y = analog_2, DZ = dead/neutral zone factor.

  //Movement varibles
230  Using Arduino / Project Guidance / Re: Need help with 4x4 Keypad Matrix on: June 16, 2014, 01:45:03 pm
Can you show us how it is wired to the arduino?
231  Using Arduino / Project Guidance / Re: Control air conditioner with wired remote on: June 16, 2014, 01:43:54 pm
You could use something like this IR Remote (Needs an arduino on the receiver side), but on the receiving side, you need to know what wires control which button functions.
232  Using Arduino / Project Guidance / Re: Control air conditioner with wired remote on: June 16, 2014, 01:30:29 pm
This might be a stretch, but you could maybe, just maybe get one that has a wireless controller.

If that is not possible then you will need to open the controller and see what connections do what. How many buttons does the controller have?
233  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 01:27:07 pm
You already have the loop function, I gave it to you.
Quote
void loop()
{
  move(analogRead(analoginpin1), analogRead(analoginpin2), 6); // 6 is the deadzone, so you can have some slack when your joystick returns to center.
}

All you need to do now is add the pinModes in the setup() function, like how you have here, just change the variables.
Quote
void setup() {
  Serial.begin(9600);
 
pinMode(m1_f,OUTPUT);
pinMode(m1_b,OUTPUT);
pinMode(m2_f,OUTPUT);
pinMode(m2_b,OUTPUT);
pinMode(m3_f,OUTPUT);
pinMode(m3_b,OUTPUT);
pinMode(m4_f,OUTPUT);
pinMode(m4_b,OUTPUT);

}

As for this, you can probably do without the constrain, and just have ... for each.
analogWrite(LMF, abs(DRV1 - STRL) );

This takes the difference from "forward/ reverse" and "left and right" values and allows the robot to drive the way the joystick is moved. forward + left = the robot moves forward and to the left.
234  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 12:59:15 pm
Im not writing the code for you, YOU can do that. In fact you need to understand your own mistakes in order to correct and pass that exam. If this is giving you a hard time then, you need to do some serious studying.

Check your pins again, and make sure everything is in the correct spot. My wiring is different from yours, so just double check. Have you tested the code on the robot?

Also
Quote
digitalWrite(LMR, LOW);
digitalWrite(RMR, LOW);
digitalWrite(LMF2, LOW); // Things like this will cause the code to fail.
digitalWrite(RMR2, LOW);

You are also missing your setup() function and loop(). If you can't figure out how to solve your own code and also have an exam tomorrow, you're going to fail. You need to comprehend how the arduino works and how to write/structure the code. Also testing is always a good way to see if the code works or not.
235  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 12:45:55 pm
The analogRead returns a value between 0 and 1023 when reading the pot. When your joystick is centered, the value is usually 512, however this in never always true, sometimes it is above 512 or below, so DZ helps o give you more slack.

You want the motors to go forward and reverse, and what I have done is split the joystick value into two variables, DRV1 and DRV2. DRV1 handles forward movement, and DRV2 is reverse. There are also IF statements that monitor the variable z to see whether the car should be going forward or reverse based on the value. This function also handles skid steering, (constrain(abs(DRV1 - STRL),0,255) ) so Forward and Left gets calculated and the car moves forward and to the left. Same for reverse.

Why use 2 motor drivers if one should be enough, just wire both motors (on the same side) to the same pins. Also I didn't see an external battery in the picture, so are you powering the motor drivers from the Arduino directly or from a battery pack?
236  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 12:18:33 pm
It was an example function, not full code.

To use the function, it should be like this.
Code:
void setup()
{
  /* pinModes */
}

void loop()
{
  move(analogRead(analoginpin1), analogRead(analoginpin2), 6); // 6 is the deadzone, so you can have some slack when your joystick returns to center.
}

/* You can fill in the rest */

You should also not be driving the motors directly from the arduino, you can burn it out like that, instead you should be using a motor driver, if you're not already.
237  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 11:42:38 am
Here is an example function:
Code:
byte LMF = 3;// PWM Left motor forward pin
byte LMR = 5;// PWM Left motor Reverse pin
byte RMF = 11;// PWM Right motor forward pin
byte RMR = 6;// PWM Right motor reverse pin

/*Rest of code here*/

void move(int z, int y, int DZ)// z = analog_1, y = analog_2, DZ = dead/neutral zone factor.
{  
  //Movement varibles
  int DRV2 = map(z, 0, 512 - DZ, 255, 0);
  int DRV1 = map(z, 512 + DZ, 1023, 0, 255);
  int STRL = map(y, 0, 512 - DZ, 255, 0);
  int STRR = map(y, 512+ DZ, 1023, 0, 255);

  if(z > 512)//forwards              
  {
    //Serial.println("Forward with turning");
    analogWrite(LMF, constrain(abs(DRV1 - STRL),0,255));
    analogWrite(RMF, constrain(abs(DRV1 - STRR),0,255));  
    digitalWrite(LMR, LOW);
    digitalWrite(RMR, LOW);  
  }
  else if(z < 512)//backwards              
  {
    //Serial.println("Reverse with turning");
    digitalWrite(LMF, LOW);
    digitalWrite(RMF, LOW);  
    analogWrite(LMR, constrain(abs(DRV2 - STRL),0,255));
    analogWrite(RMR, constrain(abs(DRV2 - STRR),0,255));  
  }
  else if(z == 512 && y > 512)//Right              
  {
    //Serial.println("360 left");
    digitalWrite(LMR, LOW);
    analogWrite(RMR, STRR);  
    analogWrite(LMF, STRR);
    digitalWrite(RMF, LOW);
  }
  else if(z == 512 && y < 512)//Left              
  {
    //Serial.println("360 right");
    analogWrite(LMR, STRL);
    digitalWrite(RMR, LOW);  
    digitalWrite(LMF, LOW);
    analogWrite(RMF, STRL);  
  }

  else //full stop
  {
    digitalWrite(LMF, LOW);
    digitalWrite(RMF, LOW);        
    digitalWrite(LMR, LOW);
    digitalWrite(RMR, LOW);    
  }
}
238  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 11:24:14 am
Quote
if i can't user more than one pin , and i can't call function like [ auto_pikot()] ..
I asked when does the function ever get called?

Quote
the code i wrote i finished it , i but it just to understand for whom reading my topic ...
??? Can you post your finished code.
239  Using Arduino / Programming Questions / Re: need help in my programe . on: June 16, 2014, 11:04:06 am
Quote
analogWrite(here i want to put more than one pin(m1_f + m2_f) , motors_value1);
  analogWrite(m1_b , motors_value2);

You can't use more than one pin like that, you need to split them up.

Quote
  delay(4000);
  robot_left();
  if (sen4_val==HIGH){robot_stop();
  delay(1000);
  robot_down();
  delay(8000);
  robot_arm_hold();
  delay(3000);
  robot_arm_stop();
  delay(1000);
  robot_up();
  delay(3000);
These delays are going to be an issue, because they won't let you do anything else until they are done. So if that IF statement condition is true, then you will need to wait until it is false to do anything afterward. But if your willing to wait, then you can use it, but I highly recommend you look into the Blink Without Delay example for a better "delay" solution.

One more thing, when does auto_pilot() ever get called?
240  Using Arduino / Project Guidance / Re: analog keyboard interfacing on: June 16, 2014, 10:46:59 am
You might not be able to use just the keystroke and value as one, so you might need to first send the key then the value after it and make sure you get both.

Or you could probably send a Struct composed of the key and value, then on the receiving side split them up to their appropriate places. I never tried it before, but it should work.

Are you using the Keyboard library, because I didn't know it was compatible with an Arduino Micro.
Pages: 1 ... 14 15 [16] 17 18 ... 228