Men in Black

I lost my Google Pixel 6 phone. I’m on my iPhone now. I watched MIB where in the first scene there is one alien that Wil Smith and the other one stop and pull over along with a bunch of other immigrants. The aliens first name was Mikey. We had a dog named Mikey. A Rottweiler and German Shepard. He was cool.

I noticed in the news 51 immigrants were killed in the worst smuggling event in history. We’re any real aliens captured? How long will they be held?

See my instagram Andyt

See my twitter andyt443

Controlling a motor with an encoder with an Arduino

I ordered this motor:

uxcell DC 12V 7RPM 50Kg.cm Self-Locking Worm Gear Motor with Encoder and Cable, High Torque Speed Reduction Motor

https://www.amazon.com/gp/product/B078J521TG

I have an Arduino Uno and a 12 Volt battery supply from 8 AA batteries from my previous project.


I found a few tutorials:

Tutorial for DC Gear Motor With Encoder

https://www.instructables.com/id/Tutorial-for-DC-Gear-Motor-With-Encoder/

Tutorial for Monster Motor Shield VNH2SP30

https://www.instructables.com/id/Monster-Motor-Shield-VNH2SP30/

This new motor is slower but has more torque than the motors I used in my last attempt at an autonomous robot.

The older motors had

Torque: 30 N*cm

According to Wolfram Alpha that’s:

3.059 kgf cm kilogram-force centimeters.

This new motor has 50Kg.cm.

I ordered a few items on Ebay:

NEW MEGA 2560 R3 Development Board CH340G ATMEGA 2560 Kit USB Cable For Arduino

1pcs Dual VNH2SP30 Stepper Motor Driver Module Monster Moto Shield Replace L298N

3/4/5/6/12mm Rigid Flange Coupling Motor Guide Shaft Coupler Metal Bearing Seat( 142461587108 )

Specification: 8mm

Quantity: 4

Ultrasound sensor board not working

I have a problem with the octosonarx2 circuit board.

https://www.tindie.com/products/arielnh56/octosonarx2-connect-16-x-hc-sr04-to-arduino/

I may have messed it up because I think the ultrasound sensors are working ok. I got a pretty cool soldering device that holds circuit boards in place and also some thinner solder. I think I may have messed up the octox2 board by hooking the wires to the arduino incorrectly. A replacement is not available because it’s been on backorder at tindie for a week.

 

Arduino video of turning and spinning motors

Here’s a video of my Arduino robot with some nextrox motors attached to Di servo servos. This is so it can turn and also move forward or backward.

https://youtu.be/4bpG65nveMk

 

Here’s the code:

 

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

//SERVO SECTION
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

//for servo 0
#define MIN_PULSE_WIDTH_0 900
#define MAX_PULSE_WIDTH_0 1800

//for servo 1
#define MIN_PULSE_WIDTH_1 900+100
#define MAX_PULSE_WIDTH_1 1800+100

//for servo 2
#define MIN_PULSE_WIDTH_2 900-250
#define MAX_PULSE_WIDTH_2 1800-250

//for servo 3
#define MIN_PULSE_WIDTH_3 900-250
#define MAX_PULSE_WIDTH_3 1800-250

#define FREQUENCY 50
//50 for digital

//DC MOTOR SECTION
//Motor A
const int motorPin1 = 9; // Pin 14 of L293
const int motorPin2 = 10; // Pin 10 of L293
//Motor B
const int motorPin3 = 6; // Pin 7 of L293
const int motorPin4 = 5; // Pin 2 of L293

//Motor C
const int motorPin5 = 14;
const int motorPin6 = 15;

//Motor D
const int motorPin7 = 16;
const int motorPin8 = 17;

void setup() {
Serial.begin(9600);

//DC MOTOR SECTION
pwm.begin();
pwm.setPWMFreq(FREQUENCY); // Analog servos run at ~60 Hz updates

//SERVO STUFF
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);

