Arduino Tutorial #1 – Digital Inputs & Outputs

I have played and learned Arduino a long time ago; around two years ago to be exact. I have build several projects with the Arduino, but never bothered putting up tutorials on how to use it until now.

In the first tutorial which you can see below, I walk through the basics: digital inputs and outputs for the Arduino.

The first example I write is the simple use of the LED on the 13th pin which already has a current limiting resistor.

int LED = 13;
void setup(){
pinMode(LED,OUTPUT);
}

void loop(){
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
}

The second example is an LED on the breadboard. In this case we need to connect a 120 ohm resistor in series with the LED. All that we needed to change in terms of the software was the pin that we used:

int LED = 12;
void setup(){
pinMode(LED,OUTPUT);
}

void loop(){
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
}

The final circuit in this series was the button which turns the LED on and off. The resistor used in my case was 47k pull-down resistor. I forgot to mention it at the beginning of my video…


int LED = 12;
int BUTTON = 4;

void setup(){
pinMode(LED,OUTPUT);
pinMode(BUTTON,INPUT);
}

void loop(){
if(digitalRead(BUTTON) == HIGH){
digitalWrite(LED,HIGH);
}else{
digitalWrite(LED,LOW);
}
}

Thank you for watching and make sure to comment on my video and let me know what else you would like to see in the future videos.