An open API service indexing awesome lists of open source software.

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.

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:

![Tinkercad Circuit](_readme/tinkercad-motor.png)

> [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)