Question

Question 1. With AVR ATmega16 microcontroller, a circuit has servomotor (PC0), a potentiometer and two LEDs....

Question 1.
With AVR ATmega16 microcontroller, a circuit has servomotor (PC0), a potentiometer and two LEDs. Write a program as:

  • When turn the potentiometer’s knob to the right the servomotor will rotate clockwise and the first LED (PB0) will be on.
  • When turn the potentiometer’s knob to the left the servomotor will rotate counterclockwise and the second LED (PB1) will be on..
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#define F_CPU 1000000UL

#include<avr/io.h>

#include<util/delay.h>

void main()

{

//Configure TIMER1

TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11); //NON Inverted PWM

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(0<<CS11)|(1<<CS10); //PRESCALER=1 MODE 14(FAST PWM)

  

ICR1=19999; //fPWM=50Hz (Period = 20ms Standard).

DDRD|=(1<<PD4)|(1<<PD5); //PWM Pins as Out

  

while(1)

{

OCR1A=0; //0 degree

_delay_ms(1000);

OCR1A=600; //45 degree

_delay_ms(1000);

OCR1A=950; //90 degree

_delay_ms(1000);

OCR1A=1425; //135 degree

_delay_ms(1000);

OCR1A=1900; //180 degree

_delay_ms(1000);

OCR1A=1425; //135 degree

_delay_ms(1000);

OCR1A=950; //90 degree

_delay_ms(1000);

OCR1A=650; //45 degree

_delay_ms(1000);

}

}

but this is the interface of microcontroller and servomotor this shall help you a lot.

Add a comment
Know the answer?
Add Answer to:
Question 1. With AVR ATmega16 microcontroller, a circuit has servomotor (PC0), a potentiometer and two LEDs....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Two simple, single loop circuits are positioned next to each other on the plane of...

    1. Two simple, single loop circuits are positioned next to each other on the plane of a desk. The first consists of a 10 v battery, a switch and an 0.2 mH inductor. The second has a 0.3 mH inductor and a galvanometer. The inductors from each circuit are aligned (coaxial). Which of the following is true? a). The galvanometer will have a reading as long as the switch is closed b). The galvanometer can never have a reading c)...

  • QUESTION TWO a) Given the circuit below where the button is connected to Port AO Write...

    QUESTION TWO a) Given the circuit below where the button is connected to Port AO Write the correct assembly program for Atmega32 such that when the button is pressed the seven segment starts counting from 0 to 9. The delay of transition between numbers should be one second delay. Use indirect addressing Mode. The Seven Segment is a common cathode one. M 11-12

  • Question 19 (9 points) Three 2 V cells are connected in series. This circuit has two...

    Question 19 (9 points) Three 2 V cells are connected in series. This circuit has two resistors in parallel. The first resistor is 2 ohms and the second resistor is 4 ohms. What is the voltage of the second resistor? What is the total resistance in the circuit? What is the amperage of each of the resistors? What is the total amperage of the circuit?

  • Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, s...

    Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, setZ, alter (change the lock’s combination to the numbers passed) turn (use for loops to show the dial turning), close (locks the lock), attempt (tries to unlock the lock – calls turn( ), inquire (locked or unlocked), current (returns the number the dial is pointing to), toString LockClientDemoClass – You should have a...

  • PHY 212 Bonus Question for Exam #4 1. In the circuit shown in the diagram, the current in the sol...

    PHY 212 Bonus Question for Exam #4 1. In the circuit shown in the diagram, the current in the solenoid (opening is perpendicular to the plane of the page) is in the direction shown (counterclockwise). The current is INCREASING linearly in time. The battery in the circuit has an emf equal to the emf of a single loop around the solenoid. The bulbs are all identical and the internal resistance of the battery is much less than the resistance of...

  • QUIZ NAVIGATION Question 8 Two train cars filled with soy beans escape from the Hertage Cooperative...

    QUIZ NAVIGATION Question 8 Two train cars filled with soy beans escape from the Hertage Cooperative in Ada and roll along the (very flat and straigh) rairoad track east towards Dola. The frst has a mass of 2.00 x 10 kg and moves at 3.00 m/s to the right. The second has a mass of 1.00 x 10 kg and moves at 6.00 m's to the right. When the second car catches the first, the two cars collide and couple...

  • Question 1 (20 marks) Consider the circuit in Figure Q1. Ri WW R2 6T OB Figure...

    Question 1 (20 marks) Consider the circuit in Figure Q1. Ri WW R2 6T OB Figure Q1 (a) To analyze the circuit, we apply the mesh current analysis. This is achieved by assuming the current in the left and right loops are ii and i2 as shown in Figure Q1. Apply the KVL and write down two equations corresponding to those two loops (4 marks) (b) If Vo=10 V, Ri=512, R2=512, Io=1A, what are the values of ii and i2?...

  • Question 16 (1 point) The following information pertains to Questions 16-20 Consider one round of the penalty shoot-out...

    Question 16 (1 point) The following information pertains to Questions 16-20 Consider one round of the penalty shoot-outs in hockey (The kicker kicks the ball, the goalie tries to save). This is a simultaneous game. The kicker has two strategies: Kick left and kick right. The goalie also has two strategles: Dive to the left, and dive to the right. The payoffs are given below. The rows correspond to the strategles of the Kicker, and columns correspond to that of...

  • Question: Part 1: In the second part of this lab, we will extend our adder to...

    Question: Part 1: In the second part of this lab, we will extend our adder to also allow for subtraction of the second number from the first. To implement this, we must take the 2's compliment of the second number and add it to the first. This can be implemented using the circuit shown in Section 4.4.2 of the notes, which is shown again here in Figure 2. B3 A3 B2 A B, A, B, A, -SM 0: Add 1:...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT