Hackerpro 发表于 2015-11-7 15:40:11

用Arduino抢红包哈哈

双11到了,对于一些简单到不行的淘宝小游戏,又何必亲自动手玩呢

程序也很简单,哈哈
// 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);
}

eysajan 发表于 2015-11-7 17:39:50

能不能介绍一下你用的硬件?点击屏幕用的是什么硬件?

超级无敌掌门狗 发表于 2015-11-7 18:00:16

eysajan 发表于 2015-11-7 17:39 static/image/common/back.gif
能不能介绍一下你用的硬件?点击屏幕用的是什么硬件?

看图应该是adafruit 的motor shield

li23108 发表于 2015-11-7 21:51:40

玩的是什么app

asdfcgdc 发表于 2015-11-8 15:36:02

电容笔的笔头加舵机或电磁铁就OK了

414545584 发表于 2015-11-8 17:46:55

麻烦能不能把头文件AMmotor发出来一下,谢谢

Hackerpro 发表于 2015-11-9 08:58:12

eysajan 发表于 2015-11-7 17:39 static/image/common/back.gif
能不能介绍一下你用的硬件?点击屏幕用的是什么硬件?

x宝杰盛电机家买的电磁铁,好像不到1块钱
驱动就那个293d

Hackerpro 发表于 2015-11-9 09:01:44

414545584 发表于 2015-11-8 17:46 static/image/common/back.gif
麻烦能不能把头文件AMmotor发出来一下,谢谢

我也是参考的
Arduino电机驱动板L293d详解
http://www.geek-workshop.com/thread-24993-1-1.html
页: [1]
查看完整版本: 用Arduino抢红包哈哈