Skip to content

Instantly share code, notes, and snippets.

@MrTrick
Last active January 1, 2016 16:08
Show Gist options
  • Save MrTrick/8168295 to your computer and use it in GitHub Desktop.
Save MrTrick/8168295 to your computer and use it in GitHub Desktop.
Problematic behaviour when using both the Adafruit motor control shield v2 and the i2c 7 segment display. Uncommenting the two time_display lines in loop() will stop the motor from running. Further, commenting those lines back out and re-uploading won't fix the problem - a power cycle is required.
#include <Wire.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MotorShield.h>
// Configuration
#define AUGER_OUT 1 //M1 on Adafruit V2 motor shield
// Variables and Setup
Adafruit_7segment time_display = Adafruit_7segment();
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *auger = AFMS.getMotor(AUGER_OUT);
// Core Functions
void setup() {
//Comms
time_display.begin(0x70);
//Motors
AFMS.begin(); //Uses 0x60
auger->run(BACKWARD);
auger->setSpeed(0);
}
void loop() {
//time_display.print(0xBEEF, HEX);
//time_display.writeDisplay();
auger->setSpeed(100);
delay(1000);
auger->setSpeed(0);
delay(10000);
}
//Not working. Same program as for A, but haven't power-cycled the shield since uploading and running B
[0xE0+0x21+]
[0xE0+0x81+]
[0xE0+0xEF+]
[0xC0+0x00+0x00+]
[0xC0+0x00+]
[0xC1+0x00-]
[0xC0+0x00+0x10+]
[0xC0+0xFE+0x03+]
[0xC0+0x00+0x00+]
[0xC0+0x00+0xA1+]
[0xC0+0x06+0x00+0x00+0x00+0x00+]
[0xC0+0x0A+0x00+0x00+0x00+0x00+]
[0xC0+0x0E+0x00+0x00+0x00+0x00+]
[0xC0+0x12+0x00+0x00+0x00+0x00+]
[0xC0+0x16+0x00+0x00+0x00+0x00+]
[0xC0+0x1A+0x00+0x00+0x00+0x00+]
[0xC0+0x1E+0x00+0x00+0x00+0x00+]
[0xC0+0x22+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x32+0x00+0x00+0x00+0x00+]
[0xC0+0x36+0x00+0x00+0x00+0x00+]
[0xC0+0x3A+0x00+0x00+0x00+0x00+]
[0xC0+0x3E+0x00+0x00+0x00+0x00+]
[0xC0+0x42+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x10+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x40+0x06+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
//A) Motor working. Display initialised, not called.
[0xE0+0x21+]
[0xE0+0x81-]
[0xE0+0xEF-[]
[0xC0+0x00+0x00+]
[0xC0+0x00+]
[0xC1+0x00-]
[0xC0+0x00+0x10+]
[0xC0+0xFE+0x03+]
[0xC0+0x00+0x00+]
[0xC0+0x00+0xA1+]
[0xC0+0x06+0x00+0x00+0x00+0x00+]
[0xC0+0x0A+0x00+0x00+0x00+0x00+]
[0xC0+0x0E+0x00+0x00+0x00+0x00+]
[0xC0+0x12+0x00+0x00+0x00+0x00+]
[0xC0+0x16+0x00+0x00+0x00+0x00+]
[0xC0+0x1A+0x00+0x00+0x00+0x00+]
[0xC0+0x1E+0x00+0x00+0x00+0x00+]
[0xC0+0x22+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x32+0x00+0x00+0x00+0x00+]
[0xC0+0x36+0x00+0x00+0x00+0x00+]
[0xC0+0x3A+0x00+0x00+0x00+0x00+]
[0xC0+0x3E+0x00+0x00+0x00+0x00+]
[0xC0+0x42+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x10+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x40+0x06+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
//B) Motors not working - displays 'BEEF'
[0xE0+0x21+]
[0xE0+0x81+]
[0xE0+0xEF+]
[0xC0+0x00+0x00+]
[0xC0+0x00+]
[0xC1+0x00-]
[0xC0+0x00+0x10+]
[0xC0+0xFE+0x03+]
[0xC0+0x00+0x00+]
[0xC0+0x00+0xA1+]
[0xC0+0x06+0x00+0x00+0x00+0x00+]
[0xC0+0x0A+0x00+0x00+0x00+0x00+]
[0xC0+0x0E+0x00+0x00+0x00+0x00+]
[0xC0+0x12+0x00+0x00+0x00+0x00+]
[0xC0+0x16+0x00+0x00+0x00+0x00+]
[0xC0+0x1A+0x00+0x00+0x00+0x00+]
[0xC0+0x1E+0x00+0x00+0x00+0x00+]
[0xC0+0x22+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x32+0x00+0x00+0x00+0x00+]
[0xC0+0x36+0x00+0x00+0x00+0x00+]
[0xC0+0x3A+0x00+0x00+0x00+0x00+]
[0xC0+0x3E+0x00+0x00+0x00+0x00+]
[0xC0+0x42+0x00+0x00+0x00+0x00+]
[0xC0+0x2E+0x00+0x00+0x00+0x00+]
[0xC0+0x2A+0x00+0x10+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x00+0x00+]
[0xE0+0x00+0x7C+0x00+0x79+0x00+0x00+0x00+0x79+0x00+0x71+0x00+0x00+0x00+0x00+0x00+0x00+0x00+]
[0xC0+0x26+0x00+0x00+0x40+0x06+]
[0xC0+0x26+0x00+0x00+0x00+]
#include <Wire.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MotorShield.h>
// Configuration
#define AUGER_OUT 1 //M1 on Adafruit V2 motor shield
// Variables and Setup
Adafruit_7segment time_display = Adafruit_7segment();
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *auger = AFMS.getMotor(AUGER_OUT);
// Core Functions
void setup() {
//Motors
AFMS.begin(); //Uses 0x60
auger->run(BACKWARD);
auger->setSpeed(0);
//Comms
time_display.begin(0x70);
}
void loop() {
auger->setSpeed(100);
delay(3000);
auger->setSpeed(0);
delay(3000);
time_display.print(0xBEEF, HEX);
time_display.writeDisplay();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment