-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBionicHandCode.cpp
More file actions
40 lines (36 loc) · 898 Bytes
/
Copy pathBionicHandCode.cpp
File metadata and controls
40 lines (36 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Sehan Munir
// Robotics Club Bionic Hand Event
#include <Servo.h> // Servo Import
// Servos
Servo servoA;
Servo servoB;
Servo servoC;
Servo servoD;
void setup() // Setup
{
// Setup Servo Position
servoA.attach(8);
servoB.attach(9);
servoC.attach(10);
servoD.attach(11);
}
void loop() // Constant Checker
{
// Check potentiometer value, convert to angle, send info to servo
// Servo & Pontentiometer A
int potValue = analogRead(A0);
int angle = map(potValue, 0, 1023, 0, 180);
servoA.write(angle);
// Servo & Pontentiometer B
potValue = analogRead(A1);
angle = map(potValue, 0, 1023, 0, 180);
servoB.write(angle);
// Servo & Pontentiometer C
potValue = analogRead(A2);
angle = map(potValue, 0, 1023, 0, 180);
servoC.write(angle);
// Servo & Pontentiometer D
potValue = analogRead(A3);
angle = map(potValue, 0, 1023, 0, 180);
servoD.write(angle);
}