Getting Started

(lily) #1

Chapter 4: C Types, Operators, and Expressions


int main (void)

and save it to the PortIO directory then

llow m.

s, remember to turn the

{
// Init port pins
DDRB = 0x00; // set port B for input
DDRD = 0xFF; // set port D for output

while(1)
{
PORTD = PINB;
}
}

Open the makefile in the Blinky directory
change:
TARGET = PortIO.
Fo the Blinky example to write, compile, and download this little progra
Remember to turn the Butterfly off and back on, then hold down the center
joystick button before and while clicking on the ‘AVR prog...’ menu item in
AVRStudio. Also remember to browse to the PortIO.hex file in AVRStudio (I
often forget to change the hex file and end up programming the Butterfly with an
earlier hex file). And finally after the code download
Butterfly off and back on then click the joystick to the upper position to start the
program.


If everything goes as planned, the LEDs will display the state of the switches as
shown below. I told you we’d have some lame examples.

Free download pdf