package main

import (
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/firmata"
"gobot.io/x/gobot/platforms/leap"
) // Video: https://www.youtube.com/watch?v=ayNMyUfdAqc
func main() {
firmataAdaptor := firmata.NewAdaptor("/dev/tty.usbmodem1451")
//gpio端口
servo1 := gpio.NewServoDriver(firmataAdaptor, "12") leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
l := leap.NewDriver(leapMotionAdaptor) work := func() {
fist := false
l.On(leap.MessageEvent, func(data interface{}) {
handIsOpen := len(data.(leap.Frame).Pointables) > 0
if handIsOpen && fist {
servo1.Move(0)
fist = false
} else if !handIsOpen && !fist {
servo1.Move(120)
fist = true
}
})
} robot := gobot.NewRobot("servoBot",
[]gobot.Connection{firmataAdaptor, leapMotionAdaptor},
[]gobot.Device{servo1, l},
work,
) robot.Start()
}

最新文章

  1. linux学习第一天,常用命令一
  2. 【转】Oracle索引失效问题
  3. JsonPropertyOrder无法为DTO对象进行属性排序
  4. VirtualBox是什么
  5. C++ 使用cl命令编辑时发生的问题收录
  6. 解决android应用程序适用新老android系统版本方法
  7. oracle存储过程异常捕获
  8. Android任务栈TaskStack
  9. postgres 错误duplicate key value violates unique constraint 解决方案
  10. SpringMVC中的@Controller和@RequestMapping到底什么鬼?
  11. centos安装svn并创建版本库配置用户分组权限
  12. 9.3Django
  13. Python Sleep休眠函数
  14. ZT 查找字符串中连续最长的数字串
  15. jgGrid获得的id值是主键的id而不是jqGrid的行号值
  16. activiti整合spring
  17. CSS边框长度控制
  18. CentOS-6.4 minimal - 安装VMware Tools(linux)
  19. iOS 线程操作库 PromiseKit
  20. Xshell6连接虚拟机(一)

热门文章

  1. python基础一 day10(1)
  2. mysql dump 参数大全
  3. Spring框架针对dao层的jdbcTemplate操作crud之query查询数据操作
  4. 洛谷 P1663 山
  5. 【倍增】7.11fusion
  6. 我的Python分析成长之路3
  7. windows下升级pip失败,重新安装pip最新版本
  8. LeetCode(7)Reverse Integer
  9. LeetCode 673. Number of Longest Increasing Subsequence
  10. visionPro工业视觉工具中英文一览表