Devices & Components
Arduino Uno Rev3
Camera (generic)
SG90 Micro-servo motor
Project description
Code
Arduino Controller
c_cpp
Get the UART bytes and convert into movement
1#include <Servo.h> 2#define pinServ1 11 3#define pinServ2 10 4#define pinServ3 9 5#define pinServ4 8 6 7Servo serv1 , serv2 , serv3 , serv4; 8 9int motor1 = 90 ; 10int motor2 = 52 ; 11int motor3 = 67 ; 12int motor4 = 0 ; 13 14 15char buf; 16 17void setup() { 18 Serial.begin(9600); 19 20 serv1.attach(pinServ1); 21 serv2.attach(pinServ2); 22 serv3.attach(pinServ3); 23 serv4.attach(pinServ4); 24 25 26} 27 28void loop() { 29 while(Serial.available() > 0) 30 { 31 buf = Serial.read(); 32 33 if(buf == 'A' && motor1 < 170){ 34 serv1.write(motor1 += 1); 35 serv1.detach(); 36 } 37 38 if(buf == 'B' && motor1 > 10){ 39 serv1.write(motor1 -= 1); 40 serv1.detach(); 41 } 42 43 if(buf == 'C' && motor2 < 170){ 44 serv2.write(motor2 += 1); 45 serv2.detach(); 46 } 47 48 if(buf == 'D' && motor2 > 10){ 49 serv2.write(motor2 -= 1); 50 serv2.detach(); 51 } 52 53 if(buf == 'E' && motor3 < 170){ 54 serv3.write(motor3 += 1); 55 serv3.detach(); 56 } 57 58 if(buf == 'F' && motor3 < 10){ 59 serv3.write(motor3 -= 1); 60 serv3.detach(); 61 } 62 if(buf == 'G' && motor4 < 170){ 63 serv4.write(motor4 += 1); 64 serv4.detach(); 65 } 66 67 if(buf == 'H' && motor4 < 10){ 68 serv4.write(motor4 -= 1); 69 serv4.detach(); 70 } 71 delay(15); 72 73 } 74 75}
Downloadable files
Image Above
I will make the schematic to change here!
Image Above

Comments
Only logged in users can leave comments