-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrickit_tar.ino
51 lines (39 loc) · 1.21 KB
/
crickit_tar.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
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include "Adafruit_Crickit.h"
#include "seesaw_servo.h"
Adafruit_Crickit crickit;
seesaw_Servo myservo(&crickit);
seesaw_Servo myservo2(&crickit);
void setup() {
Serial.begin(115200);
Serial.println("1 Drive demo!");
if(!crickit.begin()){
Serial.println("ERROR!");
while(1);
}
else Serial.println("Crickit started");
myservo.attach(CRICKIT_SERVO1); //servo
myservo2.attach(CRICKIT_SERVO2);
//our default frequency is 1khz
crickit.setPWMFreq(CRICKIT_DRIVE1, 1000); //electromagnet
}
void loop() {
//turn all the way on
crickit.analogWrite(CRICKIT_DRIVE1, CRICKIT_DUTY_CYCLE_OFF);
CircuitPlayground.strip.setPixelColor(0, 0, 255, 0);
CircuitPlayground.redLED(true);
myservo.write(0);
myservo2.write(0);
CircuitPlayground.strip.show();
//turn all the way off
crickit.analogWrite(CRICKIT_DRIVE1, CRICKIT_DUTY_CYCLE_MAX);
CircuitPlayground.strip.setPixelColor(0, 0, 0, 255);
delay(2600);
myservo.write(180);
myservo2.write(180);
delay(2300);
CircuitPlayground.redLED(false);
CircuitPlayground.strip.show();
//delay(3000);
}