I have a sketch for Model Railway turnouts which I did copy from another site and I get a stray\342 error
which from looking at other posts it maybe a character error but not sure as my programming skills are limited, I also notice there is no Void Loop() on this sketch.
Would be grateful if anyone could help inentify problem...
/*This sketch is designed to operate Model Railway Points that are driven by Servo Motors
*A SPDT switch connected to + and – 5vDC with the centre tap going to an Input Pin.
*
*This will scan a predefined set if Pins and allocate as INPUT then set them LOW.
*Dependant on the PIN STATE and whether or not it has changed it will rotate a SERVO on the active pin
*to a pre-determined location as set out in the SERVOMIN/SERVOMAX arrays.
*Millis() function has been used to streamline the operation.
*Serial.print can be removed, they are just for checking.
*
*Machine:- UNO R3 and 16 Servo Controller
*
*Created by Doug Reed 10/05/2016
*
*My thanks to the Forum Members who pointed me in the right direction.
*/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
unsigned long previousMillisSWITCH=0; //Button Millis() setup
int intervalSWITCH = 20; //intervals for millis()
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); // called this way, it uses the default address 0x40
unsigned int SERVOMIN[11] = {172,172,172,246,246,172,246,200,200,150}; //servo lower setting to suit individual servo
unsigned int SERVOMAX[11] = {565,530,500,492,492,565,492,550,550,525}; //servo upper setting to suit individual servo
int inPin[11] = {2,3,4,5,6,7,8,9,10,11,12}; //array of input pins
int pinCount = 11; //the number of pins used, lenght of array
int Dir = 0;
int oldDir[11];
int newDir[11];
int thisPin;
int degrees;
void setup() {
Serial.begin(9600);
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
for (int thisPin = 0 ; thisPin < pinCount ; thisPin++) { //"thisPin" is array position
pinMode(inPin[thisPin],INPUT); //sets all pins 2 -12 as INPUT
}
for (int thisPin = 0 ; thisPin = intervalSWITCH) { // time between button presses
for (int thisPin = 0 ; thisPin < PinCount ; thisPin++) { //assess the direction settings
Dir = digitalRead(thisPin+2);
oldDir[thisPin] = newDir[thisPin];
Serial.print(inPin[thisPin]);
Serial.print(" Dir ");
Serial.println(Dir);
if ((Dir == 1) && (oldDir[thisPin] == 0)){
for (uint16_t pulselen = SERVOMIN[thisPin]; pulselen SERVOMIN[thisPin]; pulselen–) {
pwm.setPWM(thisPin, 0, pulselen);
Serial.print(inPin[thisPin]);
Serial.print(” LOW “);
Serial.println(pulselen);
}
NewDir[thisPin] = 0;
}
}
}
previousMillisSWITCH = currentMillis;
}