Show Posts
Pages: 1 ... 30 31 [32] 33 34 ... 241
466  Using Arduino / Programming Questions / Re: Use of LCD 16x2 and Keypad 3x4, use of array of struct and string. on: June 08, 2014, 10:39:32 pm
There is a sticky post in bold orange, in the main screen, please read it. Code tags are a MUST, please highlite your code and click the # symbol above the smiley faces.

Also why is your lcd sharing the same pins as your keypad?
467  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.
468  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;
}
469  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.
470  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;
471  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;
472  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.
473  Development / Other Software Development / Re: New TFT Extension Library on: June 07, 2014, 02:59:12 pm
UPDATE!

Library is below.
474  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?
475  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?
476  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
477  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)
478  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.
479  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
480  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 ?
Pages: 1 ... 30 31 [32] 33 34 ... 241