Documente Academic
Documente Profesional
Documente Cultură
Exercise details:
• When PORT RB0 is Low, LEDs connected to RC0-
RC3 must blink
• When PORT RB0 is High, LEDs connected to
RC4-RC7 must blink
• When PORT RB1 is High, LEDs connected to
RC0-RC7 must blink
Laboratory Exercise 1: Blinking LEDs
Open your mikroC and create a project for this
experiment.
int x=1;
void main() {
TRISB = 0b111; //set port B to input
TRISC = 0b0000; //set port C to output
PORTC = 0; //initialize port C
PORTB = 0; //initialize port C
while(x=1){
if (PORTB.RB0 == 1) //check status of PORTB pin RB0
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xF0; //set port C to high
delay_ms(50);
}
…continued
else if (PORTB.RB1 == 1)
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xFF; //set port C to high
delay_ms(50);
}
else
{
PORTC = 0; //set port C to low
delay_ms(50);
PORTC = 0xF; //set port C to high
delay_ms(50);
}
}
}
Design Exercise 1: Walking LED
Exercise details:
• Utilize the previous circuit design for this activity.
• When PORT RB0 is High and RB1 is Low, lighted
LED must shift to the left
• When PORT RB0 and RB1 are Low, lighted LED
must shift to the right
• When PORT RB0 and RB1 are High, LEDs must
blink
• When PORT RB0 is Low and RB1 is High, LEDs
must stay lighted
Copy your codes and circuitry in an A4 sized PDF file
together with your name and subject details. Content
of the file must be the result of Laboratory Exercise
and Design Exercise.