-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinal_functions
More file actions
45 lines (34 loc) · 835 Bytes
/
final_functions
File metadata and controls
45 lines (34 loc) · 835 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
41
42
43
44
45
#include <MeMegaPi.h>
MeMegaPiDCMotor motor1(PORT2B);
MeMegaPiDCMotor motor2(PORT1B);
MeMegaPiDCMotor motor3(PORT3B);
MeMegaPiDCMotor motor4(PORT4B); // Motor at slot4
uint8_t motorSpeed = 200;
char val;
int card_length_to_ms(float card_length) {
return 625*card_length;
}
int process_input_time (int amount_for) {
if (amount_for < 0) {
amount_for = -1*amount_for;
}
return amount_for;
}
void setup()
{
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop()
{
val = Serial.read();
if (val== 'y') { //y is for one dimensional, 1-d motion for/back
int amount_for = Serial.read();
amount_for = process_input_time(amount_for);
motor2.run(motorSpeed);
motor1.run(-motorSpeed);
delay(amount_for);
motor2.stop();
motor1.stop();
}
}