ElectroDiva Posted February 27, 2019 Posted February 27, 2019 Welcome to the forum @holisko - the first post is always the hardest :) I’m looking forward to hearing how your project to recreate your home town’s rail network progresses. You should create a separate topic for that when you’re ready. @Cosmik42 - you weren’t joking about sensor availability. There’s virtually no stock of the Boost Color and Distance sensor on Bricklink in Europe! I was going to try to use those on my trains for track colour detection. Quote
Lok24 Posted February 27, 2019 Posted February 27, 2019 (edited) 8 minutes ago, ElectroDiva said: - you weren’t joking about sensor availability. There’s virtually no stock of the Boost Color and Distance sensor on Bricklink in Europe! There are rumors(!) that all componetns will be availble at LEGO S@H in summer. Here's a list with numbers.... unfortunately there is no number for the sensor - yet. Boost Move Hub 88006 Motor 88008 ColorSensor Powered Up LED Light 88005 Train Motor 88011 Smart Hub 88009 Handset 88010 Edited February 27, 2019 by Lok24 Quote
ElectroDiva Posted February 27, 2019 Posted February 27, 2019 Cheers @Lok24 - hopefully those rumours are true and there’s better supply going forward. In the meantime I’ve taken a chance and ordered some from a store in Korea. Let’s see if they show up :) Quote
Cosmik42 Posted February 27, 2019 Author Posted February 27, 2019 21 hours ago, holisko said: Absolutely mind-blowing! Ah thank you sooo much for taking the time to write this feedback. It makes the long hours of coding all worth it :) I did receive 4DBrix hardware! Work is completely crazy this week, but I hope to be able to tackle it next week! Quote
Giottist Posted February 27, 2019 Posted February 27, 2019 9 hours ago, Lok24 said: There are rumors(!) that all componetns will be availble at LEGO S@H in summer. Here's a list with numbers.... unfortunately there is no number for the sensor - yet. Boost Move Hub 88006 Motor 88008 ColorSensor Powered Up LED Light 88005 Train Motor 88011 Smart Hub 88009 Handset 88010 The rumors have a real background: On January 9th LEGO anounced the components on their website including the color sensor: 88007. LEGO mentioned prices but not for the color sensor. On January 12th LEGO removed the anouncment again ... For the later anounced Control+ device no number is known - we have to wait until August. Quote
Lok24 Posted February 28, 2019 Posted February 28, 2019 Hi, I just wanted to set up the finished program on another laptop, but loading the project its shows all 4 hubs left with "no connection" and add the same devices again (on the right, the active ones) How can I delete the old ones, as the auto-numbering is now 4-7 instead opf 0-3, so nothing works at all THX Quote
Cosmik42 Posted February 28, 2019 Author Posted February 28, 2019 41 minutes ago, Lok24 said: Hi, I just wanted to set up the finished program on another laptop, but loading the project its shows all 4 hubs left with "no connection" and add the same devices again (on the right, the active ones) How can I delete the old ones, as the auto-numbering is now 4-7 instead opf 0-3, so nothing works at all THX It looks like the Bluetooth address is not linked to the device, but to the computer. This is very strange. I have to investigate. Quote
Lok24 Posted February 28, 2019 Posted February 28, 2019 I used the same USB-Dongle in both machines..... Quote
Cosmik42 Posted February 28, 2019 Author Posted February 28, 2019 Just now, Lok24 said: I used the same USB-Dongle in both machines..... It looks like it is a Laptop/PC-dependent address then. Quote
Lok24 Posted February 28, 2019 Posted February 28, 2019 (edited) Here is the entry from the .lpt-file: Handset :BluetoothLE#BluetoothLE00:1a:7d:da:71:04-a4:34:f1:ce:5c:45E\ a4:34:f1:ce:5c:45E is MAC of my Handset 00:1a:7d points do cyber-bkue(HK) ?? Edited February 28, 2019 by Lok24 Quote
Lok24 Posted March 1, 2019 Posted March 1, 2019 (edited) Ah, found out: 00:1a:7d:da:71:04 is the BT Adapter of a different device (Laptop)! So the program stores the combination of PC-BT and Hubs. So it's impossible to use a stored .lpt on a different device or the same program for other hubs. Edited March 1, 2019 by Lok24 Quote
Lok24 Posted March 3, 2019 Posted March 3, 2019 Hi, my new Project can be found here, a smart remote control: Quote
Cheatay Posted March 8, 2019 Posted March 8, 2019 Hello Cosmik42 First, congratulations on your great job and sharing ! Do you think to integrate the function to play an mp3 file to your program ? Like the whistle of a train before leaving the station for example ? Regards, Cheatay Quote
Lok24 Posted March 8, 2019 Posted March 8, 2019 (edited) Hi @Cheatay You can easily do it yourself, just put some lines of code into global code, have a look: https://www.eurobricks.com/forum/index.php?/forums/topic/169318-control-all-your-powered-up-power-function-sbrick-devices-with-a-single-software/&page=12&tab=comments#comment-3075167 Edited March 8, 2019 by Lok24 Quote
Cheatay Posted March 8, 2019 Posted March 8, 2019 Thank you Lok24, but I do not know anything about programming and I do not know how to modify the code :( Quote
Lok24 Posted March 8, 2019 Posted March 8, 2019 Hi, no problem. You will learn it in a few minutes. just put the program below completely into the Global code (you find this in the menu under "programs") Click the button "compile code" left bottom, should give "succesful" then you need some .wav files (I think .mp3 work as well) and adjust the program to reflect the names (Points 1+2) Click the button "compile code" left bottom, should give "succesful" Adjust path (point 3) Click the button "compile code" left bottom, should give "succesful" and in the event or the sequence you just write play(bell); If you get FATAL: maybe your path is incorrect or file doesnt exist Try it! Here is the program: public static string [] sound = { // Filenames "xxx", "sound1", // <-----1------ change this into a filename on your disk without the .wav "sound2", // <------2----- change this into a filename on your disk without the .wav }; public const int bell = 1; //<---------- change "bell" into the name you want to use to start the sound or leave it as "bell" public const int hupe = 2; // <---------- change "hupe" into the name you want to use to start the sound or leave it as "hupe" public const string path = "E:\\Daten\\Lego\\Boost - PU - SBrick\\PoweredUp\\LegoTrainProject\\Sounds\\"; // <-----3----- change this to the path your sounds are on disk, note the double \\ // ----play---------------------------- // <------ leave the rest as it is static void play(int so) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); string fn = path + sound[so] +".wav"; player.SoundLocation = fn; player.Play(); } Quote
Cheatay Posted March 8, 2019 Posted March 8, 2019 Thanks again :) but it does not work. I checked the names and directories: everything looks ok. What I have in the global code: // The code in this section will be available in all other programs! // ////////////////////////////////////////////////// ///////////////////// // Create your own enums public enum MyEnum { MyYellowTrain = 0, MyRedTrain = 1 } // Create your own helper functions public void MyGlobalFunction () { // Execute your code here public static string [] sound = {// Filenames "Xxx" "Siflement1", // <----- 1 ------ change this to a filename on your disk without the .wav "sound2", // <------ 2 ----- change this into a filename on your disk without the .wav }; public const int bell = 1; // <---------- changes "bell" to the name you want to start the sound or leave it as "bell" public const int hupe = 2; // <---------- changes "hupe" into the name of "hupe" public const string path = "C: \\ Users \\ Denis \\ Downloads \\ Lego \\ Layout \\"; // <----- 3 ----- change this to the path of the sounds on the disk, note the double \\ // ---- play ---------------------------- // <------ leave the rest as it is static void play (int so) { System.Media.SoundPlayer player = new System.Media.SoundPlayer (); string fn = path + sound [so] + ". waw"; player.SoundLocation = fn; player.Play (); } } // Create your own constants! public const int RED_TRAIN = 1; public const int YELLOW_TRAIN = 2; and error messages: Compiling code ... Compiling failed. Error (CS1513):} expected Error (CS1518): Class, delegate, enum, interface, or expected struct Error (CS1518): Class, delegate, enum, interface, or expected struct Error (CS1518): Class, delegate, enum, interface, or expected struct Error (CS1518): Class, delegate, enum, interface, or expected struct Error (CS1001): The expected identifier Error (CS0116): A namespace can not directly contain members such as fields or methods Error (CS1022): Definition of type or namespace, or expected end of file Quote
freestorm Posted March 9, 2019 Posted March 9, 2019 (edited) 1 hour ago, Cheatay said: Thanks again :) but it does not work. I checked the names and directories: everything looks ok. In English: I do no have this program installed (I'm on Linux), But maybe I can help :-) Can you remove the line "xxx" public static string [] sound = { "Siflement1", "sound2", }; Can you remove space in the directory path (I don't know if it's a copy past error or not): public const string path = "C: \\ Users \\ Denis \\ Downloads \\ Lego \\ Layout \\"; // <----- 3 ----- change this to the path of the sounds on the disk, note the double \\ public const string path = "C:\\Users\\Denis\\Downloads\\Lego\\Layout\\"; In French Il faudrait que tu essaies d'enlever la ligne "XXX" ou tu rajoutes une virgule à la fin de la ligne "xxx", Je ne sais pas si c'est voulu ou une erreur de copier/coller mais tu ne dois pas avoir des espaces là ou tu as mis le chemin ou se trouve tes fichiers son. Est ce que tu as bien les fichiers "Siflement1.wav" et "sound2.wav" dans le répertoire C:\Users\Denis\Downloads\Lego\Layout\ ? Essaies de copier coller le code suivant: (malheureusement je ne peux pas tester de mon coté) // Create your own enums public enum MyEnum { MyYellowTrain = 0, MyRedTrain = 1 } // Create your own helper functions public void MyGlobalFunction() { // Execute your code here public static string [] sound = { "Siflement1", "sound2" }; public const int bell = 1; public const int hupe = 2; public const string path = "C:\\Users\\Denis\\Downloads\\Lego\\Layout\\"; // ---- play ---------------------------- static void play(int so) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); string fn=path+sound[so]+".waw"; player.SoundLocation=fn; player.Play(); } } Edited March 9, 2019 by freestorm typo Quote
Lok24 Posted March 9, 2019 Posted March 9, 2019 (edited) Hi @Cheatay, very good, one small error: the code you insert (so my sound-example) belongs in Line 1 or at the end, but never(!) in the section // Create your own helper functions public void MyGlobalFunction() Was my fault, I didn't make that clear. And yes, after the line "Xxx" there must be a comma to seperate form next line. Or just remove it. What you have there with the filenames is a simple list, you can write it {"file0","file1";"file2",....} as well. And yes, there should not be blanks in the path, but i suppose they come from copying here in the thread For a beginner in programming you are doing very well, give your code, examples and error messages, brilliant. Edited March 9, 2019 by Lok24 Quote
Cheatay Posted March 9, 2019 Posted March 9, 2019 hi again I tested at the moment and still no result :( The global code: public static string [] sound = { "siflement1", }; public const int bell = 1; public const string path = "C: \\ Users \\ Rebecca \\ Downloads \\ Lego Train Project \\"; // ---- play ---------------------------- // static void play (int so) { System.Media.SoundPlayer player = new System.Media.SoundPlayer (); string fn = path + sound [so] + ". wav"; player.SoundLocation = fn; player.Play (); } The compil is ok but when I execute the command "play (bell);", I have the following error: "FATAL ERROR In Program: The index is outside the bounds of the table." Quote
Lok24 Posted March 9, 2019 Posted March 9, 2019 (edited) Hi, good news This is a list with one(!) element "siflement1" { "siflement1", }; but count starts with 0(!!!) So please change public const int bell = 1; into public const int bell = 0; A programmer would say: bell "points" to the element 0, the content of which is "siflement1" And in this line string fn = path + sound [so] + ". wav"; it must be ".wav" and not ". wav" otherwise you have a blank in your filenanme After this line you may insert: MainBoard.WriteLine(fn); This will display the complete filename... Good Luck! Edited March 9, 2019 by Lok24 Quote
Cheatay Posted March 9, 2019 Posted March 9, 2019 Yeah ! It works ! I think I use it to animate train traffic: make a hissing sound when approaching a bridge, whistle the wharf leader when the train arrives at the station and start the announcement at the microphone of train departure ect ... Thanks again for the help :) Quote
Lok24 Posted March 10, 2019 Posted March 10, 2019 Just some explanation to learn a little bit programming You have a list of Filenames which is called "sound": public static string [] sound = {"siflement1","File2","file3".....}; So you automatically have 3 variables: sound[0], sound[1], sound[2] If you add a filename to the list you can address sound[3] But the "play"-Routine doesnt expect the name of the file, but a number! So you can start it with "play(0);" "play(12); " would lead to an error, cause list "sound" has only 3 Elements, numbered form 0 to 2. And to add symbolic names (bell) which are easy to remember (filenames might by different) you add line like: public const int bell = 1; So its the same if you write "play(1);" or "play(bell);" Have fun! Quote
Cheatay Posted March 10, 2019 Posted March 10, 2019 thank you so much Cosmik42, freestorm and Lok24 Tanks to you, I was able to start the tests on my layout not yet finished. I plan to run several trains but I have to buy sensors and hubs. A video to show an example of sound integration in the layout : Quote
coinoperator Posted March 13, 2019 Posted March 13, 2019 Hi, I wonder if there is a way to get the Servo's under control with this software? I did a try on it but excepr for far left or right the servo goes into some shaker mode in all other positions, even in zero. (there is that thing that I have in mind that gets me an ice cold beer from the fridge, opens it and brings it to me) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.