Jump to content

Venderwel

Eurobricks Vassals
  • Posts

    46
  • Joined

  • Last visited

Everything posted by Venderwel

  1. Yeah well depending of the size of your layout, using ESP boards especially for the sensors and switches and other stuff, might be a cheaper solution in stead of controlling everything with hubs. And also more flexible I think. Anyway, you have a new subscriber in me and can't wait to see what is more ahead. I use Mattzobricks project https://mattzobricks.com/ as a controller you might want to look into it and RocRail to orchestrate the layout. It's not much yet, but it works!
  2. Ah okay, that's brilliant! I am using Ikea AAA 750mAh batteries, but I guess that will be the same idea as your Toshiba's. Could I also use it to power an ESP8266/ESP32 board with it at the same time? That would make it even better for my layout! I mean to use an ESP8266 board with IR to automate PF hubs and motors. And the ESP32 with bluetooth for automation of PU. I know the ESP32 doesn't have to be on board with the train to work. But I'm guessing on real large layouts, Wifi might have a better range then bluetooth, so I want to add a esp32 on every PU train.
  3. I miss a small thing in your video's. What batteries are now inside the hub?
  4. I was thinking about doing something like this in the future, but then with some kind of brush contact on the charging station track. But this might be better!
  5. What makes you say that??
  6. Oh man, must have been living under a rock, only jyst saw this set today! I want it!
  7. Hi all, recently got a 9v train system. The Lego World City 4561, a compleet used set, all the bricks are still there! But now I want to use Arduino to be able to control it. And I need a little help setting it up. I found this website https://arduinolegotrains.wordpress.com/ And it uses this piece of code: //This sketch makes a classic 9V or 12V train move backwards and forwards on //the track for a fixed amount of time. int IN1=22; // train motor pin 1 int IN2=24; // train motor pin 2 int ENA=10; // train motor PMW void setup() //run once at startup { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); analogWrite(ENA, 110); } void loop() // run repeatedly from top to bottom { digitalWrite(IN1,LOW); // the train will move forward digitalWrite(IN2,HIGH); delay(250); // lock up for 0.25 seconds digitalWrite(IN1,LOW); // the train will stop digitalWrite(IN2,LOW); delay(2000); // lock up for 2 seconds digitalWrite(IN1,HIGH);// the train will move in reverse digitalWrite(IN2,LOW); delay(250); // Lock up for 0.25 seconds digitalWrite(IN1,LOW); // the train will stop digitalWrite(IN2,LOW); delay(2000); // lock up for 2 seconds } Now I am not a complete idiot, but I do feel like one. I know it has to do with the analogWrite but I can't get it to work on a AZ Delivery Wroom esp32 board. Maybe I don't know how to google anymore, but if someone here can help me a little in the right direction, that would be awesome!
  8. Any chance you can help me out for a bit on the wifi connection part? Can't get it to work .
  9. Looks great! Actually woring on my own little railplan with Matzzobricks controllers and RocRail right now. Have the sensors working, but can't seem to get the MTC4PU working. Looks like it doesn't connect to the Wifi or mqtt broker. Did you have any problems there?
  10. Hey Anthony, did you know the link in your signature is not working? 

  11. You use them completly upward? As in laying in the track?
  12. Maybe I need to experiment with it a little more, but for now I can't seem to get the range small enough. It keeps detecting my train at the otther end of the loop, or a person sitting there or stuff like that. And also can't seem to get a reliable reading when I actually do want it to detect, when a train is passing. Maybe it's to close? I don't know yet. Thing I still want to try is to have my IR on a bit of an angle up, maybe that helps. http://mattzobricks.com/ very informative!
  13. I plannend on using lightsensors for detecting trains. I found out these don't work good enough to use. So I decided to use IR sensor modules for that, they work to good, they sense all kind of things, not only the trains. So now I'm looking into using reed sensors, the way Mattzo is using them, seems to be near flawless! So I'll use them to detect trains in sectors and I'll use lego motors connected to L298n modules for track switches. Trains only PUp...... The rest is not decided yet. I'd like to be able to let all trains ride automatically, let the system decided when to stop where. But I'd also like to be able to run by hand and give actions during the automatic fase. First thoughts were to let the ESP32 do everything, but reading more stuff en watching more video's makes me thing the ESP32 should only be the man in the middle handling the sensors and switches and let the laptop and the train software like nControl or RocRail do the controling part. Having it on a screen like that makes also makes it easier to show someone else.
  14. If any of you @Toastie or @GianCann has an example for me, that would be very nice! ??
  15. I am going to test the software myself and I wonder if you could give me an example of your sketch. How do you put the sensors and switches in there to work with nControl?
  16. Thanx, I'll keep it in mind! For now I have 4 old 9v lego motors and as long as I can still get them for a reasonable price, I think I'll stick with those.
  17. Hey @Toastie, that's no problem at all! It's a thread about me getting my layout automised. With help of Arduino. Not being said all has to be in Arduino. If there are other programs that can make life easier and only use Arduino to control the switches and get input from the sensors. Even better! Also want others to learn from this thread. What I'd like my system to do in the end is: Be able to function on it's own: Random asign stations and routes to trains etc. Be able to easily add and control trains of other users. Also give me the option to asign stops to a train myzelf, handle that order and go on after the order is finished. Have a digital overview of my layout and see what train is where. Like for example in nControl by 4DBrix, I believe @GianCann is very busy with this one... ;-) (but I am open for other suggestions!) Be able to use something like https://scratch.mit.edu/ to have my kids (or maybe a class at school) program the tracks and trains. It will be a lot of work to get there I think, or maybe it's easier then I think.
  18. Okay so I just got my v9 motors in, tried them out with some simple code, but all they do is buzz instead of rotate. Is there someone who wants to share their ESP32 /l298 code with me? Wow forget about not working, I forgot to connect ground to the arduino!
  19. In the Leguino code I used in my sketch, you see there is a possibility to put in the BT address of the powerd up hub. But where how do I get that address? I need it for this idea: To know where which train is, I first need to indentify my trains (see above) if I know that, I am planning to place every train is a fixed starting/end sector. Then when the program starts the trains will leave their sectors one by one with sufficient time between them. So let's say the program always commands train A to start first. It sector 1 as I told the program that's where Train A starts. And let's asume I didn't screw it up by putting it in a different sector. Sensor in sector one detects it's not blocked anymore and soon after that the sensor in sector 2 detects a train. It has to be Train A, because other trains didn't get a move order yet. So I can now link sector 2 to Train A.....train moves on, sensor 2 is free and sensor in sector 3 gets blocked. It has to be Train A because that one was previously in sector 2. So I can link them together and free sector 2. Etc etc. Same goes for the other trains ofcourse. I know it's full of assumptions, but is it the right way to do it? Or do you people do it in a different way?
  20. I probably should do something with that.
  21. So this is what I have now.....it works as it is. But how should I clean it up? #define LDR1 34 #define LDR2 35 #include "PoweredUpHub.h" // create a hub instance PoweredUpHub myTrainHub; PoweredUpHub::Port _port = PoweredUpHub::Port::A; //settings char hubName[] = "Yellow train"; //variables int Traindetect; int Station; int TDcounter = 0; void setup() { pinMode (LDR1, INPUT); pinMode (LDR2, INPUT); Serial.begin(9600); } // main loop void loop() { //connect the powerdUP train if (!myTrainHub.isConnected() && !myTrainHub.isConnecting()) { myTrainHub.init(); // initalize the PoweredUpHub instance //myTrainHub.init("90:84:2b:03:19:7f"); //example of initializing an hub with a specific address } // connect flow. Search for BLE services and try to connect if the uuid of the hub is found if (myTrainHub.isConnecting()) { myTrainHub.connectHub(); if (myTrainHub.isConnected()) { Serial.println("Connected to HUB"); } else { Serial.println("Failed to connect to HUB"); } } // if connected, set train name and color if (myTrainHub.isConnected()) { myTrainHub.setHubName(hubName); myTrainHub.setLedColor(GREEN); delay(1000); } else { Serial.println("Train hub is disconnected"); } Train_Detector(); Station_Stopper(); } //code where LDR1 will count how many times a train passes void Train_Detector() { Traindetect = digitalRead(LDR1); if (Traindetect == 1) { TDcounter++; Serial.print("The train passed "); Serial.print(TDcounter); Serial.println(" times!"); Serial.print("Value Traindetect:"); Serial.println(Traindetect); delay(1000); } else { Serial.print("The train passed "); Serial.print(TDcounter); Serial.println(" times!"); Serial.print("Value Traindetect:"); Serial.println(Traindetect); delay(1000); } } //station code: using counter to decide what to do, every 5 passes at Train_Detector should make the train stop at the station. void Station_Stopper() { Station = digitalRead(LDR2); int Scounter = TDcounter % 5 ; //if the traincounter reaches a number that can be devided by 5 it will set Scounter = 0 if (Station == 1 && Scounter == 0) { //train is detected and 5 passes have been done the train stops and leaves again after 3 seconds (Future: trackswitch not allowed to this section!) myTrainHub.stopMotor(_port); delay(1000); Serial.print(hubName); Serial.println(" has stopped at the station!"); Serial.print("Value Station:"); Serial.println(Station); delay(3000); myTrainHub.setMotorSpeed(_port, 35); Serial.print(hubName); Serial.println(" has left the station!"); delay(2000); } else if (Station == 0 && Scounter == 0) { //train is not detected yet but 5 passes have been done, message train is coming (Future: trackswitch should react) Serial.println("Train should stop when arriving at station!"); Serial.print("Value Station:"); Serial.println(Station); delay(1000); } else { //let it go let it go Serial.println("Train should pass the station!"); Serial.print("Value Station:"); Serial.println(Station); delay(1000); } } There are a lot of print commands, but that basically is for me to see what is going on. Am I in the right piece of code? And since I don't want to have the text rambling on my screen, I put in the delay;s. The delay's do what I want, meaning I don't see a message every millisecond, but it halts the code too right?
  22. Cool, I can now count the number of times the train passes sensor 1 and make it stop at sensor 2 every 5 passes! Just have to work out something that the counter sensor counts right. I now just build in a delay of one second. But if the train takes longer then one second to pass, if will count it as a new pass. So I think I will need to build in some kind of sensor state.
  23. Here is a nice example of how the IR detection module works.
  24. The solutions of @Toastie and @GianCann don't need sensors at two sides of the track right?
  25. Can we have a close look of the reed and IR solutions?
×
×
  • Create New...