Pages: 1 [2]   Go Down
Author Topic: HELP!!!! new to programming  (Read 874 times)
0 Members and 1 Guest are viewing this topic.
Atlanta, USA
Offline Offline
Edison Member
*
Karma: 55
Posts: 1812
AKA: Ray Burne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
« Last Edit: July 31, 2013, 07:05:08 pm by craigcurtin » Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
#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...
}
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: 1 [2]   Go Up
Jump to: