Lego.SingleOutput(0, PWM_FWD1, BLUE, CH1) // Start up train PinMode(reed1Pin, INPUT) // Init reed switch1 as input PinMode(ledPin, OUTPUT) // Init LED pin as output Int reed1Pass = 0 // Variable for counting train passing reed switch1 Int reed1State = 0 // Variable for reading reed switch1 status LEGOPowerFunctions lego(12) // IR LED on pin 12Ĭonst int reed1Pin = 2 // Reed switch1 on pin 2 LEGOPowerFunctions library by Roland Wiersma To test I put wrote this simple Arduino sketch making use of Roland Wiersma's PF library. Another idea might be to let kids at events control the trains with the IR Speed Remote and use the Arduino to monitor and send an over-ride stop or slow the train command if the kids break a speed limit or run a signal. Positive Train Control so I don't get my Amtrak train fly off the curve. Maybe I could implement speed sensing with two or more reed switches using time between switch trigger to calculate train speed. I am not sure I need to use them all to operate trains although they could be handy to "momentum" brake the train into a station and stuff like that. I think Roland Wiersma's LEGO Power Function library also supports the PWM increase/decrease modes. Lego.SingleOutput(0, PWM_FWD6, RED, CH2) Lego.SingleOutput(0, PWM_FWD5, RED, CH2) Lego.SingleOutput(0, PWM_FWD4, RED, CH2) Lego.SingleOutput(0, PWM_FWD3, RED, CH2) Lego.SingleOutput(0, PWM_REV4, RED, CH2) Level 7 was too much around the curve with the tracks sliding around on the folding table. I used this in the video of my Amtrak train engine. Are you refering PWM to set the speed to one of 7 levels? It appears that all my IR receivers are version 1.1 that blink blink when powered on. According to Philio, there is a bug with single pin mode on the version 1.0 of the IR Receiver. They added an address bit in the protocol that could be used for an additional 4 channels. I made use of a LEGO Power Function library ( ) Some resources on the Internet say IR LED in the 940nm range works best for Power Function IR receivers. Note the site is in Chinese: įor a quick test, I hooked up an IR LED desoldered from an old DVD player remote to the board and wrote a simple sketch. The driver can be downloaded from the Chinese manufacturer's website. It doesn't come with the IDE software from the Arduino website. In order for the Arduino IDE to communicate with the board, the CH341 driver has to be installed. It uses a CH340 USB to serial chip instead of the FTDI USB to serial chip found on the real Arduino. The clone is not quite exactly the same as the real Arduino UNO. ![]() ![]() I figured for $4 USD, it is not a big lost if I fried it. We agreed to make Power Functions our club standard. We are basically starting new with the current LEGO train and power offerings. One of the requirements would be battery power option. Some of our events are outside in the park where there is no plug in power. We are starting to display trains and don't have anything permanently built. I plan to use it to add some inexpensive automation to our LUG's ad hoc layout. After a month, my Arduino clone has arrived from China.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |