Go Down

Topic: Naming shift register pin. (Read 436 times) previous topic - next topic


I'm trying to name shift register pin 1 to pRow1 and be able to turn it on and off with this name, instead of referring to it by it's pin number each time.

Right now, I can get it to turn on when I write:

setRegisterPin(1, HIGH);

but I want to be able to write

digitalwrite(pRow1, HIGH);

Is what I want to do possible? and if so, how do I make it happen?


Code: [Select]

#define pRow1 1

Code: [Select]

const int pRow1 = 1 ;
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Code: [Select]

const int pRow1 = 1

worked within the loop.


Oct 31, 2012, 12:59 am Last Edit: Oct 31, 2012, 03:55 am by lloyddean Reason: 1
EDIT: Restated

I'd suggest using more descriptive names, and not knowing your application domain, those in my example are rather lame -

Code: [Select]

const uint8_t   pinSHIFTREGISTER_ROW_1  = 1;
const uint8_t   SR_ROW_OFF              = LOW;
const uint8_t   SR_ROW_ON               = HIGH;

digitalWrite(pinSHIFTREGISTER_ROW_1, SR_ROW_ON);


Another way is to use an enum, for example:
Code: [Select]

  pRow1 = 1,
  pRow2 = 3,
  pRow3 = 8

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131