Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions electromagnet.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#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(3000);


myservo.write(127);
myservo2.write(127);

delay(3000);

CircuitPlayground.redLED(false);
CircuitPlayground.strip.show();

//delay(3000);
}void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}