https://www.youtube.com/watch?v=gp7iiTzA9_Y
https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/breadboard-layout
https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/breadboard-layout
/*
Adafruit Arduino - Lesson 13. DC Motor
*/
int motorPin = 3;
void setup()
{
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 255");
}
void loop()
{
if (Serial.available())
{
int speed = Serial.parseInt();
if (speed >= 0 && speed <= 255)
{
analogWrite(motorPin, speed);
}
}
}
留言
張貼留言