Pages: [1]   Go Down
Author Topic: Specify "Pin"?  (Read 495 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 101
Write befitting for a 13 year old!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A little funny question, but, must I specify a pin number using "Pin"?
Code:
int ledPin = 13;
That should work. But would this?:
Code:
int led = 13;
Logged

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

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 27
Posts: 1178
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

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

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

Logged

Examples can be found in your IDE.

Offline Offline
Full Member
***
Karma: 1
Posts: 101
Write befitting for a 13 year old!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you.
Logged

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6049
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: