A sketch that was working on version 1.0.5 of the Arduino IDE will no longer compile on version 1.6.5.
I'm pretty new to this programming/Arduino thing, but it looks like the problem has to do with a library I'd added to simplify chasing LEDs.
The sketch drives servos for the wings of a PKE meter prop (from Ghostbusters} and chases the LEDs on the wings and display.
#include <Servo.h>
#include <ChaseLEDs.h>
#define NACELLE_RATE 22 // Analog input for reading the nacelle chase rate
#define NACELLE_CHASE_LEN 8 // Length of nacelle chase, 1..6
#define NACELLE_MIN_PERIOD 25 // Minimum time to advance the nacelle chase (milliseconds)
#define NACELLE_MAX_PERIOD 250 // Maximum time to advance the nacelle chase (milliseconds)
#define NACELLE_DIM_VALUE 0 // Value for dimming previous LED in chase, 0..255
// Output pins to use for the nacelle chase
boolean chaseOn = false;
byte nacelleChasePins[8] = {14, 15, 16, 17, 18, 19, 20, 21}; // Pin 21 is not connected to leave blank spot in sequence
class NacelleChaseLEDs : public ChaseLEDs
{
public:
NacelleChaseLEDs(const byte *pins, int num)
: ChaseLEDs(pins, num, 0) {}
protected:
void advance(byte prevPin, byte nextPin) {
digitalWrite(previousPin(2), LOW);
analogWrite(prevPin, NACELLE_DIM_VALUE);
if (chaseOn)
{
digitalWrite(nextPin, HIGH);
}
setAdvanceTime(map(analogRead(NACELLE_RATE), 0, 1023, NACELLE_MIN_PERIOD, NACELLE_MAX_PERIOD));
//digitalWrite(13, !digitalRead(13)); // toggle the LED <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
};
NacelleChaseLEDs nacelleChase(nacelleChasePins, NACELLE_CHASE_LEN);
const int touchPinFull = 12; // the number of the pushbutton pin
int touchStateFull = 0;
Servo myservoL; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo myservoR;
void setup()
{
myservoL.attach(9);
myservoR.attach(10);
digitalWrite(13, LOW); //Status LED OFF
pinMode(14, OUTPUT); //Wing LED
pinMode(15, OUTPUT); //Wing LED
pinMode(16, OUTPUT); //Wing LED
pinMode(17, OUTPUT); //Wing LED
pinMode(18, OUTPUT); //Wing LED
pinMode(19, OUTPUT); //Wing LED
pinMode(20, OUTPUT); //Wing LED
pinMode(13, OUTPUT); // Status LED
pinMode(touchPinFull, INPUT);
pinMode(11, INPUT_PULLUP); // Pushbutton
}
void loop()
{touchStateFull = digitalRead(touchPinFull);
if (touchStateFull==LOW) // 12 pin is low due to pullup resistor - Returns 0, so this block happens. If it returns 1 (touch pressed, pin goes high), else (Full Wings) happens WINGS AT HOME, NO LIGHTS
{
if (digitalRead(11)) // 11 pin is high due to pullup resistor - Returns 1, so this block happens. If it returns 0 (button pressed, pin goes low), else happens WINGS AT HOME, NO LIGHTS
{
digitalWrite(13, LOW); //Status LED OFF
digitalWrite(14, LOW); //Wing LED OFF
digitalWrite(15, LOW); //Wing LED OFF
digitalWrite(16, LOW); //Wing LED OFF
digitalWrite(17, LOW); //Wing LED OFF
digitalWrite(18, LOW); //Wing LED OFF
digitalWrite(19, LOW); //Wing LED OFF
digitalWrite(20, LOW); //Wing LED OFF
myservoL.write(20); // Servo home position
myservoR.write(140); // Servo home position
chaseOn = false;
}
else
{
// Pin is Low - returns 0 - 12 pin is low due to pushbutton pressed WINGS HALF UP, LIGHTS
digitalWrite(13, HIGH); // Status LED on
myservoL.write(80); // Servo half up
myservoR.write(80); // Servo half up
chaseOn = true;
}
}
else
{
// Pin is High - returns 1 - 12 pin is high due to touch pressed WINGS FULL UP, LIGHTS
digitalWrite(13, HIGH); // Status LED on
myservoL.write(140); // Servo Full Up
myservoR.write(20); // Servo Full Up
chaseOn = true;
}
nacelleChase.loop();
}
This was all working fine, but I had to update my Teensy 3.x libraries to play audio from an SD card, and that required updating the Arduino software.
After the update, when I attempt to compile this I get this error message (I've removed much of the error due to forum limitations):
Arduino: 1.6.5 (Mac OS X), TD: 1.25, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimized (overclock), US English"
In file included from Pushbutton_Dual_Servos_With_Chase_Blink.ino:2:0:
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:1:5: error: stray '\302' in program
1 /*
^
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:1:5: error: stray '\240' in program
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:22:4: error: stray '\302' in program
22
^
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:22:4: error: stray '\240' in program
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:23:4: error: stray '\302' in program
23 #ifndef ChaseLEDs_h
^
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:23:4: error: stray '\240' in program
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:23:8: error: stray '#' in program
23 #ifndef ChaseLEDs_h
^
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:24:4: error: stray '\302' in program
24 #define ChaseLEDs_h
^
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:24:4: error: stray '\240' in program
/Users/ShawnM/Documents/Arduino/libraries/ChaseLEDs/ChaseLEDs.h:24:8: error: stray '#' in program
24 #define ChaseLEDs_h
^
Error compiling.
** This report would have more information with**
** "Show verbose output during compilation"**
** enabled in File > Preferences.**
I assume something's broken with the ChaseLEDs library, but I don't know what. The ChaseLEDs library is visible in the "Contributed libraries" section in the "Include Library" pulldown. If I start a new sketch, add the ChaseLEDs library, and then attempt to compile I get the same error message.
This is the ChaseLEDs.h code (with copyright info removed):
1 /*
22
23 #ifndef ChaseLEDs_h
24 #define ChaseLEDs_h
25
26 #include <inttypes.h>
27
28 class ChaseLEDs
29 {
30 public:
31 ChaseLEDs(const uint8_t *pins, int num, unsigned long advanceTime);
32
33 void loop();
34
35 unsigned long advanceTime() const { return _advanceTime; }
36 void setAdvanceTime(unsigned long advanceTime) { _advanceTime = advanceTime; }
37
38 protected:
39 virtual void advance(uint8_t prevPin, uint8_t nextPin);
40 uint8_t previousPin(int n) const
41 { return _pins[(_currentIndex + _numPins - n) % _numPins]; }
42
43 private:
44 const uint8_t *_pins;
45 int _numPins;
46 int _currentIndex;
47 unsigned long _advanceTime;
48 unsigned long _lastChange;
49 };
50
51 #endif
This is the code for ChaseLEDs.cpp:
1 /*
22
23 #include "ChaseLEDs.h"
24 #if defined(ARDUINO) && ARDUINO >= 100
25 #include <Arduino.h>
26 #else
27 #include <WProgram.h>
28 #endif
29
71 ChaseLEDs::ChaseLEDs(const uint8_t *pins, int num, unsigned long advanceTime)
72 : _pins(pins)
73 , _numPins(num)
74 , _currentIndex(-1)
75 , _advanceTime(advanceTime)
76 , _lastChange(millis())
77 {
78 for (uint8_t index = 0; index < _numPins; ++index) {
79 pinMode(_pins[index], OUTPUT);
80 digitalWrite(_pins[index], LOW);
81 }
82 }
83
87 void ChaseLEDs::loop()
88 {
89 if (_currentIndex >= 0) {
90 if ((millis() - _lastChange) >= _advanceTime) {
91 // Advance to the next LED in sequence.
92 _currentIndex = (_currentIndex + 1) % _numPins;
93 _lastChange += _advanceTime;
94 advance(previousPin(1), _pins[_currentIndex]);
95 }
96 } else {
97 // First time - light the first LED.
98 _currentIndex = 0;
99 _lastChange = millis();
100 advance(previousPin(1), _pins[_currentIndex]);
101 }
102 }
103
136 void ChaseLEDs::advance(uint8_t prevPin, uint8_t nextPin)
137 {
138 digitalWrite(prevPin, LOW);
139 digitalWrite(nextPin, HIGH);
140 }
141
This is the basis for the ChaseLEDs library I'm using:
http://rweather.github.io/arduinolibs/blink_startrek.html
Any help would be appreciated.
Thank you.
Shawn Marshall
Portland, OR