Skip to content

Instantly share code, notes, and snippets.

@houmei
Created July 4, 2016 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houmei/76a1d26c207333ba5b7496113de297de to your computer and use it in GitHub Desktop.
Save houmei/76a1d26c207333ba5b7496113de297de to your computer and use it in GitHub Desktop.
Digispark + PIR Sensor : PC wakeup
#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