Program Arduino Uno in C Language




Introduction: Program Arduino Uno in C Language

About: Curious by nature. Like to know how things works & love to learn about them. Especially electrical, electronics, mechanical, micro-processors.

Hello friends,

In this instructable, i have shown how to program Arduino Uno in C language.

Arduino uses its own language to program Arduino boards,Because its programming language is easy to understand.

But it can also be programmed in C language.

This instructable is beginners who are thinking to program Arduino Uno in C language. (I am a beginner too ;P )

So let's get started.

Step 1: Setting Up Things..

To write code in C, we need a software,
You can use AVR studio & any other coding software.

Here we will use code blocks, a light weight, easy to use & it has a built in software to directly upload code to your Arduino. you can download it here.

when download is done, open it & select new project.

A dialogue box will open.

Select AVR project,

( Yes, there is a Arduino project too, because code blocks also support Arduino programming language too. )

click Go,

Click Next

give the name of the project, (you can also change the destination folder for saving this project.)

click Next.

It will ask for the compiler, default compiler is already selected,

click Next

here you have to select chip of your Arduino, ( i am using Uno, so i will select Atmega328p.)

click finish.

A blank screen open. On the left side. There is work space

double click on sources & select main.c.

Step 2: Writing Code.

So we have set up all things

a text file is attached with instrctable, find & download it.

copy the code save in it & paste it in the screen.

{ understand the code.

<avr/io.h> to tell thi chip where all the ports & pins are located.

<util/delay.h> to use built in delay features. for accurate delay

DDRB Data direction register for port B

PORTB5 In Uno, PORTB5 is connected to digital pin 13.

BV bit value. }

now Click on the gear like icon located below the menu bar. it will compile & build all the necessary files.

Now go to tools in menu bar & Click on Arduino Builder.

Step 3: Uploading Code to Arduino...

A program will open.

Now attach the Uno to PC.

Click on Load sketch / hex file & browse the hex file from where you had stored it. ( default is in C drive/file_name/bin/debug/ )

Dont change Clock.

Select the COM port of Uno.

as soon you click on COM port, the Arduino Builder will start to program it.

when programming is done, L led on Uno should blink.

I have used Uno in this tutorial, but you can use any arduino, you just have to know which pin of IC is connected to which digital or analog pin of Arduino.

If you any suggestions or you get any error, you can write me in comment section below.

happy programming ^_^

Be the First to Share


    • Microcontroller Contest

      Microcontroller Contest
    • Automation Contest

      Automation Contest
    • Make it Glow Contest

      Make it Glow Contest



    10 months ago

    thanks for your tutorial. my main question is what is the advantage, if any, of doing things in c vs Arduino code?


    1 year ago

    i am getting like this, what to do now????

    Screenshot (2).png

    1 year ago

    How do I get an existing C program or library onto my Arduino Uno using codeblocks

    Suman Kumari
    Suman Kumari

    Question 2 years ago on Step 3

    hello sir..
    im a student of 3rd yr BSC doing a project on arduino uno for auto billing shopping cart..
    im not getting the circuit diagram for this project ..can u plz help me out .

    Suman Kumari


    Question 2 years ago on Step 2

    I couldn't find Arduino Builder in the tools menu.


    Question 2 years ago

    Hie can i get a soution for this; write a code which do binary counting using 8 led from o to 255


    Question 2 years ago on Step 3

    I will do this but in same other way like using breadboard connections connected to series resistance to the led then compile program and run it will start to blink


    Answer 2 years ago

    Not Resistance it is resister


    3 years ago

    led is not blinking not getting proper power to to control this?


    Reply 2 years ago

    Use resister series with led