|
双11到了,对于一些简单到不行的淘宝小游戏,又何必亲自动手玩呢
程序也很简单,哈哈
[pre lang="arduino" line="1" file="Hongbao"]// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
AF_DCMotor motor1(4);
AF_DCMotor motor2(3);
uint8_t analog = A0;
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor1.setSpeed(255);
motor1.run(RELEASE);
pinMode(analog, INPUT);
}
void loop() {
uint8_t i = 255;
Serial.print("tick");
motor1.run(FORWARD);
while(1){
motor1.setSpeed(i);
delay(analogRead(analog)/5);
--i;
if(i < 190)i = 250;
}
// delay(1000);
// motor.run(BACKWARD);
// motor1.run(RELEASE);
// delay(200);
}[/code] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|