Go Down

Topic: Specify "Pin"? (Read 630 times) previous topic - next topic

yosler

A little funny question, but, must I specify a pin number using "Pin"?
Code: [Select]
int ledPin = 13;
That should work. But would this?:
Code: [Select]
int led = 13;
I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

marco_c

Yes it all works. The name is irrelevant as the compiler and linker will simply translate it all to a memory address when it does it's job.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

GoForSmoke

You can make your code more easily clear or less clear through your choices of names for variables and functions. 

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

yosler

I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

James C4S

From a syntax point of view, it doesn't matter.

From a good-practices point of view, it is rather silly to name a variable "pin".  You already know it is a pin, why call the variable that?  Instead, call the variable what that pin is connected to and even better, the function.

"errorLED" or "startButton" or something descriptive like that is much more useful than "int pin = 12;" when you are reading the code.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up