https://github.com/codeadamca/arduino-motor
A basic example of controlling a motor using an Arduino.
https://github.com/codeadamca/arduino-motor
actuator arduino cplusplus motor
Last synced: 3 months ago
JSON representation
A basic example of controlling a motor using an Arduino.
- Host: GitHub
- URL: https://github.com/codeadamca/arduino-motor
- Owner: codeadamca
- Created: 2020-10-02T04:36:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-26T22:05:16.000Z (5 months ago)
- Last Synced: 2025-01-26T23:18:10.169Z (5 months ago)
- Topics: actuator, arduino, cplusplus, motor
- Language: C++
- Homepage:
- Size: 604 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Arduino and a Motor
A basic example of controlling a motor using an Arduino.
## Arduino Code
Open up [Arduino Create](https://create.arduino.cc/editor/) and add the following code:
```csharp
int motorPin = 9;
int motorValue = 0;void setup() {
Serial.begin(9600);
}
void loop() {
// Alternate between full speed and off
if (motorValue == 0) {
motorValue = 255;
} else {
motorValue = 0;
}analogWrite(motorPin, motorValue);
Serial.println(motorValue);delay(1000);
}
```[View the Arduino code on Arduino Create](https://create.arduino.cc/editor/professoradam/703dc0ed-a25d-4c01-a3c9-433ba5afcabc/preview)
You will need to setup the following circuit using your Arduino:

> [View the Circuit on Tinkercad](https://www.tinkercad.com/things/h2MepgtwoSD)
> Full tutorial URL:
> https://codeadam.ca/learning/arduino-motor.html---
## Repo Resources
- [Visual Studio Code](https://code.visualstudio.com/) or [Brackets](http://brackets.io/) (or any code editor)
- [Arduino Create](https://create.arduino.cc/editor)