Show Posts
Pages: 1 ... 65 66 [67] 68 69 ... 232
991  Using Arduino / Project Guidance / Re: Help on trivia game project on: January 27, 2014, 12:24:32 pm
Will the audio recording be on an MP3 shield or outside unit?

Quote
Pushing the button will lock the other person out.
Is this just one panel or individual panels? Never mind

Quote
If it is correct it will add 1 to the persons score and go to the next question. If it is wrong it will just go to the next question. I am not sure how I will show the score.
This is  really straight forward. Will you be using an LCD display, 7 Segment display, or Serial monitor?

Quote
How should I store and check the answers?
If you use and MP3 Shield, you can use an array to store the track number and correct answer letter/button/pin whatever. If you use an outside unit, then you will need to make sure the correct track is played in order to match it with the correct answer.
992  Using Arduino / Project Guidance / Re: My 1st project: TIE Crawler from the Star Wars Expanded Universe on: January 27, 2014, 09:35:51 am
Well if you want to make it out of Legos, you can still use an Arduino as the brain. This link HERE is my video where I have done just that. It can be controlled via Bluetooth, so I can use a computer, tablet, or android phone to control it. Right now I am using a wireless PS2 controller to control it.

Making it out of Legos, is easy. I was going to suggest you use Lego treads, but since you mentioned you wanted it to look impressive, I scraped the idea.
993  Using Arduino / Programming Questions / Re: Adding buttons to my Simon Says game & general questions. on: January 27, 2014, 04:43:27 am
Play around with mine, change some variables and learn how it works. If you haven't noticed, it is 99% identical to your simon says game. What makes mine different from yours?
994  Using Arduino / Programming Questions / Re: Adding buttons to my Simon Says game & general questions. on: January 26, 2014, 08:33:44 pm
Sorry I didn't respond sooner, busy. Here is my memory game that I think you can learn from, it uses 3 buttons and 3 LEDs.

Code:
/*
  This code is set for buttons to be normally LOW by default.
 To change from normally LOW to HIGH, use "if (buttonState[count] == LOW && buttonState[count] != lastButtonState[count]) "
 */
const byte Num_of_Pins = 3;

byte LEDpin[Num_of_Pins] = {
  5,6,7}; //on-board LED
byte ButtonPin[Num_of_Pins] = {
  2,3,4}; //digital pin 2
byte ledList[32] = {  // renamed to yours
  7,5,6,5};
byte buttonState[Num_of_Pins] = {
  0,0,0};
byte lastButtonState[Num_of_Pins]={
  0,0,0};
byte Pat_count = 4,Btemp = 0;
byte i = 0, output = 0;

int Speed = 300;
int temp = 0, count = 0;

long lastDebounceTime[Num_of_Pins]; 
long debounceDelay = 50;
long time;

boolean PatternStatus = false;
void setup()
{
  randomSeed(A4/A5);
  Serial.begin(9600);
  for(int cnt = 0; cnt < Num_of_Pins; cnt++)
  {
    pinMode(LEDpin[cnt], OUTPUT);
    pinMode(ButtonPin[cnt], INPUT);
  }
}

void loop() {
  showPattern();
  VerifyButtons();
}

void showPattern()
{
  for(byte pattern = 0; pattern < Pat_count; pattern++)
  {
    time = millis();
    while(millis() - time < Speed)
    {
      digitalWrite(ledList[ pattern ], HIGH);
    }
    time = millis();
    while(millis() - time < Speed)
    {
      digitalWrite(ledList[ pattern ], LOW);
    }
  }
}

void updatePattern()
{
  if(Pat_count > 32) Serial.println("Player has won the game");
  else Pat_count++;
  ledList[Pat_count - 1] = random(5, 7);   
}

void VerifyButtons()
{
  i = 0;
  while(i < Pat_count)
  {
    Btemp = Getbutton();
    if(Btemp)
    {
      Serial.println(Btemp);
      if(ledList[i] == (Btemp+Num_of_Pins))
      {
        i++;     
        PatternStatus = true;
      }
      else
      {
        PatternStatus = false;
        break;
      }
    }     
  }
  if(PatternStatus == true)
  {
    Speed -= 9;
    Serial.println("Pattern was Good");
    updatePattern();
  }
  else Serial.println("Player Lost");
}

