Introduction: Short Blink Code for Arduino

Today, I am going to show you how to write really short code to blink Arduino's default LED as attached on board on pin number 13. Why I am doing this? Because, the blink code is the first code who has just begin to play with Arduino Uno, and first time user may face a lot of words to read, so that maybe seem so hard to code because the developer developed like this to run blink code, that should be so hard to do. NO! It is really basic that I will show you here in Instructable!

The need list:

1. Arduino Uno Board (Or any Arduino boards which has got pin 13 to a led)

2. USB Cable (For Arduino Uno users: USB A to USB B type cable is needed)

3. Arduino IDE loaded your computer (I wrote how to install Arduino IDE)

Step 1: The Original Blink Code

On Arduino IDE, follow this way: File >> Examples >> Basics >> Blink

/*
Blink Turns on an LED on for one second, then off for one second, repeatedly.

Most Arduinos have an on-board LED you can control. On the Uno and Leonardo, it is attached to digital pin 13. If you're unsure what pin the on-board LED is connected to on your Arduino model, check the documentation at http://www.arduino.cc

This example code is in the public domain.

modified 8 May 2014 by Scott Fitzgerald */

//the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin 13 as an output.

pinMode(13, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

Step 2: What I Did to Make It Easy

Open Arduino IDE, copy these codes below then paste into Arduno IDE:

void setup() {pinMode(13, OUTPUT);}void loop(){digitalWrite(13,1);delay(1000);digitalWrite(13,0);delay(1000);}

I count this line in Twitter post. I still have 30 free space. When you compile this code, you see no error.

Step 3: Bonus Idea: How to Force Coding Really Short?

Let me give you an idea about that. This would be the very small coding to blink. the idea is getting everything from library to pull from there to here as seems like that:

#include "b.h" void setup() {pinMode(13, OUTPUT);b();}

With these code, we said that we wrote a library is named as b.h for blink's b to blink. Then, we pull these to our IDE from there.

I repeat, this is an idea, I didn't wrote a code to do that.

That's all!

Step 4: BONUS: Reading This Instructable

NOTE: This instructable's step is aimed for visually impaired people to hear the sentences to learn what's going on here. Watch the video, it explains all steps.

Comments

author
MichaelJ2 (author)2016-03-28

Good job ...

Here's a 94 character version :)

void setup(){pinMode(13,OUTPUT);}void loop(){digitalWrite(13,(!digitalRead(13)));delay(1000);}

author
Bay Yolal (author)MichaelJ22016-03-28

Perfect Michael! What so interesting thing is deleting delay(1000); and using pin 1 instead pin 13. But, this is not we want. I am clapping your effort to do that! This sign (!) didn't come to my mind :D Thank you very much!

About This Instructable

603views

7favorites

License:

Bio: Electrical and Electronics Engineer in Istanbul. Open for fresh business inquiries.
More by Bay Yolal:How to use Raspberry Pi 3 Model B+ V1.2 For The First Time!How to knit baby booties in only one hour! Ta-Da!How to extract walnut
Add instructable to: