Skip to content

Instantly share code, notes, and snippets.

@RobotGrrl
Last active January 12, 2018 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobotGrrl/6e88393586e0fdaeeee82db437de1baf to your computer and use it in GitHub Desktop.
Save RobotGrrl/6e88393586e0fdaeeee82db437de1baf to your computer and use it in GitHub Desktop.
Confusing Servo Bug
Quick overview of the Bowie Lib:
- Modules like BowieHopper, BowieScoop, BowieComms, etc. all get imported by MegaBowieShoreline.
- This is so that there can eventually be a MegaBowieSeedPlanter, for the next missions etc.
In MegaBowieShoreline.cpp, void MegaBowieShoreline::begin() {
This is where the objects get initialised
Bowie Lib:
https://drive.google.com/open?id=1UxYtklpj5Cls7tZ_94N0011cSO4xvv_t
Running this in a sketch for MegaBowieSHoreline only moves whatever is first in begin
Full sketch here:
https://drive.google.com/open?id=1NMJpFaNbmJdALVNyzhmOOGpiRYOQ1Gvq
while(1<3) {
Serial << "hi" << endl;
bowie.bowiehopper.moveLid(LID_MAX);
bowie.bowiescoop.moveEnd(END_PARALLEL_BOTTOM);
delay(500);
bowie.bowiehopper.moveLid(LID_MIN);
bowie.bowiescoop.moveEnd(END_MIN);
delay(500);
}
Running a sketch like this works fine
Full sketch here:
https://drive.google.com/open?id=11WYU_r5nVlk-cVvbWzKsW8QLNVUO4kkO
#include <Servo.h>
#include "BowieHopper.h"
#include "BowieScoop.h"
void servoInterrupt(int key, int val);
BowieHopper bowiehopper;
BowieScoop bowiescoop;
void setup() {
Serial.begin(9600);
bowiehopper = BowieHopper();
bowiehopper.begin();
bowiehopper.setServoHopperLidPin(25);//SERVO_HOPPER_LID);
bowiehopper.setServoInterruptCallback(servoInterrupt);
bowiehopper.initServos();
bowiescoop = BowieScoop();
bowiescoop.begin();
bowiescoop.setServoScoopPin(4);//SERVO_END_EFFECTOR);
bowiescoop.setServoInterruptCallback(servoInterrupt);
bowiescoop.initServos();
}
void loop() {
//bowiehopper.initServos();
bowiehopper.moveLid(LID_MAX);
//bowiescoop.initServos();
bowiescoop.moveEnd(END_PARALLEL_BOTTOM);
delay(500);
//bowiehopper.initServos();
bowiehopper.moveLid(LID_MIN);
//bowiescoop.initServos();
bowiescoop.moveEnd(END_MIN);
delay(500);
}
void servoInterrupt(int key, int val) {
Serial.println("Interrupt");
}
Stuff that I tried:
- Changing BowieHopper to *BowieHopper and same with scoop, and changing the .'s to -> in MegaBowieShoreline. This did not work.
- Making a BowieGhost servo class. This was a stupid idea, because none of the servos after it worked (duh)
- (Re)setting bowieInstance to this. Nothing really changed, it didn't work.
- Making sure that Servo.h is only imported if Servo_h is defined. This didn't change anything.
- Works fine in the sketch without MegaBowieShoreline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment