-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f2e103a
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
57 changes: 57 additions & 0 deletions
57
Arduino Code/mouse_gun_effect_arduino/mouse_gun_effect_arduino.ino
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <AccelStepper.h> | ||
//#include "Keyboard.h" | ||
int currentRandm = 0; | ||
bool shouldClick = false; | ||
|
||
|
||
void setup() { | ||
// open the serial port: | ||
Serial.begin(9600); | ||
pinMode(2, OUTPUT); | ||
pinMode(3, OUTPUT); | ||
pinMode(4, OUTPUT); | ||
pinMode(5, OUTPUT); | ||
pinMode(6, OUTPUT); | ||
pinMode(7, OUTPUT); | ||
pinMode(8, OUTPUT); | ||
|
||
digitalWrite(2, HIGH); | ||
digitalWrite(3, HIGH); | ||
digitalWrite(4, HIGH); | ||
digitalWrite(5, HIGH); | ||
digitalWrite(6, HIGH); | ||
digitalWrite(7, HIGH); | ||
digitalWrite(8, HIGH); | ||
} | ||
|
||
void loop() { | ||
|
||
if (Serial.available() > 0) { | ||
// read incoming serial data: | ||
char inChar = Serial.read(); | ||
if(inChar == '2') { | ||
shouldClick = false; | ||
} else { | ||
shouldClick = true; | ||
} | ||
} | ||
|
||
if (shouldClick) { | ||
currentRandm = random(2,7); | ||
digitalWrite(2, LOW); | ||
digitalWrite(3, LOW); | ||
digitalWrite(4, LOW); | ||
digitalWrite(5, LOW); | ||
digitalWrite(6, LOW); | ||
digitalWrite(7, LOW); | ||
delay(30); | ||
digitalWrite(2, HIGH); | ||
digitalWrite(3, HIGH); | ||
digitalWrite(4, HIGH); | ||
digitalWrite(5, HIGH); | ||
digitalWrite(6, HIGH); | ||
digitalWrite(7, HIGH); | ||
// digitalWrite(currentRandm, HIGH); | ||
delay(45); | ||
} | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from pynput.keyboard import Key, Listener | ||
from pynput import mouse | ||
import serial | ||
from pynput import keyboard | ||
from threading import Thread | ||
import signal | ||
|
||
arduino = serial.Serial('COM4', 9600, timeout=.1) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
listener = None | ||
interrupted = False | ||
def signal_handler(signal, frame): | ||
# example.stop() | ||
print("interrupted") | ||
global interrupted | ||
interrupted = True | ||
|
||
|
||
def on_click(x, y, button, pressed): | ||
if interrupted: | ||
return False | ||
if not button == mouse.Button.left: | ||
return True; | ||
arduino.write(bytes("1", 'utf-8')) | ||
print('{0} at {1}'.format( | ||
'Pressed' if pressed else 'Released', | ||
(x, y))) | ||
if not pressed: | ||
arduino.write(bytes("2", 'utf-8')) | ||
# Stop listener | ||
return True | ||
signal.signal(signal.SIGINT, signal_handler) | ||
|
||
|
||
# ...or, in a non-blocking fashion: | ||
# listener = mouse.Listener(on_click=on_click) | ||
# listener.start() | ||
|
||
with mouse.Listener(on_click=on_click) as listener: | ||
listener.join() |
2 comments
on commit f2e103a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do I find <AccelStepper.h> source file ?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is library called accelstepper
…On Thu, 22 Jul 2021 at 7:33 PM, Jovis481 ***@***.***> wrote:
Where do I find <AccelStepper.h> source file ?
Thanks
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<f2e103a#commitcomment-53833151>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOBZ2DCUW5Y2IZ2R7NTXWG3TZAQLTANCNFSM4ZPEPZXQ>
.
Ok