INTRODUCTION TO
EMBEDDED C
What is Embedded C?
Embedded C is nothing but a subset of C
language which is compatible with certain
microcontrollers.
Some features are added using header files like
<avr/io.h>, <util/delay.h>.
scanf() and printf() are removed as the inputs are
scanned from the sensors and outputs are given
to the ports.
Control structures remain the same like ifstatement, for loop, do-while etc.
Development process of Embedded C
projects
Write C programs in AVR Studio IDE(Integrated
Development Environment)
Compile them into a .hex file using the AVR-GCC
compiler (which integrates into AVR Studio)
Simulate the target AVR program and debug the
code within AVR Studio
Program the actual chip using the USBasp device,
which is attached to our target board with a
special 6-pin cable
Once programmed, the chip runs the program in
your circuit
If-statement
Syntax:
if( condition)
{
statement.
}
else
{
statement..
}
Do- while statement
Syntax:
Initial counter
Do
{
statement.
update statement
}
While(condition);
For- statement
Syntax:
For( initial counter; test condition; update stmt)
{
statement..
statement...
}
Program:
for(int i=0;i<5;i++)
sprintf(str, Hello Robosapiens);
Creation of Arduino Projects
Home screen of Arduino
Creation of new Sketch
Coding
window
Compilation the code
Compile
Status
If there is no error
in the code the
compile
succeeded
without any error.
How to burn the sketch file
in Arduino Board
Connect one end of your USB Cable with
Computers USB Port and connect other end
with the Arduino board.
Click on to the button Serial Port.
Browse your Board to be used. Here we will be
using Arduino NG older w/ Atmega8
Finally click on to the Upload button to burn
the sketch file in the Arduino Board.
Finally after uploading the sketch you will see
a message on console.
THANK YOU