feat: 全量同步 254 个常用的 Arduino 扩展库文件

This commit is contained in:
yczpf2019
2026-01-24 16:05:38 +08:00
parent c665ba662b
commit 397b9a23a3
6878 changed files with 2732224 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
#include <Servo.h>
// DC motor on M2
AF_DCMotor motor(2);
// DC hobby servo
Servo servo1;
// Stepper motor on M3+M4 48 steps per revolution
AF_Stepper stepper(48, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor party!");
// turn on servo
servo1.attach(9);
// turn on motor #2
motor.setSpeed(200);
motor.run(RELEASE);
}
int i;
// Test the DC motor, stepper and servo ALL AT ONCE!
void loop() {
motor.run(FORWARD);
for (i=0; i<255; i++) {
servo1.write(i);
motor.setSpeed(i);
stepper.step(1, FORWARD, INTERLEAVE);
delay(3);
}
for (i=255; i!=0; i--) {
servo1.write(i-255);
motor.setSpeed(i);
stepper.step(1, BACKWARD, INTERLEAVE);
delay(3);
}
motor.run(BACKWARD);
for (i=0; i<255; i++) {
servo1.write(i);
motor.setSpeed(i);
delay(3);
stepper.step(1, FORWARD, DOUBLE);
}
for (i=255; i!=0; i--) {
servo1.write(i-255);
motor.setSpeed(i);
stepper.step(1, BACKWARD, DOUBLE);
delay(3);
}
}