Meine Homepage

Arduino 11

12,10,2017


Arduino Sketch Weichensteuerung für die LGB Weichen.

Die Servoplatine ist so praktisch ich habe diese Platine schon oft mit dem Nano bestückt
und das hat bis heute sehr gut funktioniert.Doch jetzt brauche ich einige Servos mehr
meine LGB Anlage hat jetzt schon einige Weiche die in der Werkstatt auf einen Servoweichenantrieb warten.
Aus diesem Grund mahe ich mich wieder einmal für einen Arduino Mega entschieden.

Die anderen Streifenplatinen werden nach und nach mit Drähten bestückt.
Wenn die Kabelbäume angeschlossen sind werde ich mich um die Schalter kümmern!

Hier ist schon einmal ein Servo zum Testen angeschlossen, nun muss ich erst einmal wieder einige Drähte verlöten.
Ich werde hier an Steller von POTIs Wechselschalter verbauen und die werden Analogewerte zu den PINs A0-A14 senden. Mal schauen wie das nachher funktioniert?
Wie es hier weiter geht...

Zurück zur Startseite

14,10,2017
was für ein Tag heute wurde soviel erledigt und auch hier habe ich weiter machen können.
Manchmal braucht man etwas Abstand zum Projekt und auf einmal funktioniert es einfach!

Hier einmal der neue Sketch für die große Baustelle:

#include <Servo.h>

Servo myservo;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
Servo myservo7;
Servo myservo8;
Servo myservo9;
Servo myservo10;
Servo myservo11;
Servo myservo12;
Servo myservo13;
Servo myservo14;
 
const int b1 = 22;
const int b2 = 23;
const int b3 = 24;
const int b4 = 25;
const int b5 = 26;
const int b6 = 27;
const int b7 = 28;
const int b8 = 29;
const int b9 = 30;
const int b10 = 31;
const int b11 = 32;
const int b12 = 33;
const int b13 = 34;
const int b14 = 35;
const int b15 = 36;

int Weiche1;
int Weiche2;
int Weiche3;
int Weiche4;
int Weiche5;
int Weiche6;
int Weiche7;
int Weiche8;
int Weiche9;
int Weiche10;
int Weiche11;
int Weiche12;
int Weiche13;
int Weiche14;
int Weiche15;

int P = 90;

void setup()
{
 
  myservo.attach(2);
  myservo1.attach(3);
  myservo2.attach(4);
  myservo3.attach(5);
  myservo4.attach(6);
  myservo5.attach(7);
  myservo6.attach(8);
  myservo7.attach(9);
  myservo8.attach(10);
  myservo9.attach(11);
  myservo10.attach(12);
  myservo11.attach(13);
  myservo12.attach(44);
  myservo13.attach(45);
  myservo14.attach(46);  
  pinMode(b1, INPUT);
  pinMode(b2, INPUT);
  pinMode(b3, INPUT);
  pinMode(b4, INPUT);
  pinMode(b5, INPUT);
  pinMode(b6, INPUT);
  pinMode(b7, INPUT);
  pinMode(b8, INPUT);
  pinMode(b9, INPUT);
  pinMode(b10, INPUT);
  pinMode(b11, INPUT);
  pinMode(b12, INPUT);
  pinMode(b13, INPUT);
  pinMode(b14, INPUT);
  pinMode(b15, INPUT);

  digitalWrite(b1, true);  // pullup Wiederstand einschalten
  digitalWrite(b2, true);  // pullup Wiederstand einschalten
  digitalWrite(b3, true);  // pullup Wiederstand einschalten
  digitalWrite(b4, true);  // pullup Wiederstand einschalten
  digitalWrite(b5, true);  // pullup Wiederstand einschalten
  digitalWrite(b6, true);  // pullup Wiederstand einschalten
  digitalWrite(b7, true);  // pullup Wiederstand einschalten
  digitalWrite(b8, true);  // pullup Wiederstand einschalten
  digitalWrite(b9, true);  // pullup Wiederstand einschalten
  digitalWrite(b10, true);  // pullup Wiederstand einschalten
  digitalWrite(b11, true);  // pullup Wiederstand einschalten
  digitalWrite(b12, true);  // pullup Wiederstand einschalten
  digitalWrite(b13, true);  // pullup Wiederstand einschalten
  digitalWrite(b14, true);  // pullup Wiederstand einschalten
  digitalWrite(b15, true);  // pullup Wiederstand einschalten
}

void loop()
{
 
  Weiche1 = digitalRead(b1);
  myservo.write(P);
  if (Weiche1 == HIGH) P=90;
  if (Weiche1 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche2 = digitalRead(b2);
  myservo1.write(P);
  if (Weiche2 == HIGH) P=90;
  if (Weiche2 == LOW)  P=0;
  delayMicroseconds(20);

  Weiche3 = digitalRead(b3);
  myservo2.write(P);
  if (Weiche3 == HIGH) P=90;
  if (Weiche3 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche4 = digitalRead(b4);
  myservo3.write(P);
  if (Weiche4 == HIGH) P=90;
  if (Weiche4 == LOW)  P=0;
  delayMicroseconds(20);

  Weiche5 = digitalRead(b5);
  myservo4.write(P);
  if (Weiche5 == HIGH) P=90;
  if (Weiche5 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche6 = digitalRead(b6);
  myservo5.write(P);
  if (Weiche6 == HIGH) P=90;
  if (Weiche6 == LOW)  P=0;
  delayMicroseconds(20);

   Weiche7 = digitalRead(b7);
  myservo6.write(P);
  if (Weiche7 == HIGH) P=90;
  if (Weiche7 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche8 = digitalRead(b8);
  myservo7.write(P);
  if (Weiche8 == HIGH) P=90;
  if (Weiche8 == LOW)  P=0;
  delayMicroseconds(20);

  Weiche9 = digitalRead(b9);
  myservo8.write(P);
  if (Weiche9 == HIGH) P=90;
  if (Weiche9 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche10 = digitalRead(b10);
  myservo9.write(P);
  if (Weiche10 == HIGH) P=90;
  if (Weiche10 == LOW)  P=0;
  delayMicroseconds(20);

   Weiche11 = digitalRead(b11);
  myservo10.write(P);
  if (Weiche11 == HIGH) P=90;
  if (Weiche11 == LOW)  P=0;
  delayMicroseconds(20);

   Weiche12 = digitalRead(b12);
  myservo11.write(P);
  if (Weiche12 == HIGH) P=90;
  if (Weiche12 == LOW)  P=0;
 delayMicroseconds(20);

  Weiche13 = digitalRead(b13);
  myservo12.write(P);
  if (Weiche13 == HIGH) P=90;
  if (Weiche13 == LOW)  P=0;
  delayMicroseconds(20);

  Weiche14 = digitalRead(b14);
  myservo13.write(P);
  if (Weiche14 == HIGH) P=90;
  if (Weiche14== LOW)  P=0;
 delayMicroseconds(20);

  Weiche15 = digitalRead(b15);
  myservo14.write(P);
  if (Weiche15 == HIGH) P=90;
  if (Weiche15 == LOW)  P=0;
  delayMicroseconds(20);
  }

--------------------------------------------
Der Rest wird dann wie gehabt in den nächsten paar Wochen fertig gestellt wenn die ganzen Schalter bei mir aufgeschlagen sind!!!

Zurück zur Startseite
Diese Webseite wurde kostenlos mit Homepage-Baukasten.de erstellt. Willst du auch eine eigene Webseite?
Gratis anmelden