Show Posts
Pages: 1 2 [3] 4 5 ... 252
31  Using Arduino / Programming Questions / Re: 4x4 keypad for menu driven functions on: September 13, 2014, 11:37:20 pm
Make Num an array, NOT String Object and use a counter to see how many digits are entered. If the user enters more than 4, clear the array and start over.

It's very simple.
32  Using Arduino / Programming Questions / Re: How to read the position of 6 switches. on: September 13, 2014, 10:22:55 pm
You can use this sample sketch to check the overall result of the switches.

Code:
byte output;

void setup()
{
  Serial.begin(115200);
  for(byte i = 2; i <= 7; i++)
    pinMode(i, INPUT);
}

void loop()
{
  output = 0x01; // set output to 1
 
  for(byte i = 2; i <= 7; i++)
    output &= digitalRead(i); // reads pins 2 - 7, and using the AND logic, it multiples
                              //each result by output(0x01) and if any of the switchs are LOW
                              // output will equal 0

    if(output == 0x01) // if all switches were high, then output is still 0x01
    {
      // solenoid on
    }
    else // output = 0x00, a switch was LOW
    {
     //off
    }
}

NOTE: Make sure you have pull down resistors connected to the arduino pins, otherwise you may have incorrect results.
33  Using Arduino / Motors, Mechanics, and Power / Re: DC motor on: September 13, 2014, 07:52:39 pm
No, when you use the serial monitor, you need to send it yourself, it doesn't do it automatically. Try PuTTY, I use it myself and it does exactly what you want.
34  Using Arduino / Project Guidance / Re: Could I connect multiple 8x8 LED matricies (w/ MAX2719)? on: September 13, 2014, 07:43:39 pm
Easy, each one has 5 pins at the top and bottom.

(Top) VCC, GND, DOUT, CLK and CS.
(Bottom) VCC, GND, DIN, CLK and CS

All the CLK must be connected, as well as all the CS, top or bottom, it doesn't matter. What does matter is the DIN and DOUT pins, the first DIN will come from the Arduino, and then all the rest get DOUT(first display) -> DIN(second display), then DOUT(second display) -> DIN(third display) ... and so on.

These do take a bit of power each, so having multiple connected will take even more so, what you should do is power them with a good 5V wall charger at +700mA .

To get them to work you can either write the code yourself using shiftOut() or one of the already made libraries. (Search arduino 8x8 Dot matrix library)

I use LEDControl found HERE
35  Using Arduino / Project Guidance / Re: Working with RF Module on: September 13, 2014, 06:54:04 pm
Those don't use the virtual wire library, they are actually very straight forward. If you set D0 on the transmitter side to HIGH, then D0 on the receiver side will be HIGH.

What are you trying to do with them exactly, what is being controlled?
36  Using Arduino / Programming Questions / Re: Expected Unqualified-Id Before ')' Token on: September 12, 2014, 06:22:49 pm
You need to call your functions with () on the end of them, not just local; or auto;
37  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 04:23:02 pm
Try this.

Code:
int LEDRED = 11;
int LEDGREEN = 9;
int counter = 0;

void setup ()
{
  Serial.begin(9600);
  randomSeed(analogRead(0)); //Seed the random number generator
  pinMode(LEDGREEN, OUTPUT); // Configure green LED
  pinMode(LEDRED,OUTPUT); // Configure red LED
  digitalWrite(9, LOW); // Making sure the green LED is off
  digitalWrite(11, LOW); // Making sure the red LED is off
  Serial.println("Welcome to the dice game!");
}

void loop()
{
  int answer;
  int user;
  int computer;

  Serial.print('\n');
  Serial.print("Want to play? (1 = yes, 2 = no)");
  while(Serial.available() <=0); //Waiting while the user inputs vaule

  digitalWrite(9, LOW); // Making sure the green LED is off
  digitalWrite(11, LOW); // Making sure the red LED is off

  answer = Serial.parseInt(); //Recieves the vaule from the user
  switch(answer)
  {
  case 1:
    if(counter < 3) // regular
    {
      user = random(1,7);
      computer = random(1,7);
    }
    else
    {
      user = random(4,7);
      computer = random(1,3);
    }

    Serial.print('\n');
    Serial.println("The user rolls a");
    Serial.println(user);
    Serial.println("The computer rolls a");
    Serial.println(computer);

    if(user > computer)
    {
      counter = 0;
      Serial.println("You win!!!!");
      digitalWrite(LEDGREEN, HIGH);
      delay(3000);
    }

    else if(user < computer)
    {
      counter ++;
      Serial.println("You loose, Computer wins!");
      digitalWrite(LEDRED, HIGH);
      delay(3000);
    }
    else /*if(user ==computer)*/ // not needed anymore
    {
      counter =0;
      Serial.println("It's a tie!");
      digitalWrite(LEDRED, HIGH);
      digitalWrite(LEDGREEN, HIGH);
      delay(3000);
    }
    break;

  case 2:
    Serial.print('\n');
    Serial.print("You've hurt my feelings, I really wanted to play :/");
    break;

  default:
    Serial.println("Invalid response, please enter a 1 or 2");
  }
}
38  Using Arduino / Programming Questions / Re: Strange conflict between SdFat.write() and Serial.print() on: September 12, 2014, 04:10:25 pm
I'm not sure if this will make a difference, but you can try to put your strings in the flash memory with F().

Example:
Code:
Serial.print(F("got array [")); Serial.print(sample_arr); Serial.println(F("]"));
39  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 04:01:40 pm
Post your code, and please use code tags, its the # symbol above the smiley face.
40  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 03:53:29 pm
Quote
reseting to zero every time the game loops?
It should only reset when the user wins.
41  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 03:09:15 pm
Now when I place that in my code where would I place it? I would want it before the void loop, so I am thinking in the void setup?

It's practically already in your code, you just need to figure out where that is. (Hint: When the computer wins, counter++, when the user wins counter = 0.)

All you need to do after is have an if statement that sees if the user has lost 3 times and then on the next game, the user wins.

Quote
so I am thinking in the void setup?
A whole lot of good that will do for you. smiley-wink
42  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 03:02:29 pm
(face palm)
Do you know how to increment a variable (byte) by 1, and set it back to zero? If so you can use this to make a simple counter.

if( /*condition*/) // what condition would you put in here to see if the user has lost?
{
  //conditions is true
  counter++;
}
else // user has won, reset the counter to zero
{
  //condition is false
  counter = 0;
}
43  Using Arduino / Project Guidance / Re: Servo agitating water? on: September 12, 2014, 02:57:36 pm
Three Stooges re-runs  smiley-grin, im only 24.
44  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 02:54:42 pm
Please look at number 6, bullet point 6 of first post in this thread. Read this before posting a programming question

Where is the counter that keeps track of the number of times the user has lost?
45  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 12, 2014, 02:48:33 pm
Do you have an arduino to upload the sketch to and two different color LEDs? If so, run the sketch and use the serial monitor as the interface.

Pages: 1 2 [3] 4 5 ... 252