Go Down

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

mmaier7

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?

MarkT

Code: [Select]

#define pRow1 1

or
Code: [Select]

const int pRow1 = 1 ;
[ I won't respond to messages, use the forum please ]

mmaier7

Thanks!
Code: [Select]

const int pRow1 = 1


worked within the loop.

lloyddean

#3
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);


guix

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

enum
{
  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!

Arduino
via Egeo 16
Torino, 10131
Italy