Last active
January 1, 2016 15:59
-
-
Save MrTrick/8167692 to your computer and use it in GitHub Desktop.
Does not work - motor runs continuously instead of cycling on and off.
If sections (1) and (2) are swapped, works!
Why?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------------------------------- | |
// Libraries | |
//--------------------------------------------- | |
#include <Wire.h> | |
#include <Adafruit_LEDBackpack.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_MotorShield.h> | |
//--------------------------------------------- | |
// Pin configuration | |
//--------------------------------------------- | |
//MOTORS | |
#define AUGER_OUT 1 //M1 on Adafruit V2 motor shield | |
#define FAN_OUT 2 //M2 on Adafruit V2 motor shield | |
#define TIME_DISPLAY 0x70 //I2C Address | |
//--------------------------------------------- | |
// Variables and Setup | |
//--------------------------------------------- | |
Adafruit_7segment time_display = Adafruit_7segment(); | |
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); | |
Adafruit_DCMotor *auger = AFMS.getMotor(AUGER_OUT); | |
//--------------------------------------------- | |
// Core Functions | |
//--------------------------------------------- | |
/** | |
* Run once at startup | |
*/ | |
void setup() { | |
//Comms | |
Serial.begin(9600); | |
Serial.println(F("Mindbleach Engineering - Motor AND Display Test")); | |
time_display.begin(TIME_DISPLAY); | |
//Motors | |
AFMS.begin(); | |
auger->run(BACKWARD); | |
auger->setSpeed(0); | |
} | |
int i=0; | |
void loop() { | |
//(1) | |
Serial.println("Setting auger to 50%"); | |
auger->setSpeed(128); | |
//(2) | |
Serial.println("Displaying i"); | |
time_display.print(i++, DEC); | |
time_display.writeDisplay(); | |
delay(3000); | |
Serial.println("Setting auger off"); | |
auger->setSpeed(0); | |
delay(3000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i2c for above code: Motor runs slowly and doesn't stop. Display works. | |
[0xC0+0x26+0x00+0x00+0x00+0x08+] | |
[0xE0+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x7D+0x00+0x00+0x00+0x00+0x00+0x00+0x00+] | |
[0xC0+0x26+0x00+0x00+0x00+0x00+] | |
i2c for case when (1) and (2) are reversed. Motor starts/stops properly, display works. | |
[0xE0+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x00+0x7D+0x00+0x00+0x00+0x00+0x00+0x00+0x00+] | |
[0xC0+0x26+0x00+0x00+0x00+0x08+] | |
[0xC0+0x26+0x00+0x00+0x00+0x00+] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment