Date: 09/23/09

Student Name: Hao (Hardy) He

TAs: Mike Pridgen

Thomas Vermeer

Instructors: Dr. A. Antonio Arroyo

Dr. Eric M. Schwartz

University of Florida

Department of Electrical and Computer Engineering

EEL 5666

Intelligent Machines Design Laboratory


Weekly Report 4


I read the ATxmega128A1 data sheet and studied TAs' sample code. Because the ordered motors and sensors have not arrived, to get something working first, I made a bumper switch and wrote a simple program to test it.

The bumper switch is connected to the PIN 0 of PORT B. The program keeps reading this PIN. When the bumper is not pressed, the reading from PIN 0 of PORT B is 1 and the program does nothing. When the bumper is pressed, PIN 0 of PORT B is grounded and the reading becomes 0; then the program lights up the LCD from PIN 0 of PORT Q.

The main part of the code is shown below:
int temp; //for reading B0
PORTQ_DIR |= 0x01; //set Q0 (LED) as output
PORTB_DIR &= 0xFE; //set B0 (Bumper Switch) as input
while(1)
{
	temp = (PORTB_IN & 0x01); //read B0
	if (temp == 0) //if B0=0, turn on the LED
		PORTQ_OUT = 1;
	else
		PORTQ_OUT = 0;
	delay_ms(100); //delay 100ms
}