Loading...
Pages: [1]   Go Down
Author Topic: Specify "Pin"?  (Read 252 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 85
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
Offline Offline
God Member
*****
Karma: 14
Posts: 716
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


Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 31
Posts: 2947
I only know some basic electricity....
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 at Learning in the Main Site and at the Playground

Offline Offline
Jr. Member
**
Karma: 1
Posts: 85
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: 41
Posts: 5176
CMiYC
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

www.cmiyc.com - A guide to being an Enginerd

Pages: [1]   Go Up
Print
 
Jump to: