Show Posts
Pages: 1 ... 18 19 [20] 21 22 ... 196
286  Using Arduino / Programming Questions / Re: abort for-loop at any time on: February 22, 2014, 04:25:19 pm
Your not reading the signal pin in the for loop, your reading what it previously was and not what it currently is. Try to digitally read the pin while in the for loop.
287  Using Arduino / Project Guidance / Re: Controls for a project on: February 22, 2014, 04:21:01 pm
The library comes with an example sketch that shows you all the possibilities the library has to offer. Try it out.
288  Using Arduino / Programming Questions / Re: abort for-loop at any time on: February 22, 2014, 04:07:57 pm
break; will exit the for loop when it is called. So if you monitor the signal and it suddenly stops, you can call break; and it will exit the loop.

It does the same thing for while loops too.
289  Using Arduino / Project Guidance / Re: password activated garage on: February 22, 2014, 04:03:53 pm
Is it supposed to be '5000' or just 5000, because there is a major difference of the two.
290  Using Arduino / Project Guidance / Re: Controls for a project on: February 22, 2014, 01:50:29 pm
Here is a code to get you started, but you need to download the library in the Arduino Playground, link HERE.
Code:
#include <PS2X_lib.h>  //for v1.6

PS2X ps2x; // create PS2 Controller Class

int error = 0;
byte type = 0;
byte vibrate = 0;

int speed1 =128, speed2 = 128;

byte M1L = 5;// PWM
byte M1R = 3;// PWM
byte M2L = 6;// PWM
byte M2R = 9;// PWM

void setup(){
  Serial.begin(57600);

  //**************PAY ATTENTION*************
  pinMode(M1L, OUTPUT);                                // Establishes LEDPin as an output so the LED can be seen
  pinMode(M1R, OUTPUT);
  pinMode(M2L, OUTPUT);                                // Establishes LEDPin as an output so the LED can be seen
  pinMode(M2R, OUTPUT);
  error = ps2x.config_gamepad(13,11,10,12, true, true);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error

  if(error == 0)
    Serial.println("Controller found! You may now send commands");

  else if(error == 1)
    Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");

  else if(error == 2)
    Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");

  else if(error == 3)
    Serial.println("Controller refusing to enter Pressures mode, may not support it. ");

  type = ps2x.readType();
  switch(type)
  {
  case 0:
    Serial.println("Unknown Controller type");
    break;
  case 1:
    Serial.println("DualShock Controller Found");
    break;
  }
}

void loop()
{
  if(error == 1) //skip loop if no controller found
    return;

  else { //DualShock Controller

    ps2x.read_gamepad(false, vibrate);          //read controller and set large motor to spin at 'vibrate' speed

    if(ps2x.Button(PSB_L1))
    {
      // rotate turret left
    }
    else if(ps2x.Button(PSB_R1))
    {
      // rotate turret right
    }
    else
    {
      // do nothing
    }

    if(ps2x.Analog(PSS_LY) >= 136 && ps2x.Analog(PSS_LY) <= 255)//real center value is 128, but 140 is needed because controller is HIGHLY sensitive
    {
      speed1 = map(ps2x.Analog(PSS_LY),136 , 255, 0 , 255);
      analogWrite(M1L, speed1);
      digitalWrite(M1R, LOW);
    }
    else if(ps2x.Analog(PSS_LY) >= 0 && ps2x.Analog(PSS_LY) <= 120) //Same as above
    {
      speed1 = map(ps2x.Analog(PSS_LY),0 ,120 , 255 , 0);// create a set range for values and set output values respectively
      digitalWrite(M1L, LOW);
      analogWrite(M1R, speed1);
    } 
    else
    {
      digitalWrite(M1L, LOW);// all off
      digitalWrite(M1R, LOW);
    }
    //--------------------Right side motor----------------------- 
 
    if(ps2x.Analog(PSS_RY) >= 136 && ps2x.Analog(PSS_RY) <= 255)
    {
      speed2 = map(ps2x.Analog(PSS_RY),136 , 255, 0 , 255);
      analogWrite(M2L, speed2);
      digitalWrite(M2R, LOW);
    }

    else if(ps2x.Analog(PSS_RY) >= 0 && ps2x.Analog(PSS_RY) <= 120)
    {
      speed2 = map(ps2x.Analog(PSS_RY),0 ,120 , 255 , 0);
      digitalWrite(M2L, LOW);
      analogWrite(M2R, speed2);
    }

    else
   {
      digitalWrite(M2L, LOW);
      digitalWrite(M2R, LOW);
    } 
  }

  delay(50); // not needed, but give the robot some time to finish inputted commands   
}

291  Using Arduino / Project Guidance / Re: password activated garage on: February 22, 2014, 12:23:11 pm
This should be switching with idx, not 'Password'.
Quote
switch ('Password')

