What I'm trying to achieve with this code is to move a single-arm of an SG90 motor from 0 degrees to 180 degrees back and forth.
I'm using the MSP430g2553 to do this. The connection is simple, is just the SG90 connected to the Launchpad, and using the onboard button P1.3
will enable the following actions: When it is pressed, the motor will start moving back and forth, if I press it again, the motor will stop and the onboard LEDs will indicate the state of the motor, the red for when it's not moving and the green for when it is moving.
The problem I have with this code is that I do not know how to implement those actions within the Timer ISR, and I ask for help on this since I'm pretty much new to this subject. So far I have made it move but it moves erratically, although the Red and Green LEDs are turning on as I want.
Here's what I've got so far. Oh and by the way I don't understand how to do the increments on the duty cycles, I know that for 1ms it is supposed to put the blade in the position of 0 degrees, 1.5ms for 90 and 2 ms for 180. Thank you in advance.
I'm using the MSP430g2553 to do this. The connection is simple, is just the SG90 connected to the Launchpad, and using the onboard button P1.3
will enable the following actions: When it is pressed, the motor will start moving back and forth, if I press it again, the motor will stop and the onboard LEDs will indicate the state of the motor, the red for when it's not moving and the green for when it is moving.
The problem I have with this code is that I do not know how to implement those actions within the Timer ISR, and I ask for help on this since I'm pretty much new to this subject. So far I have made it move but it moves erratically, although the Red and Green LEDs are turning on as I want.
Here's what I've got so far. Oh and by the way I don't understand how to do the increments on the duty cycles, I know that for 1ms it is supposed to put the blade in the position of 0 degrees, 1.5ms for 90 and 2 ms for 180. Thank you in advance.
Attachments
-
2.8 KB Views: 13