Using uVison: Write a C program that generates a 1 second square wave on Pin 2 Port B. Using generated signal from that Pin 2, as an input to Pin 3 Port B drive the red LED at the same rate and the Blue LED at half the rate of the Red LED.
I m writing this program for 8051 microcontroller
#include<reg51.h>
void T0M1Delay(void);
sbit mybit=P2^2;
sbit LED=P2^3;
getting input from P2^2
unsignedint i; //data type
void main(void)
{
while(1)
{
mybit=~mybit; //for generation of square wave
RLED=~RLED; //Red led as per the square wave it will be on and
off
for(i=0;i<28;i++)
{
T0M1Delay() ; //this is to provide the delay of 1 sec which is
required
}
}
BLED=~BLED; //for blue led we want half time
for(i=0;i<14;i++)
{
T0M1Delay() ;//this is to provide half the time delay
}
}
This loop should repeat 28 times to get the delay of 1 sec
void T0M1Delay(void)
{
TMOD=0×01; //timer 0 in mode 1
TL0=0×00; //load the value of TL0
TH0=0×00; //load the value of TH0
TR0=1; //start timer
while(TF0==0); //wait untill TF0 becomes 0
TR0=0;
TF0=0;
}
XTAL frequency=22MHz
so the maximum delay with this crystal frequency is 37.75ms
to get 1 sec delay we take a loop which runs 28 times
=28*35.75
=1000ms=1sec
Using uVison: Write a C program that generates a 1 second square wave on Pin 2...
Using uVison: Write a C program that generates a 1 second square wave on Pin 2 Port B. Using generated signal from that Pin 2, as an input to Pin 3 Port B drive the red LED at the same rate and the Blue LED at half the rate of the Red LED.
Using uVision: Write a 2 Port B. U inCprogram that generates a 1 second square wave on Pin sing the generated signal from that Pin 2, as an input to Pin 3 Port B. th e ed LED at the same rate and the Blue LED at half the rate of the Red LED. (Turn in your source code as Q7.c)
04. a) Write an 8051 C program to send values 00 through FFH to port Pl. b) Write an 8051 C program to send values -3 to +3 to port P1. c) Write an 8051 C program to toggle all bits of P1 (between 55H and AAH) with some delay d) A door sensor is connected to P1.1 and a buzzer to P1.7. Write an 8051 C program to monitor the sensor and when it opens (0') sound the buzzer...
Write a program which produces a constant-amplitude square wave with a frequency of 440Hz (440 cycles per second). Using the init function, the output is configured to use signed 16-bit values for the signal, so a value of 0x8000 represents the “bottom” of the signal range, 0x0 represents the “middle” and 0x7FFF is the “top”. The output sample rate (the rate at which these 16-bit values come out) is 48kHz. This is all the info you need to put the...
C++ Write a program that generates and prints 24 random values using an array and the rand () function. Implement an algorithm to find the maximum and a minimum number of random numbers generated. Use the header "#include <ctime>", "#include <cstdlib>" in addition to the usual header: "#include <iostream>"
C# Programming 1-Write a program that generates the following sequence using while loop 2, 3,6,11, 18, 27,... 102 2-A. Repeat 1 using for loop. B. Modify your program in A to skip 27 from that sequence. C. Modify your program in A by using break statement to stop generating the sequence if the generated number is greater than 30 3. Using loops, find the value of f(7) given: fO)-4, f(n) 2f(n-1)+4, where n is Natural number Hint: f(1)-2f(0)+4-2 4+4-12 f12)-2f(1)+4-...
Write an AVR assembly code that generates a periodic square wave with 4 kHz frequency with 50% duty cycle on the OC0 pin using the Timer/Counter0 CTC mode. Assume a system clock frequency of 16 MHz. Use the follow skeleton code: ; AVR Assembly code - CTC mode with 4 kHz and 50% duty cycle .INCLUDE "m128def.inc" .DEF mpr = R16 ; General purpose register .ORG $0000 ; Reset and Power On interrupt RJMP INITIALIZE ; Jump to initialization .ORG...
Write a program for PIC18F4580 microcontroller to blink the LED at the pin RC0 with the frequency of 8Hz using the Timer1 overflow interrupt and the LED at the pin RC7 with the frequency of 0.8Hz using the Timer0 overflow interrupt concurrently. (Assume that Fosc = 8MHz.) (1) Choose the prescaler and the initial value for TMR1, respectively. (Round off the numbers.) (2) Choose the prescaler and the initial value for TMR0, respectively. (Round off the numbers.) (3) Write the...
C++ language Write a program that 1. generates a random integer between 100 and 1000, call the number N 2. reads a file name from the keyboard 3. opens a file for output using the file name from step 2 4. generates N random numbers between 1 and 100 and writes them to the file from step 3 5. closes the file 6. opens the file from steps 3, and 4 for input 7. reads the numbers from the file...
Write a C++ program using four enumerators. Initialize each as follows: 1. first, second, third, fourth, fifth, sixth, seventh, eighth, ninth 2. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday 3. curve, fast, knuckle, slider 4. single, double, triple, homer The program should prompt a user to input a character array or 4 numbers pertaining to each enumerator. Display help text to assists the user. The help text should display the smallest and largest possible valuesfor each inputted number. Validate the...