Go Down

Topic: HELP!!!! new to programming (Read 987 times) previous topic - next topic

mrburnette

Apologies ... I assumed you were talking about the PC end.

Your buttons go to pins on the Arduino that are defined in statements like this
Code: [Select]

void setup() {
  pinMode(14, INPUT);  //enter
  pinMode(15, INPUT);  //up
  pinMode(16, INPUT);  //down
  pinMode(17, INPUT);  //left
  pinMode(18, INPUT);  //right
  //other setup code...
}


The 14 - 18 are Arduino pins NOT physical numbers.

Buttons are wired: http://arduino.cc/en/Tutorial/Button

craigcurtin

#16
Aug 01, 2013, 02:03 am Last Edit: Aug 01, 2013, 02:05 am by craigcurtin Reason: 1

Apologies ... I assumed you were talking about the PC end.

Your buttons go to pins on the Arduino that are defined in statements like this
Code: [Select]

void setup() {
 pinMode(14, INPUT);  //enter
 pinMode(15, INPUT);  //up
 pinMode(16, INPUT);  //down
 pinMode(17, INPUT);  //left
 pinMode(18, INPUT);  //right
 //other setup code...
}


The 14 - 18 are Arduino pins NOT physical numbers.

Buttons are wired: http://arduino.cc/en/Tutorial/Button


And you really want to look at some of the Debounce code options to ensure you are getting what you think you are getting from each of the buttons.

Have a look in the examples under digital for Button and Debounce

Craig

GoForSmoke


Apologies ... I assumed you were talking about the PC end.

Your buttons go to pins on the Arduino that are defined in statements like this
Code: [Select]

void setup() {
  pinMode(14, INPUT);  //enter
  pinMode(15, INPUT);  //up
  pinMode(16, INPUT);  //down
  pinMode(17, INPUT);  //left
  pinMode(18, INPUT);  //right
  //other setup code...
}


The 14 - 18 are Arduino pins NOT physical numbers.

Buttons are wired: http://arduino.cc/en/Tutorial/Button


One reason to learn the Control Examples in the IDE before writing your own code is to learn about arrays and for-loops.

Code: [Select]

#define KEYS 5;
byte keyPin[ KEYS ] = { 14, 15, 16, 17, 18 }; // easy to change once here, easy to use below
enum { enter, up, down, left, right } key; // learn about these later, just be aware

void setup() {
  for ( byte i = 0; i < KEYS; i++ ) // i will not exist outside of this for loop
  {
    pinMode( keyPin[ i ], INPUT );   
  }
  //other setup code...
}

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up