Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Servos use regular (non-PWM) pins on MEGA boards. Remove listener whe…

…n pin mode set to out.
  • Loading branch information...
commit d30e070e655c3222aaa736c8b83cd49ec668de2f 1 parent 4c1bc25
@vickash vickash authored
View
4 CHANGELOG.md
@@ -3,7 +3,9 @@
## 0.11.2
* Make servos work better by using the existing Arduino Servo library.
- * Up to 12 servos can be controlled, on digital pins 2-13 only.
+ * Up to 12 servos can be controlled.
+ * On MEGA boards, servos may be used on pins 22-33 ONLY.
+ * On other boards, servos may be used on pins 2-13 ONLY.
* Flashing the updated sketch to the board is required.
## 0.11.1
View
2  spec/lib/tx_rx/usb_serial_spec.rb
@@ -89,7 +89,7 @@ module Dino
IO.should_receive(:select).and_return(true)
subject.stub(:io).and_return(mock_serial = mock)
- mock_serial.should_receive(:puts).with('a message')
+ mock_serial.should_receive(:syswrite).with('a message')
subject.write('a message')
end
end
View
8 src/lib/Dino.cpp
@@ -113,13 +113,13 @@ long Dino::timeSince(long event) {
// CMD = 00 // Pin Mode
void Dino::setMode() {
if (val == 0) {
+ removeListener();
pinMode(pin, OUTPUT);
#ifdef debug
Serial.print("Set pin "); Serial.print(pin); Serial.print(" to "); Serial.println("OUTPUT mode");
#endif
}
else {
- removeListener();
pinMode(pin, INPUT);
#ifdef debug
Serial.print("Set pin "); Serial.print(pin); Serial.print(" to "); Serial.println("INPTUT mode");
@@ -201,13 +201,13 @@ void Dino::servoToggle() {
#ifdef debug
Serial.print("Detaching servo"); Serial.print(" on pin "); Serial.println(pin);
#endif
- servos[pin - 2].detach();
+ servos[pin - SERVO_OFFSET].detach();
}
else {
#ifdef debug
Serial.print("Attaching servo"); Serial.print(" on pin "); Serial.println(pin);
#endif
- servos[pin - 2].attach(pin);
+ servos[pin - SERVO_OFFSET].attach(pin);
}
}
@@ -217,7 +217,7 @@ void Dino::servoWrite() {
#ifdef debug
Serial.print("Servo write "); Serial.print(val); Serial.print(" to pin "); Serial.println(pin);
#endif
- servos[pin - 2].write(val);
+ servos[pin - SERVO_OFFSET].write(val);
}
// CMD = 90
View
2  src/lib/Dino.h
@@ -11,8 +11,10 @@
// Allocate listener storage based on what board we're running.
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
# define PIN_COUNT 70
+# define SERVO_OFFSET 22
#else
# define PIN_COUNT 22
+# define SERVO_OFFSET 2
#endif
// Uncomment this line to enable debugging mode.
Please sign in to comment.
Something went wrong with that request. Please try again.