Press CTRL + T in your arduino sketch when your done writing something, it formats your code.
Not here on the forum.
292  Using Arduino / Project Guidance / Re: password activated garage on: February 22, 2014, 12:36:32 am
I fixed the code, try it now.
293  Using Arduino / Project Guidance / Re: password activated garage on: February 21, 2014, 11:17:42 pm
You took the pseudo code I gave you and literally copy and pasted it without understanding what it does or where things should have gone. I'm not surprised really.

I fixed the entire code and made it work. What you do once the password is correct is up to you.

Code:
#include <Password.h>
#include <Keypad.h>
#define Password_Lenght 4
#define Num_of_Passwords 3

Password password = Password( "1101" ); //password to unlock box, can be changed
Password password2 = Password ("1102");
Password password3 = Password ("1103");

Password PWs[ Num_of_Passwords ] = { password, password2, password3 };
const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
byte currentKey = 0;

char Data[Password_Lenght]; // 4 is the number of chars it can hold
byte idx = 0;

// Define the Keymap
char keys[ROWS][COLS] = {
  {
    '1','2','3','A'   }
  ,
  {
    '4','5','6','B'   }
  ,
  {
    '7','8','9','C'   }
  ,
  {
    '*','0','#','D'   }
};
 Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {
  9, 8, 7, 6};// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {
  5, 4, 3, 2 };

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
  //keypad.addEventListener(KeypadEvent); //add an event listener for this keypad // GIVES ERROR
}

void loop()
{
  char eKey = keypad.getKey(); // my method, but you can use eKey instead
  if (eKey) // check if a key is actually pressed.
  {
    Serial.print(eKey);
    Data[ currentKey ] = eKey; // currentKey is first set to 0.

    Serial.print(" ");
    Serial.println(currentKey);

    if( currentKey == Password_Lenght - 1)
    {
      Serial.println();
      currentKey = 0;
      checkPassword( Data );
    }
    else
    currentKey++;
  }
}

void checkPassword( char * myPass)
{
  Serial.print(myPass);
  Serial.println();

  while( idx < Num_of_Passwords )
  {
    Serial.print("Attempt: ");
    Serial.println(idx);
    for(byte P = 0; P < Password_Lenght; P++)
    {
      PWs[ idx ].append( myPass[P] ); // idx = 0
    }

    if (PWs[ idx ].evaluate())
    { 
      // show password is good message
      Serial.println("Password found");
      PWs[ idx ].reset(); // clear the password for next guess, NOTE: this does not delete the initialized passwords set above.
      idx = 0;
      break; // password was found, break out of while loop, OR go to a new function
    }
    else  idx++;
  }
 
  if( idx == Num_of_Passwords ) // if idx has reached the maximum number of passwords.
  {
    Serial.println("Password not found");
    for(byte i = 0; i < Num_of_Passwords; i++)
      PWs[ i ].reset(); // clear all passwords entered
    idx = 0;
    // show message "password was not found".
  }
}
294  Using Arduino / Programming Questions / Re: Annoying pinMode error please help on: February 21, 2014, 08:42:57 pm
PingPin2 should be actually set to pin 2 and not just named.
#define pingPin2 2

Or

byte pingPin2 = 2;
295  Using Arduino / Project Guidance / Re: Motor controlled by programmable interface: LCD + buttons on: February 21, 2014, 06:34:09 pm
Based on the links you provided, it looks more like a Raspberry Pi project then an Arduino project. The Raspberry Pi can record video for a set duration or be triggered manually (either software or hardware) to start and stop recording. The downside is, the coding language is Linux/Python, which I am not very good at otherwise I would give you some code to start with. But the Raspberry Pi can also interface with the Arduino if you still want to that. Sensors and motor could be controlled by the Arduino and a signal could be sent to the RPI to start recording if a sensor detects motion. Or you can have the RPI do everything itself, LCD interface, sensors and the motors, it up to you.

I found a rather useful link to get you started. RPI Surveillance
296  Using Arduino / Programming Questions / Re: compile error with LiquidCrystal_I2C on: February 21, 2014, 10:08:59 am
Do you have that chip as well and have you tried the code on that page?
If you have tried that exact code, try to change 0x38 to 0x27 or 0x20 and see if that makes a difference.
297  Development / Other Software Development / Re: New TFT Extension Library on: February 21, 2014, 02:24:40 am
Ah, ok I forgot about that. Thanks again Pyro.
298  Using Arduino / Project Guidance / Re: Intermediate kits to build onto the "The Arduino Starter Kit" on: February 20, 2014, 07:41:04 pm
Radio Shack sells some Arduino compatible kits that are rather pricey, but they come with a lot of great parts. You can also check online for such kits too.
299  Using Arduino / Programming Questions / Re: Feasibility of a temperature gauge on: February 20, 2014, 07:38:12 pm
Why not use an LCD screen instead of a servo? I have a code that you can modify to work with a TFT screen.
300  Development / Other Software Development / Re: New TFT Extension Library on: February 20, 2014, 06:35:06 pm
@PaulS

Is there anyway I can make the precompiler detect if someone actually has the UTFT or UTouch libraries and then have the precompiler determine what lines to enable for the library to work?
Pages: 1 ... 18 19 [20] 21 22 ... 196