IDE:Arduino 1.0.4

一、线路连接

S-Y ——> P5(A0)

S-X ——> P2(A1)

S-K ——> P0

VCC ——> VCC

GND ——> GND

二、Arduino代码

//from A0 start,the max is 1023 ,the max Vol is 5V
//A0 ==> P5 //from 470 begin ,less this can't working
//A1 ==> P2
//A2 ==> P4 but the value is smaller and can't read VCC ,maybe beacause it is used by USB conmunication //#include "DigiKeyboard.h"
#include "DigiMouse.h"
const int buttonPin = 0;
const int ledPin = 1;
int buttonState = 1; void setup() {
} void loop() {
int x = analogRead(A1);
int y = analogRead(A0);
/*DigiKeyboard.sendKeyStroke(0);// prevent missing the first character after a delay:
DigiKeyboard.print("(");
DigiKeyboard.print(x);
DigiKeyboard.print(",");
DigiKeyboard.print(y);
DigiKeyboard.println(")");
DigiKeyboard.delay(1000);*/ DigiMouse.moveY(y-537); //down 10
DigiMouse.delay(100);
DigiMouse.moveX(x-521); //right 20
DigiMouse.delay(100);
//DigiMouse.scroll(5);//pg up
//DigiMouse.delay(500);
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) { //the JoyStick button down is low level
digitalWrite(ledPin, HIGH);
// three buttons are the three LSBs of an unsigned char
DigiMouse.setButtons(1<<0); //1<<0 left click;1<<1 right click
DigiMouse.delay(500);
DigiMouse.setButtons(0); //unclick all
//DigiMouse.delay(500);
}
else {
digitalWrite(ledPin, LOW);
}
}

说明:

1、DigiMouse.moveX(char deltaX)、DigiMouse.moveY(char deltaY)函数是相对当前位置进行移动;

2、DigiMouse.scroll(5);为向上翻页;

3、DigiMouse.setButtons(1<<0) 为鼠标左键单击,DigiMouse.setButtons(1<<1) 为鼠标右键单击,DigiMouse.setButtons(0)为清除单击事件;

4、鼠标单击函数执行后,设置合适的延时,可以实现双击。

ps:该Digispark kickstarter似乎存在一点问题,P5脚,即A0脚模拟量无法读取全部模拟量,只能从约470的AD值开始读(最大AD值为1023)。

Digispark kickstarter + JoyStick 模拟鼠标的更多相关文章

  1. C#模拟鼠标键盘控制其他窗口(一)

    编写程序模拟鼠标和键盘操作可以方便的实现你需要的功能,而不需要对方程序为你开放接口.比如,操作飞信定时发送短信等.我之前开发过飞信耗子,用的是对飞信协议进行抓包,然后分析协议,进而模拟协议的执行,开发 ...

  2. C# 模拟鼠标移动与点击

    我们需要用到的mouse_event函数,位于user32.dll这个库文件里面,所以我们要先声明引用. [System.Runtime.InteropServices.DllImport(" ...

  3. C# 模拟鼠标(mouse_event)

    想必有很多人在项目开发中可能遇见需要做模拟鼠标点击的小功能,很多人会在 百度过后采用mouse_event这个函数,不过我并不想讨论如何去使用mouse_event 函数怎么去使用,因为那没有多大意义 ...

  4. Selenium2学习-027-WebUI自动化实战实例-025-JavaScript 在 Selenium 自动化中的应用实例之三(页面滚屏,模拟鼠标拖动滚动条)

    日常的 Web UI 自动化测试过程中,get 或 navigate 到指定的页面后,若想截图的元素或者指定区域范围不在浏览器的显示区域内,则通过截屏则无法获取相应的信息,反而浪费了无畏的图片服务器资 ...

  5. WEBBROWSER中模拟鼠标点击(SendMessage/PostMessage)

    好久没有写文章,发一篇顶顶博客访问量.别人建议转一些比较好的代码也贴过来,但是我打算这里主要发自己原创的代码,所以么..流量该多少就多少吧... 回到主题,在webbrowser中点击某链接网上几乎都 ...

  6. Linux 模拟 鼠标 键盘 事件

    /************************************************************************ * Linux 模拟 鼠标 键盘 事件 * 说明: ...

  7. selenium webdriver(4)---模拟鼠标键盘操作

    webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...

  8. python模拟鼠标键盘操作 GhostMouse tinytask 调用外部脚本或程序 autopy右键另存为

    0.关键实现:程序窗口前置 python 通过js控制滚动条拉取全文 通过psutil获取pid窗口句柄,通过win32gui使程序窗口前置 通过pyauto实现右键菜单和另存为操作 1.参考 aut ...

  9. 可以用py库: pyautogui (自动测试模块,模拟鼠标、键盘动作)来代替pyuserinput

    PyAutoGUI 是一个人性化的跨平台 GUI 自动测试模块 pyUserInput模块安装前需要安装pywin32和pyHook模块.(想要装的看https://www.cnblogs.com/m ...

随机推荐

  1. freeswitch编译mod_av模块

    需要先编译libav库 编译libav下载:git clone https://freeswitch.org/stash/scm/sd/libav.git cd libav ./configure - ...

  2. ubuntu 安装php ,apache 问题总结

    1.apache没有权限 修改log   cd  /var/www chmod -R 777 html/ 2. The bootstrap/cache directory must be presen ...

  3. vue-router 不重新加载问题

    -----------------------同一个路由不同的参数页面不重新加载的解决版本---------- // 监听 route , watch: { '$route': 'getContent ...

  4. MySQL 显示表字段及注释等信息

    SHOW TABLES  from resource [FROM db_name] //列出数据库数据表 SHOW TABLE STATUS from resource [FROM db_name]  ...

  5. Selenium之ActionChains(一)

    今天,分享的是ActionChains的使用方法. 先来说一下今天要用到的方法: click(element=null)                                 点击元素,参数 ...

  6. PRCT-1302 the OCR has an invalid ip address

    PRCT-1302 the OCR has an invalid ip address 1. 报错信息 an internal error occurred within cluster verifi ...

  7. Linux安装模式AppImage,Flatpak,Snap整理

    本文只谈Linux世界用户较多的前2大主要分支, RedHat Red Hat Enterprise Linux 简称RHEL rpm (RedHat, CentOS, Fedora, Oracle. ...

  8. 【shell编程】之基础知识-语法

    一.shell变量 1.定义变量 定义变量时,变量名不加美元符号($,PHP语言中变量需要), 如: your_name="runoob.com" 注意,变量名和等号之间不能有空格 ...

  9. 每天进步一点点- 资源与URI(吐血精华总结)

    1.资源(Resources) 每一个URI代表一种资源这句话的理解 ***************************************************************** ...

  10. mysql export query result

    1 . export by shell a.sql use dbname; SELECT id,iab_num FROM iab_list ; mysql -h host -uusername -P3 ...