3xmaker,人機協作共融萬物互聯,柔性可穿戴人機交互感知與測量!

  1. 設計指南
  2. |
  3. 新品速遞
  4. |
  5. 聯系我們
機器人+
傳感器+
柔性/印刷電子+
增強現實+
人機交互感知+
網站首頁
/
智造案例
/
智造

鐳射激光逗貓神器

來源:3XMaker   發布時間:2019年03月26日

鐳射激光逗貓神器

http://www.knexny.com/UploadFiles/2019-03/20193263218123754.jpg

喵星人對于激光發射器發出的光點有著天生、難以抗拒的執著。它們就像一個個職業殺手一樣直接的撲向那個小小的紅色激光點。對于貓咪們來說狩獵是一項很好的運動。看著萌寵們發起攻擊的樣子,作為鏟屎官的你會不會覺得是一件饒有興趣的事情呢!通常你只要拿起你的激光發射器就可以做到,但是你總會預先知道激光點的方向。讓我們給這個游戲制造一些混亂元素——可以平面移動或改變仰角的激光炮塔,并讓它可以周期性地隨機移動。先看看下面的視頻~

第一步:準備項目組件清單

它需要用你慣用的任何舵機來配合驅動塔樓。這里有兩種方案:
RobotGeek 云臺:
如果你喜好添加一個攝像頭或者附加一個的自帶釣魚桿的逗貓玩具,這款將是一個好的選擇。

RobotGeek云臺和舵機

鐳射激光發射器和固定配件

Geekduino或者其他兼容Arduino UNO 開發板

傳感器模塊 (推薦,可簡化接線)

7V 5A 電源

Mini 云臺:
不錯的低成本選擇, 但是9G 的舵機輸出的力量有限。

Mini 云臺套件

9G 舵機 x 2

鐳射激光發射器和固定配件

Geekduino或者其他兼容Arduino UNO 開發板

傳感器模塊 (推薦,可使簡化接線)

6V 2A電源

第二步:組裝炮塔

http://www.knexny.com/UploadFiles/2019-03/20193264186180223.jpg
如果你使用的是RobotGeek云臺,安裝說明可以在這找到。
如果你使用的是Mini云臺, 安裝說明可以在這找到。
拿上激光發射器,讓我們把它連接起來。

第三步:接線

http://www.knexny.com/UploadFiles/2019-03/20193261239017874.jpg

設備

引腳類型

引腳編號

平移舵機

數字

10

仰角舵機

數字

11

激光發射器

數字

2

確保設定的輸入電壓能供更大的伺服7v運行。對于9G的伺服系統,你可以用5V6V的電源。真的是超級簡單的接線。趕緊編碼起來吧!

第四步:編程

上傳以下代碼到你的 Arduino 主板上。

幫助

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

//https://github.com/robotgeek/desktopRoboTurretV3/tree/master/roboTurret3_lazerDazer

//Includes

#include   <Servo.h>            //include the servo library for working with servo objects

 

//Defines

const int PAN =   10;         //Pan Servo Digital Pin

const int TILT =   11;        //Tilt Servo Digital Pin

const int LASER =   2;        //Laser Digital Pin

const int PAN_MIN =   40;     // minimum pan servo range, value should be   between 0 and 180 and lower than PAN_MAX

const int PAN_MAX =   140;    // maximum pan servo range, value should be between 0   and 180 and more than PAN_MIN

const int TILT_MIN =   60;    // minimum tilt servo range, value should be between 0   and 180 and lower than TILT_MAX

const int TILT_MAX = 100;   //   maximum tilt servo range, value should be between 0 and 180 and more than   TILT_MIN

const int SPEED_MIN = 10;   //   minimum interpolation speed (less than 5 not recommended)

const int SPEED_MAX = 10;   //   maximum interpolation speed (Lower SPEED_MAX values mean that the program   will cycle more quickly, leading to an increased occurance of pausing. Adjust   ROLL_MAX accordingly)

const int ROLL_MAX =   40;    // Roll the dice for random pause. Lower value = more   frequent pauses, higher value = less frequent pauses

const int PAUSE_MIN = 500;  //   define minimum pause length in mS. 1000 = 1 second

const int PAUSE_MAX = 1500; // define   maximum pause length in mS.

 

Servo panServo, tiltServo;  //   create servo objects to control the pan and tilt servos

 

long dazer_speed;

int dazer_pause_roll;

int pause_length = 1;

 