pinMode(motorPin5, OUTPUT);
pinMode(motorPin6, OUTPUT);
pinMode(motorPin7, OUTPUT);
pinMode(motorPin8, OUTPUT);

delay(1000);
}

//SERVO SECTION
void turnServo(int channel, int angle) {
pwm.setPWM(channel, 0, pulseWidth(channel, angle));
}

void turnServosLeft() {
//turn servos to 0
turnServo(0, 0);
turnServo(1, 0);
turnServo(2, 0);
turnServo(3, 0);
delay(2000);
}

void turnServosRight() {
//turn servos to 180
turnServo(0, 180);
turnServo(1, 180);
turnServo(2, 90);
turnServo(3, 90);
delay(2000);
}

void setServosStraight() {
turnServo(0, 90);
turnServo(1, 90);
turnServo(2, 90);
turnServo(3, 90);
delay(1000);
}

int pulseWidth(int channel, int angle)
{
int MY_MIN_PULSE_WIDTH;
int MY_MAX_PULSE_WIDTH;

if(channel ==0) {
MY_MIN_PULSE_WIDTH=MIN_PULSE_WIDTH_0;
MY_MAX_PULSE_WIDTH=MAX_PULSE_WIDTH_0;
}
else if(channel == 1) {
MY_MIN_PULSE_WIDTH=MIN_PULSE_WIDTH_1;
MY_MAX_PULSE_WIDTH=MAX_PULSE_WIDTH_1;
}
else if(channel == 2) {
MY_MIN_PULSE_WIDTH=MIN_PULSE_WIDTH_2;
MY_MAX_PULSE_WIDTH=MAX_PULSE_WIDTH_2;
}
else if(channel == 3) {
MY_MIN_PULSE_WIDTH=MIN_PULSE_WIDTH_3;
MY_MAX_PULSE_WIDTH=MAX_PULSE_WIDTH_3;
}

int pulse_wide, analog_value;
pulse_wide = map(angle, 0, 180, MY_MIN_PULSE_WIDTH, MY_MAX_PULSE_WIDTH);

analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
Serial.println(analog_value);
return analog_value;
}

//END SERVO SECTION

//DC MOTOR SECTION
void goForwardWithMotorA() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
}

void goForwardWithMotorB() {
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}

void goForwardWithMotorC() {
digitalWrite(motorPin5, LOW);
digitalWrite(motorPin6, HIGH);
}

void goForwardWithMotorD() {
digitalWrite(motorPin7, LOW);
digitalWrite(motorPin8, HIGH);
}

void goBackWithMotorA() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
}

void goBackWithMotorB() {
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}

void goBackWithMotorC() {
digitalWrite(motorPin5, HIGH);
digitalWrite(motorPin6, LOW);
}

void goBackWithMotorD() {
digitalWrite(motorPin7, HIGH);
digitalWrite(motorPin8, LOW);
}

void goForwardWithDCMotors() {
//motor a
goForwardWithMotorA();

//motor b
goForwardWithMotorB();

//motor c
goForwardWithMotorC();

//motor d
goForwardWithMotorD();

}

void goBackWithDCMotors() {
//motor a
goBackWithMotorA();

//motor b
goBackWithMotorB();

//motor c
goBackWithMotorC();

//motor d
goBackWithMotorD();
}

void stopDCMotors() {

analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 0);

analogWrite(motorPin5, 0);
analogWrite(motorPin6, 0);
analogWrite(motorPin7, 0);
analogWrite(motorPin8, 0);
}

void rightSideDCMotorsBackward() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}

void leftSideDCMotorsBackward() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}

//END DC MOTOR SECTION

void loop() {

setServosStraight();

goForwardWithDCMotors();

delay(2000);

stopDCMotors();

turnServosLeft();

}

Robot progress

Here are some pics of my project so far. I got some servo mounts from ServoCity and they are mounted in order to turn the other motors. They turn on carpet in tandem which is pretty cool. I am waiting on a 1/4 20 tap to connect the plexiglass to the 80 20 pieces.