The numbering of the GPIO pins is total confusion to me.

I am testing this simple sketch that drives 2, DC Motors.
For the life of me I cannot figure out, nor find a reference that explains/defines what the proper pin numbers are. I.E.
board-pin = sketch-pin
I said GPIO in the subject but I could have that all wrong as well.
So, here is the sketch and here are the simple lines that defines what pins are to be used.

// Motor A

int enA = 9;
int in1 = 8;
int in2 = 7;

// Motor B

int enB = 3;
int in3 = 5;
int in4 = 4;

I have been struggling for at least a week to equate the sketch pin numbers to a board pin number.
The board that I am using is a Feather Huzzah.
Additionally, it seems that perhaps depending on the manufacturer and/or rev and/or ???, the stupid pin numbers may be different.
Also it seems that what I thought to be a GPIO pin, and under control of the sketch, was always on, even though it was not used in the sketch. That was pin 2, TX.

/*  
  L298N Motor Demonstration
  L298N-Motor-Demo.ino
  Demonstrates functions of L298N Motor Controller
  
  DroneBot Workshop 2017
  http://dronebotworkshop.com
*/
  

// Motor A

int enA = 9;
int in1 = 8;
int in2 = 7;

// Motor B

int enB = 3;
int in3 = 5;
int in4 = 4;

void setup()

{

  // Set all the motor control pins to outputs

  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

}

void demoOne()

{

  // This function will run the motors in both directions at a fixed speed

  // Turn on motor A

  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);

  // Set speed to 200 out of possible range 0~255

  analogWrite(enA, 200);

  // Turn on motor B

  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);

  // Set speed to 200 out of possible range 0~255

  analogWrite(enB, 200);

  delay(2000);

  // Now change motor directions

  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);

  delay(2000);

  // Now turn off motors

  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);

}

void demoTwo()

{

  // This function will run the motors across the range of possible speeds
  // Note that maximum speed is determined by the motor itself and the operating voltage

  // Turn on motors

  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);

  // Accelerate from zero to maximum speed

  for (int i = 0; i < 256; i++)

  {

    analogWrite(enA, i);
    analogWrite(enB, i);

    delay(20);

  }

  // Decelerate from maximum speed to zero

  for (int i = 255; i >= 0; --i)

  {

    analogWrite(enA, i);
    analogWrite(enB, i);

    delay(20);

  }

  // Now turn off motors

  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);  
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);  

}

void loop()

{

  demoOne();

  delay(1000);

  demoTwo();

  delay(1000);

}

which arduino board are you using?

gcjr:
which arduino board are you using?

I think it says The board that I am using is a Feather Huzzah.

The board-pin IS the sketch-pin. What makes this difficult ?

Yes, getting from board-pin to microcontroller-pin is tricky but that is a different story.

When in doubt, check Pinouts | Adafruit Feather HUZZAH ESP8266 | Adafruit Learning System.

hextejas:
I think it says The board that I am using is a Feather Huzzah.

You 'Think' ?

A good starting point would be to be certain which board you are using .........

srnet:
You ‘Think’ ?

A good starting point would be to be certain which board you are using …

No, the original post on this thread definitely says Feather Huzzah.

There are little numbers written on the board next to the pins. Use those numbers in your sketch.

The ESP8266 is a bit weird, because it doesn’t have that many pins, and some of the pins it does have are restricted to particular uses (pins that connect to the on-module memory, for example.)
I don’t think that pins 7, 8, or 9 exist!

(Not Adafruit’s fault, BTW. The ESP8266 is a 32pin chip with 9 power pins, 6 pins for connecting to memory, 2 for a crystal, one (?) for the radio, and two for reset-like functions…)

srnet:
You 'Think' ?

A good starting point would be to be certain which board you are using .........

srnet why dont you go take a course in reading for beginners and STFU.

vaj4088:
The board-pin IS the sketch-pin. What makes this difficult ?

Yes, getting from board-pin to microcontroller-pin is tricky but that is a different story.

Would that it were so.
But I don't think so hence my questions here.
And by the way, what kind of pin does the sketch refer to ?
Is it a GPIO pin, a Digital pin, or some other type as is shown in the myriad of illustrations.

