Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Test 1 Jan -

APR 2023

then from right to left PORT D


Q1 (b) More LED from left to right in

For 1000 times

Void main (void) [


✗ output .
RED
0 ;
TRIS D=
int him ;
×
, y ,

-1-1 ) {
< 101 ; n
for (n=l ; n

< Him -1-1 ) {


for ( m = 1 ; m

OBI 0000000 ;
Y =

PORT D= Y ;
< 8; ✗ + + ) {
0 ; ✗
for ( ✗
=

X;
PORT D= ✗
( 300)
- delay .ms
-

3 0001 ;
OB 0000
Y
=

< 8; ✗+ t ){
for ( ✗ = 0; ✗
x ;
D= Ya
PORT
delay -
_
ms ( 300)
-

}
use Data in Port B to obtain new in
port ☐
0,1 ¢ ,
Void main / void) {
TRIS D= 0 ;

TRI D= 0 ;

int ✗ [ 5) = { 1,2 34,5 ) ;,


HPORTB
/ / PORTD
int y[ 5 ] ;

int i ;

for ( iso : i 25 ; i ++ ) [
PORT A- ✗ [ i] ;

- -

delay .ms ( 500) ;

if ( i % 2 = =D {

y [i ]
= ✗ [ i ] +1 ;

3
else (
y [i ] = ✗ [ i] ;

3
PORT D= Y[ i ] ;
- -

delay _
ms ( 500) ;

3
While (1) ; 11 Stay here
Final Exam Jan -
APR 2022

Q2 (A)
Void main ( void) [
TRIS D= 0 ;

int him ;
× ,
y ,

2251 ; ) {
for ( n
n -1-1
= 1 ; n

for (m = 1 ; m <3 ; m -1-1 ) {


D= 255 ;
PORT
-
-
delay .ms ( boo ) ;

PORT D= 0 ;

3
I/ Stay here
while (1) ;
Test 1 May -

Any 2022

Q1 (b)

Void main ( void) [


TRIS D= 0 ;

int him ,
×
,y ,

in -1-1 ) {
for (n=1;ne6
for (m=1;m< 6 ; m -1-1 ) {
for ( ✗ =\ ;m< 5 ; ✗ + + )L

D= 255 ;
PORT
-
-
delay .ms ( 500 ) ;

PORT D= 0 ;

3
I/ Stay here
while (1) ;
I ii:
Q ] :c
" 7
Void main / void) { g-
6
TRISB -_ 0 ;

TRID :O ;
w

int ✗ [ 5) = { 2,448,10) ; HPORTB


I / PORTD
int y[ 5 ] ;

inti ;

for ( i=o:ic5;i++)[
PORTA -
✗ [ i] ;

- -

delay _ms( 500) ;

[i ]
941=11 -

P0RTD=Y[ i ] ;

- -

delay _
ms( 500) ;

3
While (1) ; 11 Stay here

You might also like