Program Arduino Uno in C Language


56,441

43

11

Introduction: Program Arduino Uno in C Language

Curious by nature. Like to know how things works & love to learn about them. Especially electrical,…

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 ^_^

1 Person Made This Project!

Recommendations

  • Frozen Treats Speed Challenge

    Frozen Treats Speed Challenge
  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • Tinkercad to Fusion 360 Challenge

    Tinkercad to Fusion 360 Challenge

11 Comments

0
Bozone44
Bozone44

1 year ago

When I went to select the chip set , the list did not have any Arduino Chips. IE: Atmega 328p

0
pwrbeats
pwrbeats

2 years ago

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

0
kaushal115
kaushal115

2 years ago

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

Screenshot (2).png
0
RobertH527
RobertH527

2 years ago

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

0
Suman Kumari
Suman Kumari

Question 3 years ago on Step 3

hello sir..
im a student of 3rd yr BSC ..im 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 .

regards
Suman Kumari

0
VinayG38
VinayG38

Question 4 years ago on Step 2

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

buildernotfound.png
0
Talkmore
Talkmore

Question 4 years ago

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

0
SanjuS23
SanjuS23

Question 4 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

0
SanjuS23
SanjuS23

Answer 4 years ago

Not Resistance it is resister

0
RohanP70
RohanP70

5 years ago

led is not blinking properly.like not getting proper power to it..how to control this?

0
SanjuS23
SanjuS23

Reply 4 years ago

Use resister series with led