Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coulson liang motor task #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

// the id of the motor, need to change according to the set id, 0-3
#define ROBOT_ID 0

#define ROBOT ID 1
// motor speed, increase if motor is not spinning
#define SPEED 2700 // there's a 9:1 gear box, so the actual rpm is divided by 9

Expand Down Expand Up @@ -71,6 +71,9 @@ void SystemClock_Config(void);
/* USER CODE BEGIN 0 */


void turnOnMotor(void);
void turnOffMotor(void);

/* USER CODE END 0 */

/**
Expand Down Expand Up @@ -125,6 +128,12 @@ int main(void)

while (1)
{

if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)==0) {
turnOnMotor();
} else {
turnOffMotor();
}
HAL_Delay(10);


Expand Down