-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeMashArduino.ahk
More file actions
116 lines (94 loc) · 1.22 KB
/
CodeMashArduino.ahk
File metadata and controls
116 lines (94 loc) · 1.22 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_class SunAwtFrame
::.setup::
(
void setup()
{
}
)
::.loop::
(
void loop()
{
}
)
::.led::
(
#define led 13
)
::.ledpin::
(
pinMode(led, OUTPUT);
)
::.ledhigh::
(
digitalWrite(led, HIGH);
delay(700);
)
::.ledlow::
(
digitalWrite(led, LOW);
delay(300);
)
; add button to same sketch
::.button::
(
#define button 2
int buttonState = 0;
)
::.buttonpin::
(
pinMode(button, INPUT);
)
::.readbutton::
(
buttonState = digitalRead(button);
)
::.setled::
(
if (buttonState == 1)
{
digitalWrite(led, LOW);
}
else
{
digitalWrite(led, HIGH);
}
)
::.refactor::
(
digitalWrite(led, 1 - buttonState);
)
; motor for new sketch
; setup and loop
::.servo::
(
#include <Servo.h>
Servo robot;
)
::.servosetup::
(
robot.attach(9);
)
::.servoint::
(
int center = 70;
int left = center - 10;
int right = center + 10;
)
::.servoleft::
(
robot.write(center);
delay(500);
robot.write(left);
delay(500);
)
::.servoright::
(
robot.write(center);
delay(500);
robot.write(right);
delay(500);
)