Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: teensyduino code on: April 18, 2011, 08:45:16 pm
Thanks for all of your help I got it to work.

This is my finished code

const int pinBtnUp = 0;
const int pinBtnDown= 1;
const int pinLEDOutput = 11;


boolean boolBtnUp;
boolean boolBtnDown;

void setup()
{
  //Setup the pin modes.
  pinMode( pinLEDOutput, OUTPUT );
 
  pinMode( pinBtnUp, INPUT_PULLUP );
  pinMode( pinBtnDown, INPUT_PULLUP );
  //Zero the SNES controller button keys:
  boolBtnUp = false;
  boolBtnDown = false;
}


void loop()
{
//  //debugging the start button...
  digitalWrite ( pinLEDOutput, digitalRead(pinBtnUp));

 
  fcnProcessButtons();
 
}


void fcnProcessButtons()
{
 
  boolean boolBtnUp = !digitalRead(pinBtnUp);
  boolean boolBtnDown = !digitalRead(pinBtnDown);
  if ( boolBtnUp )
  {
    //Set key1 to the U key
    Keyboard.set_key1( KEY_U );
  } else {
    Keyboard.set_key1( 0 );
  }
    if ( boolBtnDown )
  {
    //Set key1 to the U key
    Keyboard.set_key2( KEY_D );
  } else {
    Keyboard.set_key2( 0 );
  }
     
  //Send all of the set keys.
  Keyboard.send_now();


}
 smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin smiley-grin
2  Using Arduino / Programming Questions / Re: teensyduino code on: April 18, 2011, 08:10:30 pm
I tried BoolBtnUp = false; but they just keep on coming.
This is way harder than I thought. smiley-roll-sweat
3  Using Arduino / Programming Questions / Re: teensyduino code on: April 18, 2011, 12:30:18 pm
Thanks but when I type U or D once they don't stop.
 
I press the button once and instead of there being one d it does this dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.

111swords
4  Using Arduino / Programming Questions / teensyduino code on: April 17, 2011, 02:21:14 pm
I have had an arduino for a year now and just got a teensyduino 2.0.
I am still having a hard time with the code.
I wanted to make a usb controller for my computer it wold have about ten buttons on it.

This is the code I found.
I wonted to add more buttons to the code but I cant.

Can some one help.


const int pinBtnUp = 0;

const int pinLEDOutput = 11;

//Variables for the states of the SNES buttons
boolean boolBtnUp;


void setup()
{
  //Setup the pin modes.
  pinMode( pinLEDOutput, OUTPUT );
  //Special for the Teensy is the INPUT_PULLUP
  //It enables a pullup resitor on the pin.
  pinMode( pinBtnUp, INPUT_PULLUP );
 
  //Zero the SNES controller button keys:
  boolBtnUp = false;
 
}


void loop()
{
//  //debugging the start button...
  digitalWrite ( pinLEDOutput, digitalRead(pinBtnUp));

  //Progess the SNES controller buttons to send keystrokes.
  fcnProcessButtons();
 
}

//Function to process the buttons from the SNES controller
void fcnProcessButtons()
{
  //Assign temporary values for the buttons.
  //Remember, the SNES buttons are read as active LOW.
  //Capture their status here:
  boolean boolBtnUp = !digitalRead(pinBtnUp);
 
  if ( boolBtnUp )
  {
    //Set key1 to the U key
    Keyboard.set_key1( KEY_U );
  } else {
    Keyboard.set_key1( 0 );
  }
   
  //Send all of the set keys.
  Keyboard.send_now();


}
5  Using Arduino / Installation & Troubleshooting / Problem uploading to board. on: February 09, 2011, 02:19:16 pm
 smiley-roll-sweat  I can't upload anything to my arduino but when I try to it says
avrdude: stk500_retsync() : not in sync: resp=0x30
avrdude: stk500_disable() : protocol error, expect=0x14, resp=0x51.  smiley-mad

Can someone help.

111swords
Pages: [1]