Show Posts
Pages: 1 ... 104 105 [106] 107 108 ... 196
1576  Using Arduino / Programming Questions / Re: Needing a little bit of guidance for connecting arduino codes... on: April 18, 2013, 01:22:08 pm
Post what you have done.
1577  Using Arduino / Project Guidance / Re: Open source, cheap and Do It Yourself handeld console on: April 18, 2013, 01:19:29 pm
As a gamer, I am very interested in your project, but im a little concerned about the amount of memory it will use up.

Quote
Software, a library (I'm currently writing it) that will handle :
 - Frame rate, like the draw() function for people who know processing (done)
 - Button state : pressed, held, released (done)
 - Sprites : animation, rotation... (done)
 - User interface : Menus, settings, high scores... (ongoing)
 - Settings : sound, brightness, contrast... (ongoing)
 - Music/sound effects (to do)
 - Battery level indicator (to do)
 - Multiplayer synchronization (to do)
 - Performance monitor displaying cpu and ram use to optimize your games (done)
 - Examples and tutorials to understand how to code a game

That is a lot of memory usage for that particular Atmega chip. Even if you fit all of those in there, how much room will you have to write the games? Do you plan to embed them into the main code or make them as external SD cards?
1578  Using Arduino / Programming Questions / Re: Needing a little bit of guidance for connecting arduino codes... on: April 18, 2013, 12:55:17 pm
Quote
and the same for the button pin INPUT, but with its 1-6 range?
yes
1579  Using Arduino / Programming Questions / Re: Needing a little bit of guidance for connecting arduino codes... on: April 18, 2013, 12:28:09 pm
You will need to use FOR loops and change it to:

Code:
for(int ledCount = /*first led pin*/ ; ledCount < /* 1 + last led pin*/ ; ledCount++)
{
   pinMode(ledPin[ ledCount ], OUTPUT);
}
1580  Using Arduino / Programming Questions / Re: Needing a little bit of guidance for connecting arduino codes... on: April 18, 2013, 12:04:36 pm
You can't do it like that,
Quote
int buttonPin = 1, 2, 3, 4, 5, 6; // the number of the push button pin
int ledPin = 8, 9, 10, 11, 12, 13; // the number of the LED pin
but you can make them into arrays.
Quote
int buttonPin[] = {1, 2, 3, 4, 5, 6}; // the number of the push button pin
int ledPin[] = {8, 9, 10, 11, 12, 13}; // the number of the LED pin
Now if you do it this way, you will need to tweak your code a bit.

Note: if you plan to use the serial monitor, DONT USE pins 1 or 0 in your code.
1581  Using Arduino / Programming Questions / Re: Needing a little bit of guidance for connecting arduino codes... on: April 18, 2013, 11:22:40 am
Fixed
Added: You had quite a few errors that were hard to describe how to fix. About half way through of writing the progress, I just decided it would be easier just to do it myself.
Code:
int pinRead;
char pinAssignments[6] ={
  A0, A1, A2, A3, A4, A5};
byte PadNote[6] = {
  60, 62, 64, 65, 67, 69,};         // MIDI notes from 0 to 127 (Mid C = 60)
int PadCutOff[6] =
{
  400,400,400,400,400,400};           // Minimum Analog value to cause a drum hit
int MaxPlayTime[6] = {
  90,90,90,90,90,90};               // Cycles before a 2nd hit is allowed
#define  midichannel 1;                              // MIDI channel from 0 to 15 (+1 in "real world")
boolean VelocityFlag  = true;                           // Velocity ON (true) or OFF (false)

// set pin numbers:
int buttonPin = 2; // the number of the push button pin
int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
//*******************************************************************************************************************
// Internal Use Variables
//*******************************************************************************************************************
boolean activePad[6] = {
  0,0,0,0,0,0};                   // Array of flags of pad currently playing
int PinPlayTime[6] = {
  0,0,0,0,0,0};                     // Counter since pad started to play
byte status1;

int pin = 0;     
int hitavg = 0;
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
  Serial.begin(57600);                                  // connect to the serial port 115200

    // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }

  for(int pin=0; pin < 16; pin++)                          //
  {
    //int pin = 3;
    //   for (pinRead=0; pinRead < 16, pin++)
    hitavg = analogRead(pinAssignments[pin]); 
    //Serial.println(hitavg);   
    // read the input pin

    if((hitavg > PadCutOff[pin]))
    {
      if((activePad[pin] == false))
      {
        if(VelocityFlag == true)
        {
          //          hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin]));    // With full range (Too sensitive ?)
          hitavg = (hitavg / 8) -1 ;                                                 // Upper range
        }
        else
        {
          hitavg = 127;
        }
        MIDI_TX(144,PadNote[pin],hitavg); //note on

        PinPlayTime[pin] = 0;
        activePad[pin] = true;
      }
      else
      {
        PinPlayTime[pin] = PinPlayTime[pin] + 1;
      }
    }
    else if((activePad[pin] == true))
    {
      PinPlayTime[pin] = PinPlayTime[pin] + 1;
      if(PinPlayTime[pin] > MaxPlayTime[pin])
      {
        activePad[pin] = false;
        MIDI_TX(144,PadNote[pin],0);
      }
    }
  }
}

