Jump to content
 

RudyB

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by RudyB

  1. Fun with Arduino 17 Railway Crossing, State Transition Diagram, switch() We're at the start of a new Arduino project: an automatic railway crossing. The system comprises several parts: train detection (optical), blinking lights ('blink' with a twist), a moving beam (servo motor). We'll look into a way of specifying these kinds of systems as well as a way to translate the specifications into code, with a stepwise approach that does not put too much strain on our grey cells. Fun with Arduino 17 Railway Crossing, State Transition Diagram, switch()
  2. Fun with Arduino 16 LED Dimming with Fade, analogWrite(), millis() Now that we know how to dim LEDs with analoWrite(), we can go a step further and change the dimming over time to create a gradual fade in or out. This is a nice effect for instance for LED strips mounted under kitchen cabinets, or for LED strip overhead lighting on a model railway layout to simulate a gradual change from night to day. And also for the red/green transition of railway signals along the track a fade gives just that little extra eye candy. Fun with Arduino 16 LED Dimming with Fade, analogWrite(), millis()
  3. Fun with Arduino 15 LED Dimmer, analogWrite(), Pulse Width Modulation We used analogRead() to read the voltage on our potentiometer. The Arduino also has the opposite instruction: analogWrite(). This name is somewhat misleading. Unlike with an analog input, where a 10 bit A/D converter is used, the Arduino does not have a D/A converter on board. The analogWrite() function uses a technique called Pulse Width Modulation. A digital output switches between HIGH and LOW in a fast pace, whereby the HIGH percentage is proportional to the analog value we wish to send out. If a device that receives the signal is too slow to follow the switching frequency, the result is it 'sees' the average of the on/off times. This also holds for light ... even though LEDs are fast enough to follow the switch frequency, our human eyes + brain are not and we see an average brightness. Fun with Arduino 15 LED Dimmer, analogWrite(), Pulse Width Modulation
  4. Fun with Arduino 14 Day Night Cycle with millis(), no Delay, Direct Feedback Now that we know how to get rid of the delay(0 and use millis() in stead (video 13) we can finalize our Automatic Day Night Light Cycle unit to have direct on screen feedback of cycle time adjustment by the user and to have the cycle stop, and the lights turn off, immediately when the switch is set to ‘off’. Our unit has quite nice specifications: - Configurable timing, via keyboard or via analog input with on screen display - An option to randomize the times to give it some ‘livelyness’ - On screen display of the on/off, day/night state and the cycles times Fun with Arduino 14 Day Night Cycle with millis(), no Delay, Direct Feedback
  5. Fun with Arduino 13 Timer with millis(), no delay(), Multitasking The delay() statement that we used so far for our timing stalls the Arduino. This leads to a complete lack of feedback when we change the cycle time while the cycle is running. Luckily there is a solution: we can use the Arduino internal clock, which counts milliseconds from the moment the Arduino is started. We can read the clock using the millis() statement and we can decide if it is time for action. Fun with Arduino 13 Timer with millis(), no delay(), Multitasking
  6. Fun with Arduino 12 Analog Input, analogRead(), Change Range, map() Now that we can change the cycle time via the PC keyboard, let's have a look at a hardware oriented solution ... a rotating knob. We connect a potentiometer to an analog input and read the voltage with the analogRead() instruction. With the map() instruction we can convert the range from 0-1023 to the range that we like to use for our cycle time, like say 1-9 minutes with a 1 minute step size, or maybe 10-300 seconds, with a 10 second step size. Fun with Arduino 12 Analog Input, analogRead(), Change Range, map()
  7. Fun with Arduino 11 Keyboard Input via Serial Read and ParseInt The User Interface works, it shows the status if the day / night cycle on screen. We're now going to add the option to change the cycle time via the keyboard. The functions we are going to use are Serial.available(), which tells us that there is new input, and Serial.read() or Serial.parseInt() to read the characters that are typed. Fun with Arduino 11 Keyboard Input via Serial Read and ParseInt
  8. Fun with Arduino 09 Variables byte int long unsigned Before we continue to work on our User Interface, let's first take a moment to have a closer look at variables and data types. We are going to use ever more variables in the coming videos ... and ... we'll have a look at a pitfall concerning data types that prevented our code from previous video 8 to always work as intended. Fun with Arduino 09 Variables byte int long unsigned PS: I started the post here because there already was another Arduino thread here: Arduino Applications and Programs. If a board admin feels inclined to move it to a 'better' location it's perfectly fine with me.
  9. @Keith I don't know if this series of 'introductory videos' will reach the point of covering DCC applications, that requires more advanced code. Arduino DCC applications are available for download on My blog Rudysmodelrailway. They cover topics like DCC servo decoder, DCC accassory decoder, S88 bus encoder, a DCC sniffer ... and more.
  10. Fun with Arduino 08 User Interface Serial.print() Our way of modifying the day / night cycle time seemed quite handy, but we do need to modify the code and upload it again every time we like to change the cycle time. Is there maybe an easier way? Yes there is ... we can change the cycle time 'on the fly' via a User Interface. There are different solutions, with hardware otr with software. We're going to try them both. In this video we'll do the first preparations, writing text and numbers to the PC screen via Serial.print(). Link to Fun with Arduino 08 User Interface Serial.print()
  11. Fun with Arduino 07 Day & Night Cycle, Multiple Light Groups, Random Times Our day / night module of the previous video works perfect, but it controls just one light group. On our layout we probably have multiple groups ... houses, street lights, a railway station or an industry area. In this video we're going to see how we can control multiple light groups in a day / night cycle, while of course they do not switch all at the same time and also while making it non predictable. Link to Fun with Arduino 07 Day & Night Cycle, Multiple Light Groups, Random Times
  12. Fun with Arduino 06 Automatic Day & Night Cycle with on/off Switch and LED In this 6th video we are going to create a fully automatic day / night sequence, witch a toggle switch and an indicator LED on our switch panel. The day & night times are going to be configurable in seconds, which means we need some math to go to milliseconds. Link to Fun with Arduino 06 Automatic Day & Night Cycle with on/off Switch
  13. Fun with Arduino 05 Connect More LEDs with Relay or FET Arduino outputs can only switch 20mA. If we want to control groups of multuple lights on our model railway layout, we will need some more 'oompf'. A 12V power supply will do great and we can use Relay or FET modules, controlled by the Arduino, to swicth the higher current / voltage. How to do this, how to wire this, is the subject of this video and article. Link to Fun with Arduino 05 Connect multiple LEDs with a Relay or a FET
  14. Fun with Arduino 04 Readable & Maintainable Code , #define, delay() The goals in this video are: To make our code better readable and easier to maintain. We imagine pin 8 operates 20 street lights on a model railway layout. They switch on when we press the button. To simulate a night cycle we want them to stay on for 3 minutes and then automatically switch off again. Link to Fun with Arduino 04 Readable & Maintainable Code , #define, delay()
  15. Fun with Arduino 03 Connect an External LED and resistor The third video is online. To control the on board LED is fun, but the real fun only starts when we can control external LEDs, like on a switch panel, or on a model railway layout. This video is about how to connect a LED and how to choose the value of the series resister we need to set the LED brightness. In the next video we are going to control the external LED and we will simulate a night cycle on a model layout. Link to Fun with Arduino 03 External LED and Resistor
  16. Fun with Arduin 02 Digital Input and Output The second video is online. The plan is to start writing our first code ( 4 lines ) The goal is to switch the on-board LED on when a push button is pressed. This way we come across commands like pinMode, digitalRead, digitalWrite and we even throw in an if-then-else. Link to the video.
  17. Hi 'Theakerr'. If you have any specific Arduino task to be resolved, with no answer yet as to how to do it, who knows if you'd post it here there might be readers who can offer a solution.
  18. Fun with Arduino - 01 - Getting Started in 6 Easy Steps. I bet almost everyone here at the forum has heard about the Arduino and how much fun and how useful it can be to model railroaders and to other hobbyists. Price is no issue at about 3,- £$€. But not every hobbyist has affinity with electronics or with software. To some the initial hurdle can be just too much, even while there may be an interest to get started with Arduno and to try things out. That is where the plan arose to do a series of articles and videos titled 'Fun with Arduino' ... aimed at anyone who is not an IT specialist (yet ). The first article with video is out: Getting Started in 6 Easy Steps. Link to the video.
  19. Digikeijs DR5000 03 Connect Phone / Tablet to WiFi and use the Z21 app Oops … for some reason Digikeijs DR5000 video 3 never got posted here … Altzheimer? Here it is yet. It’s about how to connect to WiFi and use the Z21 app on your phone or tablet. Link to the video.
  20. Digikeijs DR5000 04 Connect to a Network via a Router Video 04 on the Digikeijs DR5000 is out. It’s about how to connect to your home network via a router. The reason to do this is if your DR5000 is further than 5m away from your PC, the maximum length for a USB cable. Link to the video.
  21. @steveheat: I use Arduino's with self written code for all my DCC (servo / accessory) decoders and for S88 sensor feedback modules. These are 10% of the price of commercial units and they work just as well. All info can be found on my blog: rudysmodelrailway. For complete DIY packages with all the software and shipped at costprice + shipping, you could have a look at the ARCOMORA website. It is very well possible to use current sensing with a reverse loop.
  22. Digikeijs DR5000 Video 02: Control Properties and Settings Window This video is about the DR5000 Control Properties / Settings window and about the settings in the Drive- and Switch windows. One of the important settings is the number of speed steps we want the DR5000 to send to our loco’s. In most cases 28 steps is a good default value, which also works fine with most layout control software like e.g. Koploper, iTrain or Traincontroller. Unless maybe the majority of your loco’s is equipped with 14 step decoders, then of course 14 steps would be the obvious default. Once the default is set, then in the ‘Loco Speed Steps Table’ we only need to fill in the loco’s that differ from the default. Personally I always stay away from 128 speed steps … to my eyes it does not render a visibly better driving behavior, while it drastically increases (and maybe could clog?) data traffic on the communication lines and DCC. Link to the video
  23. Traincontroller 54: Stations. Traincontroller 9 has the option to work with Stations. A Station is a collection of blocks that we allocate to it. Once Stations are defined several new options are available. The video shows three: A local Spontaneous-Run: the train will never run further away than one block from the station. Autotrain-by-Drag-and-Drop now has Station Icons: a random train will leave from the Departure Station and will drive to a random lane in the Destination Station. The number of trains in the Station is available for use in a Variable. There is more that can be done, please refer to the chapter about Stations in the Traincontroller 9 User Manual. Link to the video. …
  24. Hi Frederick, Yeah, I can't say I don't like it. Maybe you too if you'd try again? It must be products I feel enthusiastic about though, or I couldn't do it.
×
×
  • Create New...