Skip to content

Commit

Permalink
code
Browse files Browse the repository at this point in the history
  • Loading branch information
teenenggr-git committed May 9, 2020
0 parents commit f2e103a
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Arduino Code/.DS_Store
Binary file not shown.
57 changes: 57 additions & 0 deletions Arduino Code/mouse_gun_effect_arduino/mouse_gun_effect_arduino.ino
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 added pc code/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions pc code/mouse_gun_effect_pc.py
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.

Copy link
@pratap4656

pratap4656 Mar 19, 2021

Ok

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

@Jovis481
Copy link

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

@teenenggr-git
Copy link
Contributor Author

@teenenggr-git teenenggr-git commented on f2e103a Jul 24, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.