Add the following snippet to your HTML:
This project is a arduino car which will coontrolled by keyboard using python and arduino.
Read up about this project on
This lockdown I made a arduino car which is controlled using arduino. It is programmed using python and arduino.
I have explained all in this video
https://www.youtube.com/watch?v=tgSH2h5tutI
#include <AFMotor.h> #include <Servo.h> AF_DCMotor motor(1);#the pin in which your motor is in adafruit motor shield AF_DCMotor motor1(4);#the pin in which your motor 2 is in adafruit motor shield Servo servo1; void setup() { motor.setSpeed(200); motor1.setSpeed(200); motor.run(RELEASE); motor1.run(RELEASE); Serial.begin(9600); } void loop() { if (Serial.read()=='b'){ motor.run(BACKWARD); motor1.run(BACKWARD); } else if(Serial.read()=='f'){ motor.run(FORWARD); motor1.run(FORWARD); } else if(Serial.read()=='s'){ motor.run(RELEASE); motor1.run(RELEASE); } else if(Serial.read()=='r'){ motor.run(BACKWARD); motor1.run(FORWARD); } else if(Serial.read()=='l'){ motor.run(FORWARD); motor1.run(BACKWARD); } }
import keyboard,serial ser=serial.Serial('com6',9600) while True: if keyboard.ispressed('w'): ser.write(b'f') elif keyboard.is_pressed("s"): ser.write(b'b') elif keyboard.is_pressed("d"): ser.write(b'r') elif keyboard.is_pressed("a"): ser.write(b'l') else: ser.write(b's')
Comments