Hello,
I need some code changed. I would like to do it myself, but I had a stroke that has limited some of my logic abilities. So I need help.
Now I am basically limited to uploading code and, with the help of my wife, doing the necessary wiring.
I am using an arduino mega and pca9685.
So I ask if someone could do this for me.
I will pay if necessary.
There are to be 12 turnouts.
There will be 6 lights per turnout. 2 on each leg and 2 on the control panel.
Code is to be modified so that LEDS are shifted out to a shift register.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
int buttonPin0 = 2; // Can add as many buttons as needed
int ledPin0C = 3; // C designates Closed position of turnout
int ledPin0T = 4; // T designates Thrown position of turnout
int buttonState0 = 0;
int buttonPin1 = 5;
int ledPin1C = 6;
int ledPin1T = 7;
int buttonState1 = 0;
void setup() {
Serial.begin(9600);
Serial.println("pca9685_TurnoutFinal!");
pwm.begin();
pwm.setPWMFreq(60);
delay(30);
pinMode(ledPin0C, OUTPUT);
pinMode(ledPin0T, OUTPUT);
pinMode(buttonPin0, INPUT);
pinMode(ledPin1C, OUTPUT);
pinMode(ledPin1T, OUTPUT);
pinMode(buttonPin1, INPUT);
}
void loop() {
///////////
buttonState0 = digitalRead(buttonPin0);
if (buttonState0 == HIGH) {
pwm.setPWM(0, 0, 370);
digitalWrite(ledPin0T, LOW);
digitalWrite(ledPin0C, HIGH);
}
else {
pwm.setPWM(0, 0, 285);
digitalWrite(ledPin0C, LOW);
digitalWrite(ledPin0T, HIGH);
}
//////////
buttonState1 = digitalRead(buttonPin1);
if (buttonState1 == HIGH) {
pwm.setPWM(1, 0, 370);
digitalWrite(ledPin1T, LOW);
digitalWrite(ledPin1C, HIGH);
}
else {
pwm.setPWM(1, 0, 285);
digitalWrite(ledPin1C, LOW);
digitalWrite(ledPin1T, HIGH);
}
//////////
}