Things used in this project

Hardware components:
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
The wall switches
×1
Ard nano
Arduino Nano R3
×1
11026 02
Jumper wires (generic)
×2
12002 04
Breadboard (generic)
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×2
Usb a to mini b obl 600  37222.1448061239.500.659
Digilent USB A to Mini-B Cable
×1
Software apps and online services:
Python IDLE
Ide web
Arduino IDE

Code

switches.inoC/C++
The Arduino Code
int pulsante1 = 2;
int pulsante2 = 9;
int button1stato = 0;
int button2stato = 0;
int valorepotenziometro = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(pulsante1, INPUT);
  pinMode(pulsante2, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);

}

void loop() {
  button1stato = digitalRead(pulsante1);
  button2stato = digitalRead(pulsante2);
  valorepotenziometro = analogRead(A7);
  
  if(button1stato == HIGH){
    Serial.println("sx");
    digitalWrite(LED_BUILTIN, HIGH);
    delay(200);
  }
  if(button2stato == HIGH){
    Serial.println("dx");
    digitalWrite(LED_BUILTIN, LOW);
    delay(200);
  }

}
commands.pyPython
The Python Code
import serial
import pyautogui
import time

arduino = "dx"
arduino2 = "sx"

ser = serial.Serial('COM45', 9600)
time.sleep(1)

while True:
    val = ser.readline().strip()
    if(val == arduino):
        pyautogui.click()
    if(val == arduino2):
        pyautogui.rightClick()

if __name__ == "__main__":
	main()


    

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login