Show Posts
Pages: 1 ... 18 19 [20] 21 22 ... 229
286  Using Arduino / Programming Questions / Re: 'void' function as a 'if' variable on: June 08, 2014, 11:52:17 am
I wanted to expand it, so Junblud could see what was happening.
287  Using Arduino / Programming Questions / Re: 'void' function as a 'if' variable on: June 08, 2014, 11:20:29 am
If the function returns something then yea, but not as a void or the way you have it.

Code:
void setup()
{
  Serial.begin(115200);

  for( byte idx = 0; idx < 10; idx++)
  {
    Serial.print("At index: "); Serial.print(idx);
    if( foo( idx ) == true)
    {
      Serial.println(", it was TRUE");
    }
    else
    {
      Serial.println(", it was FALSE");
    }
  }
}

void loop() {/* not being used */ }

boolean foo(byte x)
{
  if(x > 4 && x < 7)
    return true;
  else
    return false;
}
288  Using Arduino / Project Guidance / Re: Phantom reads into a 4051 on: June 08, 2014, 01:39:12 am
I'm willing to bet you don't have any pulling resistors (pull up or pull down) in which case the pin is considered floating. But as Raschemmel suggested, you should post a schematic or photo.
289  Using Arduino / Programming Questions / Re: If else statement for two pots and two LED's on: June 07, 2014, 11:15:37 pm
Quote
One other thing, when using the Serial monitor, you should not be using pins 0 or 1,
const int LED1 = 1;
290  Using Arduino / Programming Questions / Re: If else statement for two pots and two LED's on: June 07, 2014, 10:58:45 pm
Declare your variables, don't make them all CAPS and don't make them const, otherwise you wont be able to change them.
int analogValue1;
int analogValue2 ;

Now in your loop, you want to read from the analog pins.
void loop
{
  analogValue1 = analogRead(analogPin1); // these should not be CAPS either
  analogValue2 = analogRead(analogPin2);
.
.
.
}

One other thing, when using the Serial monitor, you should not be using pins 0 or 1,
const int LED1 = 1;
291  Using Arduino / Project Guidance / Re: I finally tested the accuracy of delay() for 24 hours. on: June 07, 2014, 08:09:35 pm
Thats great, but no one uses delays. An experienced programmer will tell you to never use delays throughout your code, but to instead use the millis() or micros() function to keep track of time.

Edit: Good find.
292  Development / Other Software Development / Re: New TFT Extension Library on: June 07, 2014, 02:59:12 pm
UPDATE!

Library is below.
293  Using Arduino / Programming Questions / Re: Help me in pressure sensor read from 0 - 10Vdc 0-250 bar on: June 07, 2014, 12:01:36 pm
The pressure sensor needs 10v? What does it output then, I'm assuming more than 5v. If 125 Kpa is the max then with a little math 125/5 = 25, so why are you multiplying "volt" by 31.3, and not 25?
294  Using Arduino / Programming Questions / Re: Help me in pressure sensor read from 0 - 10Vdc 0-250 bar on: June 07, 2014, 11:29:02 am
Did you make the voltage divider circuit and does it work now?
295  Using Arduino / Project Guidance / Re: Mecanum Wheels on: June 06, 2014, 01:24:49 pm
This is the camera I am using Mini Wireless Security Camera with this mount Arduino Servo Mount
296  Using Arduino / Project Guidance / Re: Mecanum Wheels on: June 06, 2014, 12:57:10 pm
Wireless video stream.

The code snippet I gave is basically your Mode 1.
Mode 2 is a bit different, to strafe left and right, the wheels need to rotate opposite of each other.

Like so, F = forward, R = reverse
Left:   Right:
F        R   : (front wheels)
R        F   : (rear wheels)
297  Using Arduino / Displays / Re: Help Arduino Mega 2560 + 3.2" TFT LCD on: June 06, 2014, 11:39:35 am
Your using the UTFT and UTouch libraries, you should be able to run the calibration sketch. Attached is the calibration sketch, You may need to change a few lines to get it to work, like you pin numbers and model.
298  Using Arduino / Project Guidance / Re: Mecanum Wheels on: June 06, 2014, 10:39:39 am
This is my truck. http://youtu.be/aOkvHuVhnMA which original started from this (code wise) http://youtu.be/86x_E6Ngpmc
299  Using Arduino / Project Guidance / Re: Mecanum Wheels on: June 06, 2014, 09:59:10 am
Quote
I am only using 2 axis joystick. for example parallax 2 axis joystick hardwired to arduino mega on two analog inputs.
You want to hardwire the joystick to the same arduino, or make it wireless?

Either way you would need to convert the 0-1023 range from the joysticks to values for your motors. I used the map() function and a few IF/ELSE statements for my RC truck.

Here is my drive code(not the full code). My controller outputs 0 - 20 for both Forward/Reverse and Left/Right, then from those values, drive the motors accordingly.
Code:
void move(int z, int y, int s)

  //Movement varibles
  int DRV2 = map(z, 0, 10, 255, 0); //Reverse
  int DRV1 = map(z, 10, 20, 0, 255); // Forward
  int STRL = map(y, 0, 10, 255, 0); // Left
  int STRR = map(y, 10, 20, 0, 255);// Right

  if(z > 10)//forwards, Center point is 10, so if z is greater than 10, go forward, else reverse.           
  {
    //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 < 10)//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 == 10 && y > 10)//Right               
  {
    //Serial.println("360 left");
    digitalWrite(LMR, LOW);
    analogWrite(RMR, STRR);   
    analogWrite(LMF, STRR);
    digitalWrite(RMF, LOW);
  }
  else if(z == 10 && y < 10)//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);   
  }
  y=0; z=0; s=0;
}

Have you tested your motors with some simple code? Forward, reverse, left, right ?
300  Using Arduino / Project Guidance / Re: Mecanum Wheels on: June 06, 2014, 09:30:39 am
Good, now how do you plan on controlling it, what have you decided on? Both Xbox and Ps3 controllers will need the USB host shield and Bluetooth dongles to work. Or you can go with either paired bluetooth modules or RF modules. The "modules" are easier to learn and use, but are not compatible with a xbox or Ps3 controllers. The downside of these module is you would need a second arduino to act as a controller.

Quote
Two kangaroo motor controllers
Kangaroo makes motor controllers? Never mind

Alternative:
If you want, you can use a wireless Ps2 controller, which would give you the same range as a Ps3 or Xbox, and you won't need to buy a USB host shield or a second arduino. Also they are VERY cheap now, gamestop probably has them for $5 on the clearance rack.
Pages: 1 ... 18 19 [20] 21 22 ... 229