-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzocus.ino
84 lines (68 loc) · 1.8 KB
/
zocus.ino
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
/*
!!!Zero points in Centre of Zoom and Focus travel!!!
Red Bear Lab Bled Micro firmware for Zocus
Written by Ross Atkin, based on Red bear Lab's 'Simple Chat' example
Designed for the 'Zocus Rig', by Jude Pullen
*/
//"services.h/spi.h/boards.h" is needed in every new project
#include <SPI.h>
#include <boards.h>
#include <Keyboard.h>
#include <RBL_nRF8001.h>
#include <Servo.h>
int go = 0;
int nogo = 0;
long message = 0;
int val = 90; //Set zero point for Zoom - keep at 90
int val2 = 59; //Set zero point for Focus - original 57 // best to date 59
Servo myservo;
Servo myservo2;
String string;
void setup()
{
// Set your BLE Shield name here, max. length 10
ble_set_name("Trigger");
Keyboard.begin();
Serial.println("hello");
myservo.attach(11);
myservo2.attach(10);
myservo.write(val);
myservo2.write(val2);
pinMode(13, OUTPUT);
// Init. and start BLE library.
ble_begin();
string = String("0");
// Enable serial debug
Serial.begin(57600);
}
unsigned char buf[16] = {0};
unsigned char len = 0;
void loop()
{
if (ble_available()) {
while (ble_available())
message = ble_read();
if( message > 0) {
if( message < 101) {
val = map(message, 0, 100, 179, 0); //last two numbers adjust original 177 and 2 // best to date 179, 0
myservo.write(val);
Serial.print(" Zoom ");
Serial.println(val);
}
if( message > 155) {
val2 = map(message, 155, 255, 3, 117); // last two numbers original 2 and 114 // best to date 2, 117
myservo2.write(val2);
Serial.print(" Focus ");
Serial.println(val2);
}
}
Serial.println();
}
if ( Serial.available() )
{
delay(5);
while ( Serial.available() )
ble_write( Serial.read() );
}
ble_do_events();
}