Getting Started

(lily) #1

Chapter 3: A Brief Introduction to C – What Makes Blinky Blink?


nguage was developed primarily to formalize these and related concepts and

The M


All C p a ‘ ain’ f ction code that is first run
when t s.


id)

for output

i = 1; i <= 128; i = i*2)

= ~i;
_loop_2(30000);

i = 128; i > 1; i -= i/2)

D = ~i;
ay_loop_2(30000);

la
force their use.


ain() Thing


rograms must have m un that contains the
he program begin

int main (vo
{
// Do something
}

Blinky has:


int main (void)
{
// set PORTD
DDRD= 0xFF;

while(1)
{
for(int
{
PORTD
_delay
}

for(int
{
PORT
_del
}
}
}
Free download pdf