byte Getbutton()
{
  output = 0;
  for(count = 0; count < Num_of_Pins; count++) // loop through all the buttons
  {
    buttonState[count] = digitalRead(ButtonPin[count]); // read button states
   
    if ((buttonState[count] == HIGH)&&(buttonState[count] != lastButtonState[count])) // check to see if the state has changed from last press
    {
      output = ButtonPin[count];
      lastDebounceTime[count] = millis(); // record the time of the last press
      while((millis() - lastDebounceTime[count]) < 50);
    }
    lastButtonState[count] = buttonState[count];
  }
  return output;
}
995  Using Arduino / Programming Questions / Re: Adding buttons to my Simon Says game & general questions. on: January 26, 2014, 09:39:02 am
Well, you still have 8 hours to learn. I already told you what you had to do after you debounced the buttons, which you could hold of on, but it may give faulty results if you do.

Quote
. . . then you need to cycle through them and compare them to the lit LED. A simple FOR should work. Your buttons are 5 pins lower to your LEDs, so you can start on pin 4 (button) and see if the corresponding LED (+5) is lit. If the LED is lit add the next pattern, if it's not then player has lost.

In this case, you need to cycle through your pattern and see if the correct buttons were pressed. If they were, then add another LED or sequence to your pattern, and if not, then player has lost.
996  Using Arduino / Programming Questions / Re: Adding buttons to my Simon Says game & general questions. on: January 26, 2014, 07:30:13 am
Thankfully I keep all my past sketches.

Code:
/*
  This code is set for buttons to be normally LOW by default.
  To change from normally LOW to HIGH, use "if (buttonState[count] == LOW && buttonState[count] != lastButtonState[count]) "
*/

byte LEDpin[2] = {
  4,5}; //on-board LED
byte ButtonPin[2] = {
  2,3}; //digital pin 2

int buttonState[2];
int last[2];
int lastButtonState[2];

long lastDebounceTime[2]; 
long debounceDelay = 50;

void setup() {
  for(int count = 0; count < 2; count++) {
    pinMode(LEDpin[count], OUTPUT);
    pinMode(ButtonPin[count], INPUT);
  }
}

void loop() {
  for(int count = 0; count < 2; count++) // loop through all the buttons
  {
    buttonState[count] = digitalRead(ButtonPin[count]); // read button states

    if ( buttonState[count] && buttonState[count] != lastButtonState[count]) // check to see if the state has changed from last press
    {
      lastDebounceTime[count] = millis(); // record the time of the last press
      lastButtonState[count] = buttonState[count]; // update last press state
    }

    if ((millis() - lastDebounceTime[count]) > debounceDelay)  // check to see if the desired time has passed
    {
      digitalWrite(LEDpin[count], buttonState[count]); // output results
    }
  }
}
997  Using Arduino / Programming Questions / Re: Midi Input, Led. almost working but not very well :( on: January 26, 2014, 07:09:57 am
Try this one too.

Code:
#define MIDI_CHANNEL 1

byte incomingChannel;    //Read the incoming MIDI channel
byte incomingNote;       //Read the incoming MIDI note
byte incomingVelocity;   //Read the incoming note value
byte LEDs[8]={
  A8,A9,A10,A11,A12,A13,A14,A15};
byte ledStatus[8];


void setup()
{
  Serial.begin (115200);         
  for(byte p = 0; p < 8; p++)
  {
    pinMode(LEDs[p],OUTPUT);
  } 



void loop()
{
  if(Serial.available() > 2)
  {
    incomingChannel = Serial.read();
    incomingNote = Serial.read();
    incomingVelocity = Serial.read();

    if(incomingChannel == MIDI_CHANNEL+143)
    {
      if(incomingNote == 41)
      {
        if(incomingVelocity == 127)
          ledStatus[0] = 1;
        else
          ledStatus[0] = 0;
      }

      if(incomingNote == 42)
      {
        if(incomingVelocity == 127)
          ledStatus[1] = 1;
        else
          ledStatus[1] = 0;
      }
     
      for(byte D = 0; D < 8;D++)
        digitalWrite(LEDs[D],ledStatus[D]);

    }
  }
} //End of loop()


998  Using Arduino / Programming Questions / Re: Midi Input, Led. almost working but not very well :( on: January 26, 2014, 06:49:20 am
There are better codes out there then what you have, that may help you better. Here is a link, CLICK HERE Take a look at the middle example.
999  Using Arduino / Programming Questions / Re: Midi Input, Led. almost working but not very well :( on: January 26, 2014, 06:21:05 am
CTRL + T for starters. Next make it readable.
1000  Using Arduino / Programming Questions / Re: Midi Input, Led. almost working but not very well :( on: January 26, 2014, 06:02:31 am
Your code is a train wreck, please fix the format so it looks presentable and possibly readable.
1001  Using Arduino / Programming Questions / Re: Reading characters from LCD on: January 26, 2014, 06:00:26 am
Are you referring to a memory dump? LCD screens don't store any data, they just display what you tell them. If you want to keep a record if what was displayed, you will need to make an array for each row and update it every time you add something new.
1002  Using Arduino / Programming Questions / Re: Adding buttons to my Simon Says game & general questions. on: January 26, 2014, 05:57:16 am
It might work, but your really better off debouncing them. This way if you game doesn't work, you'll know it's not the buttons causing it, but another issue. Why leave gaps if you don't want to fall in later?
1003  Using Arduino / Programming Questions / Re: Touch screen calibration problem. on: January 25, 2014, 07:02:40 pm
@PaulS, with those type of LCD displays, you can't use the serial monitor. This is because the pins 1 and 0 are used as the data buses. So his only means of debugging is the screen itself. And he does in fact have a debug screen.

Quote
if (Touch.dataAvailable())
    {
       Touch.read();
       x=Touch.getX();
       y=Touch.getY();
    }
   else
    {    
       x=0;
       y=0;  
    }
    
    LCD.setFont(BigFont);
    LCD.setColor(VGA_WHITE);
    LCD.print("X=",0,60);
    LCD.print("Y=",0,80);
    LCD.print("      ",40,60);
    LCD.printNumF(x,0,40,60); //Pomen (St. decimalnih mest,Postavitev po dolžini ekrana,Postavitev po višini ekrana)
    LCD.print("      ",40,80);
    LCD.printNumF(y,0,40,80);

    LCD.setColor(VGA_RED);
    LCD.fillRoundRect(100,150,200,200); //Pomen (Začetek po dolžini, začetek po višini, velikost po dolžini, velikost po višini)
  
   if ((y>=150) && (y<=200))
    {  
      if((x>=100) && (x<=200))
      {
       pritisnjen (0,0,50,50);
      }
 
    }
   else
    {
     nepritisnjen (0,0,50,50);
    }
1004  Using Arduino / Project Guidance / Re: My 1st project: TIE Crawler from the Star Wars Expanded Universe on: January 25, 2014, 06:52:40 am
Tanks use differential steering, which takes the difference of two motors. It probably can be done with a single motor but you will need a transmission to divide the power to the treads.

Added:
If you can find pancake motors, then you can mount the motors to the back plate and use gears to drive the treads.
1005  Using Arduino / Programming Questions / Re: Removing chars per index in a char array on: January 25, 2014, 06:36:43 am
Well one way would be to shift the elements.

for(byte d = 0; d < 20; d++)
{
   Array[d] = Array[d+1];
}

This will shift out the first element, and you use an IF statement, to add a NULL or 0 in the last element.

Or.

The other way would be to simply copy the elements of the Array to a new one, starting at the second element and stop before it gets to the last element.
Pages: 1 ... 65 66 [67] 68 69 ... 232