Professional Documents
Culture Documents
and Microcontrollers
1. LAB 1:
a. Write an assembly language code to add two numbers 50
and60.
b. Write an assembly language code to add 255 and 1.
c. Write an assembly language code to XOR three numbers
X=10100111(A7), Y=11001010(CA), Z=00010001(11). Store the
result in accumulator.
d. Write an assembly language code to subtract 30 from 130.
e. Write an assembly language code to add three numbers 40,
50 and 60. Store the result in accumulator.
2. LAB 2:
a. Write an assembly language code to add ten numbers which
are stored at memory location 2010 to 2019.
3. LAB 3:
a. Move n-bytes of data from memory location 6800 to 6810.
b. Multiply two 8-bit numbers which are stored in register B
& C and store the 8-bit product in memory location
2800.
c. Multiply two 8 bit numbers which are stored in register B
& C and store the 16-bit product in memory location
2800 & 2801.
4. LAB 4:
7. LAB 7:
a. Write a subroutine to find the factorial of a number.
b. Write a subroutine to find GCD of n numbers.
8. LAB 8:
a. Submit the following codes along with explanation and
output analysis with STM NucleoFRE40.
i. On-board LED blinking
ii. User LED blinking
iii. On board user button usage
iv. User Switch operation
9. LAB 9:
a. Write embed an C code to display 0 to 9 continuously
using a common anode 7-segment display with a delay of 2
seconds.
b. Write an embed C code to display 0 to F continuously
using a common anode 7-segment display with a delay of 3
seconds.
10. LAB 10:
11. Generate a sound using a speaker with three tones. Use
pwm output ports of the STM board. Show the schematic for the
same and write the embed C code.
a. Generate sa re ga ma using speaker. Interface with STM
microcontroller board and show the schematic and write
the embed C code for the same.
12. Connect a capacitive touch switch button module with STM
microcontroller board, whenever we touch the season a siren
sound will be generated from the speaker. Show the entire
schematic of the same and write the embed C code to do the
following.
Lab-I
Lab-II
Lab-II
Lab-IV
Lab-V
Lab-VI
Lab-VII
Lab VII
On-board LED blinking:
int main()
{
while (1) //Initializing an infinite loop
{
myled = 1; //declaring myled as 1
wait(2); //waiting for 2 seconds
myled = 0; //declaring myled as 0
wait(1); //waiting for 1 sec
}
}
Output- After the code is executed, the on-board led3 of the NUCLEO-F401RE glows for 2 seconds
and then dims it for 1sec which happens on an infinite loop.
int main()
{
while(1)// Initializing an infinite loop
{
myled = 1; //declaring myled as 1
wait(2); //waiting for 2 seconds
myled = 0; //declaring myled as 0
wait(1); //waiting for 1 sec
}
}
Output- We are connecting a led in D2 port of the NUCLEO-F401RE and then installing our
program. This make the led glow for 2 seconds and then dims it for 1sec which happens on an
infinite loop.
On board user button usage:
int main() {
while(1) // initializing an infinite loop
{
if(!myButton) //if the value from the input port is 0
{
out = 1; //out is set to 1
}
else
{
out = 0; //out is set to 0
}
}
return(0); //returning 0 to the operating system
}
Output- When we do not press the USER_BUTTON it gives input 1 and the bulb does not glow but
when we press it, it gives a input 0 and the led glows
int main() {
while(1) // initializing an infinite loop
{
if(myInput) //if the value from the input port is 1
{
myled = 1; //myled is set to 1
}
else
{
myled = 0; //myled is set to 0
}
}
return(0); //returning 0 to the operating system
}
Output- We are connecting the NUCLEO F401RE with a input switch through D2 port. When the
switch is not pressed it gives input 1 and the led glows. But when we press the switch it gives input
as 0 so the led dims.
Lab IX
Displaying 0 to 9 continuously using a common anode 7-segment display
with a delay of 2 seconds:
Output- After the code is executed, SEVEN Segment display to the NUCLEO-F401RE will display 0 to
9 continuously with a Delay of 2 sec which happens on an infinite loop.
Displaying 0 to 9 and A-F continuously using a common anode 7-segment
display with a delay of 2 seconds:
}
}
int main() {
Result:
This Program will Produce a Siren Sound with a Delay of 2 Second
void siren()
{
int i=0; // initializing i as 0
}
int main()
{
float count; //Initializing a real number type variable
while(1) //Initializing an while loop
{
count= G.read(); //reading data from the Capacitive Switch
if(count <0.4) //Giving a Condition
{
siren(); //if condition Satisfied playing the
Sound
}
}
return 0;
}
Result:
This program will produce a sound of Siren when the Capacitive touch
Sensor will be touched