Upgraded PHP from 5.6 to 7.3

On my main server for GreenRobot apps, I recently upgraded PHP from 5.6 to 7.3. One thing that helped was the PHP Web and Toolkit for Coda. When there was an error I used “Tidy PHP” and the error was fixed.

Also, since I used ADODB it was pretty easy to switch to a new mysqli driver versus mysql. ADODB is available via PHP Composer.

https://php.net

2 External Displays on My Macbook Pro.

I am lucky enough to have 2 external displays so I bought an adapter for my Macbook Pro so I can connect both at the same time. I bought it on eBay:

https://www.ebay.com/itm/Thunderbolt-Mini-Display-Port-DP-to-HDMI-Adapter-Cable-For-MacBook-Pro-Air-Mac/401524373537?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2649

Happy New Year’s Eve

I am waiting on some ultrasonic module sensors for my robot.

I bought them on eBay:

https://www.ebay.com/itm/5X-Ultrasonic-Module-HC-SR04-Distance-Transducer-Sensor-For-Arduino-Robot/232126163617?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m2749.l2649

The estimated delivery is Wed, Jan 02.  

Hope you have a good new year.

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();

}