In this tutorial:
Pins -- the holes on your Arduino and how to use them
Ports--Collections of pins
Programming--Basic programming with the arduino
Remove these ads by
Signing UpStep 1What you need:
LEDs -- at least one
Resistors --as many as you have LEDs (use this calculator to calculate what you need. Voltage = 5)
Breadboard (optional)
Wire (optional)
Cable to connect Arduino to Computer
Software (not all that hard to install, not going over it in this tutorial, see this for how to install and other arduino usages get it here)
| « Previous Step | Download PDFView All Steps | Next Step » |










































can be changed
for example become
int Col1 = 5
this tells the arduino that the pin 5 will be called from now on Col1 ?
thanks phevos
saying int Col1 = 5 is only assigning the number 5 to a variable which is of type integer.
The digitalWrite command has two inputs: The pin number and the value. So, digitalWrite(Col1, HIGH), takes the pin at the value of Col1, in this case 5, and sets it to HIGH.
"this tells the arduino that the pin 5 will be called from now on Col1"
A bit of ambiguous wording there, you might have the right idea in your head but the way I read it, it is partially wrong.
int Col1 = 5
simply says that for the time being, until Col1 is changed, the value in Col1 will be 5. We then choose to use this value of Col1 to drive a specific pin.
The part of your interpretation that I don't like is that the way you said it, you implied that pin 5 is directly tied to Col1. If, for example, we did the following after the int Col1=5:
Col1 = Col1 + 1;
Col1 now will equal 6, and
digitalWrite(Col1, HIGH);
will drive a logic high to whatever is connected to pin 6.
Out of curiosity, what are you working on? Col1 implies something with columns, like a display...
int col1=5 tells arduino that when i write col1 i mean 5 , and when i i type
digitalWrite(col1,HIGH) it will be like digitalWrite(5,HIGH) with 5 representing the pin but if the variable col1 is changed ...ahmmmm destruction?
Nice instructable - one minor point:
In step 5 you have the following line:
The pins in the register are arranged from lower number = Least Significant Bit to Highest number - Most Significant Bit (so to get pins 0-3 to equal 0 and 4-7 to equal 1 it would be PORTX = B11110000)
The last part should say PORTD=B11110000 not PORTX
The code that follows is correct - but a newbie learning arduino from this example might be confused by that line.
I was trying to write in a way that was ambiguous so that people could see how it worked for all ports, but it probably does make more sense writing it your way..