int panValue = 90;   //current   positional value being sent to the pan servo.

int tiltValue = 90;  //current   positional value being sent to the tilt servo.

byte pan_goal;

byte tilt_goal;

 

//State Variables

int laserState =   LOW;         //The current state of   the laser module

 

//Timing variables

long lastDebounceTime = 0;  // the   last time the output pin was toggled. This variable is a 'long' because it   may need to hold many milliseconds, and a 'long' will afford more space than   an 'int'

int debounceDelay = 50;      // the amount of time that that a button must be held, for a reading to   register (in milliseconds)

 

void setup()

{

  //initialize servos

  panServo.attach(PAN);    // attaches/activates the pan servo on pin PAN

  tiltServo.attach(TILT);    // attaches/activates the tilt servo on pin TILT

 

  //initalize digital pins

  pinMode(LASER,   OUTPUT);      //set the LASER Pin to an output

   

  //write initial servo   positions to set the servos to 'home'

  panServo.write(panValue);    //sets the pan servo position to the default 'home' value

  tiltServo.write(tiltValue);//sets   the tilt servo position to the default 'home' value

   

  randomSeed(analogRead(0));    //set a basis for the random() engine, based off of analog0 which will be a random   number because nothing is attached

 

  digitalWrite(LASER, HIGH);

}

 

void loop()

{

  dazer_pause_roll = random(1,   ROLL_MAX);      //pick a random number between 1 and   ROLL_MAX

  pause_length =   random(PAUSE_MIN, PAUSE_MAX); //pick a random number between PAUSE_MIN and   PAUSE_MAX

  delay(pause_length);                           //use the random number to pause for pause_length milliseconds

 

  pan_goal = random(PAN_MIN,   PAN_MAX);

  tilt_goal = random(TILT_MIN,   TILT_MAX);

  dazer_speed =   random(SPEED_MIN, SPEED_MAX);

  //perfom the loop while the   current positions are different from the goal positions

 

  //if the pan_goal is larger   than the pan position, move the pan position up

  if (pan_goal > panValue)

  {

    panValue = panValue++;

  }

   

  //if the pan_goal is smaller   than the pan position, move the pan position down

  else if (pan_goal <   panValue)

  {

    panValue =   panValue--;

  }                

   

  //if the tilt_goal is larger   than the tilt position, move the pan position up

  if (tilt_goal > tiltValue)

  {

    tiltValue =   tiltValue++;

  }

  //if the tilt_goal is smaller   than the tilt position, move the pan position down

  else if (tilt_goal <   tiltValue)

  {

    tiltValue =   tiltValue--;

  }   

   

  panServo.write(pan_goal);                      // sets the servo position according to the scaled value

  tiltServo.write(tilt_goal);                    // sets the servo position according to the scaled value

  delay(dazer_speed);                            // waits for a random delay before the next loop

} //end loop()

把你的貓咪萌寵抓過來,開啟它吧?。ó斎皇情_啟你的塔樓啦,而不是你的貓咪啦?。┠愕拿葘櫩墒亲詭щ娫吹呐?!可不要嘗試給你的貓咪充電哦!

第五步:Done!就是這么完美!

現在鏟屎的你只需坐下來,看著你的貓咪追逐和攻擊那個邪惡的小紅點啦!

 


上一篇:萬物音樂盒子:讓日常物品發聲的電子鼓
下一篇:選擇困難癥福音: DIY“囚徒困境”搶答器

南京合越智能,增強智造,增強感知,增強交互!

業務合作

(我們會第一時間與您聯系)

聯系方式

  1. 微信:13815863530(手機同號)
  2. QQ:38260484
  3. 3XMaker@163.com
Copyright@ 2016-2025 南京合越智能科技有限公司 蘇ICP備18068961號
主站蜘蛛池模板: 永善县| 凉城县| 中阳县| 图木舒克市| 密山市| 陇南市| 高碑店市| 石柱| 仁怀市| 天等县| 永丰县| 泸西县| 马关县| 从化市| 盘锦市| 泾川县| 平舆县| 大同县| 保山市| 遵义市| 平遥县| 冷水江市| 鄂尔多斯市| 华阴市| 阳新县| 云林县| 崇阳县| 叶城县| 光泽县| 波密县| 宁海县| 鞍山市| 恩施市| 大关县| 昭苏县| 长顺县| 双辽市| 遂溪县| 阿拉尔市| 军事| 龙游县|