-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLarge_Crane_IR_Skeleton.ino
More file actions
executable file
·79 lines (75 loc) · 4.86 KB
/
Large_Crane_IR_Skeleton.ino
File metadata and controls
executable file
·79 lines (75 loc) · 4.86 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "MeMegaPi.h"
#include <SoftwareSerial.h>
MeInfraredReceiver infraredReceiverDecode(PORT_6); //Change this port number as needed
MeMegaPiDCMotor rightMotor(PORT1B);
MeMegaPiDCMotor leftMotor(PORT2B);
MeMegaPiDCMotor craneMotor(PORT3B);
MeMegaPiDCMotor clampMotor(PORT4B);
int motorSpeed = 150;
int turnSpeed = 0;
int craneSpeed = 0;
int clampSpeed = 0;
int maxSpeed = 255;
/*-------------------------------------------------------------------------------------------------------*/
void setup() /*-----------------------------------------------------------------------------------------*/
{ /*-----------------------------------------------------------------------------------------------------*/
infraredReceiverDecode.begin(); /*---------------------------------------------------------------------*/
} /*-----------------------------------------------------------------------------------------------------*/
void endOfAlgorithm() { /*-------------------------------------------------------------------------------*/
while(infraredReceiverDecode.available()) { /*---------------------------------------------------------*/
infraredReceiverDecode.read(); /*-------------------------------------------------------------------*/
} /*---------------------------------------------------------------------------------------------------*/
} /*-----------------------------------------------------------------------------------------------------*/
void loop() { /*-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------------*/
int ReceiverCode; /*-----------------------------------------------------------------------------------*/
int buttonState; /*-----------------------------------------------------------------------------------*/
static int PrebuttonState = 0; /*---------------------------------------------------------------------*/
buttonState = infraredReceiverDecode.buttonState(); /*-------------------------------------------------*/
if(PrebuttonState != buttonState) /*-------------------------------------------------------------------*/
{ /*---------------------------------------------------------------------------------------------------*/
rightMotor.run(0); /*-------------------------------------------------------------------------------*/
leftMotor.run(0); /*---------------------------------------------------------------------------------*/
craneMotor.run(0); /*-------------------------------------------------------------------------------*/
clampMotor.run(0); /*-------------------------------------------------------------------------------*/
rightMotor.stop(); /*-------------------------------------------------------------------------------*/
leftMotor.stop(); /*---------------------------------------------------------------------------------*/
craneMotor.stop(); /*-------------------------------------------------------------------------------*/
clampMotor.stop(); /*-------------------------------------------------------------------------------*/
PrebuttonState = buttonState; /*---------------------------------------------------------------------*/
} /*---------------------------------------------------------------------------------------------------*/
if(infraredReceiverDecode.available()) /*-------------------------------------------------------------*/
{ /*---------------------------------------------------------------------------------------------------*/
ReceiverCode = infraredReceiverDecode.read(); /*-----------------------------------------------------*/
switch(ReceiverCode) /*-----------------------------------------------------------------------------*/
{ /*-------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
case IR_BUTTON_A:; break;
case IR_BUTTON_B:; break;
case IR_BUTTON_C:; break;
case IR_BUTTON_D:; break;
case IR_BUTTON_E:; break;
case IR_BUTTON_F:; break;
case IR_BUTTON_SETTING:; break;
case IR_BUTTON_UP:;
rightMotor.run(-motorSpeed);
leftMotor.run(motorSpeed);
break;
case IR_BUTTON_DOWN:;
rightMotor.run(motorSpeed);
leftMotor.run(-motorSpeed);
break;
case IR_BUTTON_LEFT:; break;
case IR_BUTTON_RIGHT:; break;
case IR_BUTTON_0:; break;
case IR_BUTTON_1:; break;
case IR_BUTTON_2:; break;
case IR_BUTTON_3:; break;
case IR_BUTTON_4:; break;
case IR_BUTTON_5:; break;
case IR_BUTTON_6:; break;
case IR_BUTTON_7:; break;
case IR_BUTTON_8:; break;
case IR_BUTTON_9:; break;
default: break;
}}}