I’m trying to control the speed of the motor using the built in Pulse_in_start command to obtain the pwm on digital pin, but the motor is not moving at all, the following is the code for that.
RC signal pin is connected to D0.
#include <pololu/orangutan.h>
#include <avr/pgmspace.h>
#include <stdio.h>
int main()
{
unsigned long pulse_width, pw;
unsigned char status;
pulse_in_start((unsigned char[]){IO_D0},1);
get_current_pulse_state(0,&pulse_width,&status);
lcd_init_printf();
clear();
print("pulse_width");
print_unsigned_long(pulse_width);
clear();
pw=(pulse_width)*(0.4)/1000; //converting into milli seconds
print("PWM=");
print_unsigned_long(pw);
green_led(status);
set_m1_speed(pw);
print("just passed motor command");
if(pw==0)
{
set_m1_speed(150);
}
}
I haven’t coded before in atmel did in arduino…
Thanks in advance.