Show Posts
Pages: [1] 2 3 ... 197
1  Using Arduino / Programming Questions / Re: Searching for info regarding the PS2X Library on: Today at 12:23:19 am
I might be able to explain why both motors go in reverse. I know if I just turn on my controller and don't press the analog button, it goes full reverse. This is because your telling the code to look at the analog stick, get a value and map it for the motors. If the analog button is not pressed, then the sticks output 0 and that in turn is mapped to full reverse.

This could also be done if the controller suddenly cuts off so maybe your adapter is not getting enough current or a stable 3.3 voltage. If you want, you can debug and use some serial prints to see what values are being sent to the robot.
2  Using Arduino / Programming Questions / Re: keypad on: April 23, 2014, 10:06:04 pm
Did you remember to change the number in Serial.begin() to the number that is found in the lower right corner of your serial monitor?
3  Using Arduino / Programming Questions / Re: keypad on: April 22, 2014, 06:14:14 pm
What you want to do is:
First, read the keypad, which you have done.

Second, see if a button is pressed, which again you have already done with if (key != NO_KEY )

Third, you want to convert the chars into an actual value. This is done simply with, n = n * 10 + (key - '0');. Where "(key - '0')" makes the char into a value by subtracting the char by 48 or '0'. Then adding it to "n * 10", where n must be set to zero before you add the converted value. Now once that is done, every value afterwards will concatenate into n, UNTIL, n is once again set back to zero.

Example using the serial monitor. Enter 123. or 25.
Code:
int num = 0;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if(Serial.available() > 0)
  {
    char c = Serial.read();
    //if(c != NO_KEY) // For keypad library
    //{
      if(c == '.') // if char == '.' then show the value. NOTE this can be changed to if(c == '*') or if(c == '#')
      {
        Serial.println(num);
        num = 0; // once shown reset num back to 0
      }
      else // char was not a period, so store the chars and convert them into num.
       num = num * 10 + (c - '0');
    //}
  }
}
4  Development / Other Software Development / Re: New TFT Extension Library on: April 22, 2014, 04:45:33 pm
Ok here is the current version of my library.

Sorry, in my drawMoon function, there was an error. I forgot to change one of the numbers from 120 to cy
Now it's fixed.
5  Using Arduino / Programming Questions / Re: Searching for info regarding the PS2X Library on: April 22, 2014, 04:11:37 pm
What are you using to move your robot, 360 servos or DC motors?

Post a picture of your robot and if possible the connections too.
6  Development / Other Software Development / Re: New TFT Extension Library on: April 22, 2014, 12:45:00 pm
Ok, Great then the HourGlass function, will be accurate to that length of time.
7  Development / Other Software Development / Re: New TFT Extension Library on: April 22, 2014, 12:04:11 am
Related to HourGlass function.

Does anyone know how long it takes for the millis function to rollover?
8  Using Arduino / LEDs and Multiplexing / Re: Need help changing code to change display orientation on: April 21, 2014, 07:34:38 pm
Can you send me a before and after video of what your seeing?
9  Using Arduino / LEDs and Multiplexing / Re: Need help changing code to change display orientation on: April 21, 2014, 07:02:53 pm
Ok the only other thing I can think of, is this. Open a new sketch and copy & paste the whole thing.
Code:
#include <TimerOne.h>

#define A { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,0,0,0}, \
  {0,0,1,0,1,0,0}, \
  {1,1,1,1,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define B { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,1,0,1,0,1,0}, \
  {0,0,1,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define C { \
  {0,0,0,0,0,0,0}, \
  {0,0,1,1,1,0,0}, \
  {0,1,0,0,0,1,0}, \
  {0,0,1,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define D { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,1,0,0,0,1,0}, \
  {0,0,1,1,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define E { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {1,0,1,0,1,0,0}, \
  {1,0,0,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define f { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,1,0,1,0,0}, \
  {0,0,0,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define G { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,1,0,1,0,1,0}, \
  {0,1,1,1,0,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define H { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,1,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define I { \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define J { \
  {0,0,0,0,0,0,0}, \
  {0,0,1,1,0,0,0}, \
  {0,1,0,0,0,0,0}, \
  {0,0,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define K { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,1,0,0,0,0}, \
  {1,1,0,1,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define L { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {1,0,0,0,0,0,0}, \
  {1,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define M { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,1,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define N { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,1,1,1,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define O { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {1,0,0,0,1,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define P { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,1,0,1,0}, \
  {0,0,0,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define Q { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,1,0,0,0,1,0}, \
  {0,0,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define R { \
  {0,0,0,0,0,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,1,0,1,0,0}, \
  {1,1,0,1,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define S { \
  {0,0,0,0,0,0,0}, \
  {1,0,1,1,1,0,0}, \
  {1,0,1,0,1,0,0}, \
  {1,1,1,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define T { \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,1,0,0}, \
  {1,1,1,1,1,0,0}, \
  {0,0,0,0,1,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define U { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,1,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define V { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {1,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define W { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,1,0,0,0,0}, \
  {0,1,1,1,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define X { \
  {0,0,0,0,0,0,0}, \
  {0,1,1,0,1,1,0}, \
  {0,0,0,1,0,0,0}, \
  {0,1,1,0,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define Y { \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,1,1,0}, \
  {0,1,1,1,0,0,0}, \
  {0,0,0,0,1,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define Z { \
  {0,0,0,0,0,0,0}, \
  {0,1,0,0,1,1,0}, \
  {0,1,0,1,0,1,0}, \
  {0,1,1,0,0,1,0}, \
  {0,0,0,0,0,0,0} \
}

#define DASH { \
  {0,0,0,0,0,0,0}, \
  {0,0,0,1,0,0,0}, \
  {0,0,0,1,0,0,0}, \
  {0,0,0,1,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define SPACE { \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0} \
}

#define DOT { \
  {0,0,0,0,0,0,0}, \
  {0,1,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0}, \
  {0,0,0,0,0,0,0} \
}


#define COLS 5
#define ROWS 7
#define PINS 13

#define MATRIX1 { \
  {1,0,1,0,1,0,1}, \
  {0,1,0,1,0,1,0}, \
  {1,0,1,0,1,0,1}, \
  {0,1,0,1,0,1,0}, \
  {1,0,1,0,1,0,1} \
}

#define MATRIX2 { \
  {0,1,0,1,0,1,0}, \
  {1,0,1,0,1,0,1}, \
  {0,1,0,1,0,1,0}, \
  {1,0,1,0,1,0,1}, \
  {0,1,0,1,0,1,0}, \
}

byte col = 0;
byte leds[COLS][ROWS];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[PINS]= {-1, 2, 9, 3, 11, 12, 13, 5, 6, 10, 4, 8, 7};

// col[xx] of leds = pin yy on led matrix
int cols[COLS] = {pins[1], pins[3], pins[10], pins[7], pins[8]};

// row[xx] of leds = pin yy on led matrix
int rows[ROWS] = {pins[12], pins[11], pins[2], pins[9], pins[4], pins[5], pins[6]};

const int numPatterns = 7;
byte patterns[numPatterns][COLS][ROWS] = {MATRIX2, S, C, E, A, K, MATRIX1};

int pattern = 0;

void setup() {
 
  Serial.begin(115200);
 
  // sets the pins as output
  for (int i = 0; i < PINS; i++)
  {
    pinMode(pins[i], OUTPUT);
  }

  // set up cols
  for (int i = 1; i <= COLS; i++)
  {
    digitalWrite(cols[i - 1], 0);
  }
  //  and rows
  for (int i = 1; i <= ROWS; i++)
  {
    digitalWrite(rows[i - 1], 1);
  }
 
  clearLeds();

  Timer1.initialize(2000);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(display);  // attaches display() as a timer overflow interrupt
 
  //setPattern(pattern);
}

void loop() {
 pattern = ++pattern % numPatterns;
 //slidePattern(pattern, 180);
 RotatePattern(pattern);
}

// Interrupt routine
void display()
{
  digitalWrite(cols[col], 0);  // Turn whole previous column off
  col++;
  if (col == 5) {
    col = 0;
  }
  for (int row = 0; row < 7; row++)
  {
    if (leds[col][(ROWS - 1) - row] == 1)
    {
      digitalWrite(rows[row], 0);  // Turn on this led
    }
    else
    {
      digitalWrite(rows[row], 1); // Turn off this led
    }
   // delay(10);
  }
  digitalWrite(cols[col], 1); // Turn whole column on at once (for equal lighting times)
}

void slidePattern(int pattern, int del)
{
  for (int l = 0; l < COLS; l++)
  {
    for (int i = 0; i < (COLS - 1); i++)
    {
      for (int j = 0; j < ROWS; j++)
      {
        leds[i][j] = leds[i + 1][j];
      }
    }
    for (int j = 0; j < ROWS; j++)
    {
      leds[4][j] = patterns[pattern][0 + l][j];
    }
    delay(del);
  }
}

void clearLeds()
{
  // Clear display array
  for (int i = 0; i < COLS; i++)
  {
    for (int j = 0; j < ROWS; j++)
    {
      leds[i][j] = 0;
    }
  }
}
 
void setPattern(int pattern)
{
  for (int i = 0; i < COLS; i++)
  {
    for (int j = 0; j < ROWS; j++)
    {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}

void RotatePattern(int pattern)
{
  for (int i = 0; i < 5; i++) //col
  {
    for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
    {
      leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
      //Serial.print(patterns[pattern][i][j]);
    }
    //Serial.println();
  }
}
10  Using Arduino / LEDs and Multiplexing / Re: Need help changing code to change display orientation on: April 21, 2014, 06:25:21 pm
In my function, in your setup(), change the 2 to p, and add a delay time.

Quote
I used your function as you stated in the comments next to the code, but it has made no difference. the letters are still going the wrong way and the 6th and 7th rows are still on all the time. heres the new code with your function added in.
It might be doing what you want, but I didn't add a delay, so change the function to this.
Code:
void RotatePattern(int pattern, int del)
{
  for (int i = 0; i < 5; i++) //col
  {
    for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
    {
      leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
      //Serial.print(patterns[pattern][i][j]);
    }
    //Serial.println();
    delay(del);
  }
}

You also need to comment out this line "setPattern(pattern);" and move what I gave you after it.

Quote
Also the reason that those letters are not centered is because that is they only way they are legible. if I center them the top will be cut off.
That doesn't sound good to me. If your telling it to show something in a 5x7 grid, then you should see everything and not have anything cut off.
11  Using Arduino / LEDs and Multiplexing / Re: Need help changing code to change display orientation on: April 21, 2014, 05:47:49 pm
Try this function. I don't have a 5x7 display, so I used the serial monitor. ALSO, you will need to fix your letter arrays. You must make all the letter be centered in the array.

Letters that are NOT centered and must be fixed.
A, E, F, H, I, K, L, O, R, S, T, V

Code:
[b]// Put this in setup() function.[/b]
for(byte p = 0; p < 5; p++)
  RotatePattern(2);

. . .

[b]//Put this at the bottom of sketch.[/b]
void RotatePattern(int pattern)  // This function will rotate everything in the center of the 5x7 letter arrays, within your pattern.
{
  for (int i = 0; i < 5; i++) //col
  {
    for (int j = 1; j < 6; j++) //row You want to be in a 5x5 box,
    {
      //Serial.print(patterns[pattern][i][j]);
      leds[5-j][i] = patterns[pattern][i][j]; // this will rotate the letter.
    }
    //Serial.println();
  }
//  Serial.println();
//   for (int i = 0; i < 5; i++) //col
//  {
//    for (int j = 1; j < 6; j++) //row
//    {
//      Serial.print(leds[i][j]);
//    }
//    Serial.println();
//  }
}
12  Using Arduino / Project Guidance / Re: Servo programming on: April 20, 2014, 07:21:30 pm
This part here is inside the IF statement and will only set the position back to 180 if your holding the button.
Quote
if ((pos == 0) || (pos < 0))
    {                             
      pos = 180;
      delay(5); // control speed to restart position
    }
What you need is to have a ELSE statement that tells the code what to do when you are not pressing the button or if you press then release the button.

Look into State machines.
13  Using Arduino / Project Guidance / Re: Servo programming on: April 20, 2014, 12:57:07 pm
Quote
if(digitalRead(leftPin) == HIGH)
Where is the else statement telling the servo to move the other way?
14  Using Arduino / Programming Questions / Re: the output pins are not effected by serial reading on: April 20, 2014, 11:37:17 am
Quote
char angle = Serial.read();  // You're reading in one char at a time
.
.
if(angle >= 0 && angle <= 30) // but yet you are looking for an actual value.
.
else if(angle > 30 && angle <= 90)

You should write a function or something that gets one or two chars and converts them into the values you want.
15  Using Arduino / Programming Questions / Re: Getting 'setColor' was not delaired in this scope error on: April 20, 2014, 01:14:10 am
Show me how you were able to use setColor to change the color of the LED. Post the code.
Pages: [1] 2 3 ... 197