This from the Adafruit site as an explanation. Talks about 9 GPIO pins which are numbered somehow. So how are they called out in a sketch ? Is that what the #define does ?

Quote:
This breakout has 9 GPIO: #0, #2, #4, #5, #12, #13, #14, #15, #16 arranged at the top edge of the Feather PCB

All GPIO are 3.3V logic level in and out, and are not 5V compatible. Read the full spec sheet to learn more about the GPIO pin limits, but be aware the maximum current drawn per pin is 12mA.

These pins are general purpose and can be used for any sort of input or output. Most also have the ability to turn on an internal pullup. Many have special functionality:

I apologize for the confusion as the problem sketch that I am trying to make work is for an Arduino Uno whereas I am trying to modify it to work with a Feather Huzzah.

I guess that swapping boards like this is not so easy.

On an Uno, the “sketch pin numbers” and the “board pin numbers” are the same. Since the board shape is “odd”, and there wasn’t any “prior art”, there was little confusion. Moving to a different form factor, a different processor, with different (and fewer) chip pins, adds confusion. The sketch pin numbers are still the same as the board pin numbers, but you pretty much you have to find the specific board-level documentation to figure out what the “board pin numbers” are.

The motor driver board has six control pins, three for each side of the dual H-bridge. They should be labeled on the motor driver board. Wire them to six output pins on your HUZZAH and change the pin numbers in the sketch to match the pins you connected to the driver board.

The pin numbers for an Arduino Motor Shield are chosen in a strange order because only six Arduino UNO pins are set up for PWM/analogWrite(). The enA and enB pins are connected to two of those six pins (3 and 9) to get speed control. If the choice of PWM/analogWrite() pins is limited on your target board you should assign the enA and enB signals to PWM/analogWrite() pins.

hextejas:
…the problem sketch that I am trying to make work is for an Arduino Uno whereas I am trying to modify it to work with a Feather Huzzah.

Board pins (marked on the Printed Wiring Board) are sketch pins. Period. If you use the pins on a Feather Huzzah that were used on the Uno, then there should be no issue. If the Uno uses pins that do not exist on the Feather Huzzah, then you have a problem and will have to modify the sketch for whatever pins you substitute on the Feather Huzzah for the pins used on the Uno. Just the same, the pins are marked on the Uno Printed Wiring Board and are marked on the Feather Huzzah Printed Wiring Board. They may be located differently but (for example) pin 3 in the sketch is pin 3 on an Uno and if you move things correctly it will be pin 3 on the Feather Huzzah.

All pins on an Uno board have +5 volt digital capability, also known as GPIO. Various pins also have additional capabilities available, such as PWM, Serial I/O, analog input to an ADC, hardware SPI, hardware I2C, etc. etc.

vaj4088:
. They may be located differently but (for example) pin 3 in the sketch is pin 3 on an Uno and if you move things correctly it will be pin 3 on the Feather Huzzah.

Thank you van but for the life of me, I don't see any pin on the huzzah which is #3.

Can anyone point me to it

hextejas:
Thank you van but for the life of me, I don't see any pin on the huzzah which is #3.

OK, there isn't. So use a pin that is there and available for GPIO. Why is that concept so difficult?

OK, perhaps 3 was a poor choice. I originally used X but decided that something more specific was needed. If you don't like 3, replace 3 with a number that is present on the Feather Huzzah.

gfvalvo:
OK, there isn't. So use a pin that is there and available for GPIO. Why is that concept so difficult?

Its helpful gfvalvo, that you said " available for GPIO ", That was not clear nor apparent to me, and I think that I asked about it in my original post.
It still prompts more questions, eg:
What turns them on/off ? I am presuming it is the code in the sketch.
Like

#define EnA 10;
#define EnB 5;

The comments associated with the sketch says that in order to control the speed of the motor, the control pins need to be connected to PWM enabled pins.
How do I do that ? Is a GPIO pin also a PWM pin ?

Can anyone point me to some decent reference material that will help me sort this out .

Thanks and apologies for any and all headaches I might have caused.