//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
  status1 = MESSAGE + midichannel;
  Serial.write(status1);
  Serial.write(PITCH);
  Serial.write(VELOCITY);

}


Its not tested but it should work.
1582  Using Arduino / Project Guidance / Re: Any help/ideas on the project? Arduino UNO+Sim900 shield on: April 18, 2013, 10:00:26 am
It is very difficult to go through your code the way it is, use the auto format tool in the IDE or just press "Ctrl+T". Another thing is why are you putting semicolons on the closing brackets at the end of setup() and loop() " }; " ?
1583  Using Arduino / Displays / Re: SainSmart 3.2" TFT LCD and Touch..HELP!!!! on: April 18, 2013, 09:11:51 am
That particular LCD kit can be found on Ebay, and it usually has links to working libraries. Do a search for TFT 3.2 touch screen Mega, and you should be able to find it with no problems. Also make sure you put the libraries in the arduino sketch folder >> libraries, commonly located in your "my documents"
1584  Using Arduino / Project Guidance / Re: Open source, cheap and Do It Yourself handeld console on: April 18, 2013, 06:55:37 am
It looks like a miniature Sega Gamegear. The color scheme makes it look like an old Game and Watch handheld.
1585  Using Arduino / Programming Questions / Re: Virtual Wire Problem on: April 17, 2013, 02:38:00 pm
What happens when you compile one of the virtual wire examples?
1586  Using Arduino / Programming Questions / Re: Virtual Wire Problem on: April 17, 2013, 02:09:32 pm
There are two folders, arduino - 1.0.3(program folder) and arduino(sketch folder). The Arduino sketch folder is usually in your "my documents". In that folder should be a "libraries" folder, it goes in there.
1587  Using Arduino / Programming Questions / Re: Virtual Wire Problem on: April 17, 2013, 01:37:35 pm
No, those are core libraries. The virtual wire library is not a core library, so it needs to go in the sketch folder => libraries.
1588  Using Arduino / Programming Questions / Re: Virtual Wire Problem on: April 17, 2013, 01:18:27 pm
That does not look like your sketch folder. It needs to be in the sketch folder under libraries. If there is no libraries folder, make one.
1589  Using Arduino / Programming Questions / Re: Virtual Wire Problem on: April 17, 2013, 01:12:43 pm
Where did you put/install the virtualwire library?
1590  Using Arduino / Project Guidance / Re: Need a help with Servo and IR sensor on: April 17, 2013, 12:40:53 pm
Instead of jumping right in with both the servo and sensor, test them both individually.

Your servo will not work properly, running on the 5 volts from the arduino. You will harm the arduino if you continue to do that. Get a separate power supply around 6 volts to power the servo.

Also the best way to see if your sensor is working, is to use the serial monitor.
Add Serial.begin(9600); to setup() and use Serial.println(analogRead(IRpin)); to see the values your getting from the sensor.
Pages: 1 ... 104 105 [106] 107 108 ... 196