Project Progress¶
In week 7 we decide to go with Adafruit Feather Bluefruit nRF52832 becuase we need Adafruit to connect with Adafruit Motor FeatherWing and for Feather Joywing it will be more managed without the wires we use to connect Arduino to Feather Joywing and to motor drive and motor drive to the motor.
Adafruit Feather nRF52832¶
For Adafruit nRF52832 I was unenabled to choose the port who connected to Adafruit nRF52832 in Arduino IDE so I search in google and in chat GPT. After Three days I find to make Arduino IDE recognize to the port connected to Adafruit nRF52832 I need to install CP210x Universal Windows Driver and I flow this step in vide I find it in YouTube.
But after three days the Adafruit nRF52832 was not give the Feather Joywing power enough to make it run. So we go with Adafruit Feather nRF52840.
Adafruit Feather nRF52840¶
For Adafruit Feather nRF52840 I run the Stepper motor using Adafruit Motor FeatherWing and run the Feather Joywing to check them.
Feather Joywing¶
I use the code in example from Library seesaw.
The Code¶
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
#define BUTTON_RIGHT 6
#define BUTTON_DOWN 7
#define BUTTON_LEFT 9
#define BUTTON_UP 10
#define BUTTON_SEL 14
uint32_t button_mask = (1 << BUTTON_RIGHT) | (1 << BUTTON_DOWN) |
(1 << BUTTON_LEFT) | (1 << BUTTON_UP) | (1 << BUTTON_SEL);
#if defined(ESP8266)
#define IRQ_PIN 2
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
#define IRQ_PIN 14
#elif defined(ARDUINO_NRF52832_FEATHER)
#define IRQ_PIN 27
#elif defined(TEENSYDUINO)
#define IRQ_PIN 8
#elif defined(ARDUINO_ARCH_WICED)
#define IRQ_PIN PC5
#else
#define IRQ_PIN 5
#endif
void setup() {
Serial.begin(115200);
while(!Serial) {
delay(10);
}
Serial.println("Joy FeatherWing example!");
if(!ss.begin(0x49)){
Serial.println("ERROR! seesaw not found");
while(1) delay(1);
} else {
Serial.println("seesaw started");
Serial.print("version: ");
Serial.println(ss.getVersion(), HEX);
}
ss.pinModeBulk(button_mask, INPUT_PULLUP);
ss.setGPIOInterrupts(button_mask, 1);
pinMode(IRQ_PIN, INPUT);
}
int last_x = 0, last_y = 0;
void loop() {
int x = ss.analogRead(2);
int y = ss.analogRead(3);
if ( (abs(x - last_x) > 3) || (abs(y - last_y) > 3)) {
Serial.print(x); Serial.print(", "); Serial.println(y);
last_x = x;
last_y = y;
}
/* if(!digitalRead(IRQ_PIN)) { // Uncomment to use IRQ */
uint32_t buttons = ss.digitalReadBulk(button_mask);
//Serial.println(buttons, BIN);
if (! (buttons & (1 << BUTTON_RIGHT))) {
Serial.println("Button A pressed");
}
if (! (buttons & (1 << BUTTON_DOWN))) {
Serial.println("Button B pressed");
}
if (! (buttons & (1 << BUTTON_LEFT))) {
Serial.println("Button Y pressed");
}
if (! (buttons & (1 << BUTTON_UP))) {
Serial.println("Button X pressed");
}
if (! (buttons & (1 << BUTTON_SEL))) {
Serial.println("Button SEL pressed");
}
/* } // Uncomment to use IRQ */
delay(10);
}
The Result¶
Stepper Motor and Adafruit Motor FeatherWing¶
First I use the code form example but it was so mush vibration so I use anther code to run the stepper motor for 10 second.
The Code¶
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Create object for the motor shield
Adafruit_StepperMotor *myStepper = AFMS.getStepper(200, 1); // Select the motor number (M1)
void setup() {
AFMS.begin(); // Initialize the motor shield
myStepper->setSpeed(100); // Set the motor speed (RPM)
}
void loop() {
unsigned long startTime = millis(); // Get the current time
while (millis() - startTime < 10000) { // Run for 5 seconds (5000 milliseconds)
myStepper->step(100, FORWARD, SINGLE); // Step the motor forward one step
delay(10); // Delay between steps (adjust if necessary)
}
myStepper->release(); // Release the motor after 5 seconds
delay(1000); // Delay for 1 second before running again
}
The Result¶
The vibration was so mush less but it stile there.