Created
July 4, 2016 16:26
-
-
Save houmei/76a1d26c207333ba5b7496113de297de to your computer and use it in GitHub Desktop.
Digispark + PIR Sensor : PC wakeup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <DigiMouse.h> | |
#define LED 1 | |
#define PIR 0 | |
void setup() { | |
DigiMouse.begin(); | |
pinMode(LED, OUTPUT); | |
pinMode(PIR, INPUT); | |
} | |
const int len=1; | |
int x,y,a; | |
int ct=1; | |
void loop() { | |
a=digitalRead(PIR); | |
if (a) { | |
x=random(-1,1)*len; | |
y=random(-1,1)*len; | |
DigiMouse.moveX(x); | |
DigiMouse.moveY(y); | |
DigiMouse.delay(500); | |
digitalWrite(LED, ct&1); | |
} else { | |
digitalWrite(LED, 0); | |
} | |
delay(2000); | |
ct++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment