Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to using C to control the Arduino board to control the speed of the

ID: 3884669 • Letter: I

Question

I'm trying to using C to control the Arduino board to control the speed of the 2 motors. However, when uploading the code, each motor runs at different speed despite having the same OCR value.

Can you guys double check thanks a lot what might be wrong

sensor-motor_test | Arduino 1.8.2 File Edit Sketch Tools Help 90 sensor-motor-test § #include #include void setup) [ 5583300 iasicn DDRD = B00000000; TCCRCA = TCCRIA B10100011; //you can just copy and paste the next 3 lines and just have TCCR2B = B00000001; TCCRIB B00000100; //or read this one: https://Www.sparkfun.com/datasheets/Components/SMD ATMega328.pdf (page 106) OCR2A = 0 ; //to change to the correspond PIN that you guys set on the //board CRIB = 0; void loop ) OCRIB-255; OCR2A 255: PORTBBV (PORTB4); PORTBBV (PORTB5)

Explanation / Answer

* The motor connected to the OCR1B output gets 255/65535=0.3% PWM,
* while OCR2A gives 255/255 = 100% PWM to the other motor. so kindly check it.
* Timer 2 is 8 bit wide, but Timer 1 is 16 bit wide
* In this scenario use the CTC (clear timer on compare match) mode
* use two timers of the same width, like timer 0 and timer 2
* use two output compare units of the same timer (e.g. OCR1A/OCR1B)