1. Which port line is being referred by DPin-1?
[Unclear. PINDx and PORTDx are the uC nomenclature, DPin-x is not. One might assume PD1, the TXD line, is being referred to.]
2. Which two instructions of the following will ignite L?
(a) digitalWrite(8, HIGH);
(b) bitClear(PORTB, 5);
(c) boolean n= HIGH;
bitWrite(PORTB, 5, n);
[c, assuming the pin had been set to output mode]
3. Write assignment instruction for the function
pinMode(0, HIGH) to set the direction of PD0-line.
[incorrect syntax. pinMode (0, INPUT); or (0, INPUT_PULLUP) or (O, OUTPUT) are correct.
4. Write instruction to read the value of Pin-4 of ATmega328 and write it into PD1-line. Assume that the directions of the port lines are already as needed.
[digitalWrite (1, (digitalRead(2) ); assuming Pin-4 refers to the physical pin]
5. Write instruction (s) to show 3 at DP2 position of the 7-segment display unit. Assume that the directions of the lines are already set as required.
[digitalWrite (8, HIGH); // a
digitalWrite (9, HIGH); //b
digitalWrite (10, HIGH); // c
digitalWrite (11, HIGH); // d
digitalWrite (12, LOW); // e
digitalWrite (13, LOW); // f
digitalWrite (6, HIGH); // g
digitalWrite (7, LOW); // p
digitalWrite (1 HIGH); // mux 1
digitalWrite (0, LOW); // mux 0
Note the drawing is missing any current limiting resistors for the LEDs, and 74LS138 is only recommended for 8mA sink current max.
6. Write down the symbolic names of the Data Direction Register that are present in the system.
[DDRB, DDRC, DDRD]
7. After the inclusion of the 74LS138 decoder, how many port lines are now available in the system?
[1, pin 3]
8. Which segment (a or b or ……, p) of which display (DP0 or DP1, …DP3) will appear as ON after the execution of the following instruction?
byte x = 0x87;
boolean n = bitRead(x, 7);
bitWrite(PORTD, 7, n);
digitalWrite(1, HIGH);
bitSet(PORTD, 0);
[first 3 lines put HIGH on pin13, so p is driven.
PORTD bits 1,0 = 1,0 -> DP2 enabled]
9. Assume that the wiper of R2 is exactly at the 1/3rd position from 0V-point. What will be the value of x (in hex format) after the execution of the following instruction?
int x = analogRead(A5); (You can use Calculator.)
[assuming Aref is set to External, it has only a 0.1uF cap to Gnd connected, and assuming a linear pot, then the voltage at A5 = 5V/3 = 1.67V, and x ~= 1.67*1024/5V = 342decimal = 0x155]
10. What output values (0 or 1) would be produced by the following two instructions after pressing K1?
(a) digiatlRead(2);
(b) bitRead(PIND, 2);
(c) bitRead(PORTD, 2);
[which 2 of the 3 instructions?]