Page 4 of 7
Fun with Arduino 14 Day Night Cycle with millis(), no Delay, Direct Feedback
Posted: Thu Feb 14, 2019 9:53 am
by RudyB
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
Fun with Arduino 15 LED Dimmer, analogWrite(), Pulse Width Modulation
Posted: Sun Feb 17, 2019 9:57 am
by RudyB
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
Fun with Arduino 16 LED Dimming with Fade, analogWrite(), millis()
Posted: Thu Feb 21, 2019 11:11 am
by RudyB
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()
Re: Fun with Arduino - a Series of Introductory Videos
Posted: Thu Feb 21, 2019 4:18 pm
by Brian
I like the effects Rudy
I hope you can introduce UK prototype crossing light operation and not just continental only?
UK is 3 to 5 seconds of yellow (Time of Yellow On depends of road speed and local conditions). Yellow Off then all red lights On on all poles for about 0.5 second before they begin to alternate flashing On/Off at around 0.75Hz to 1Hz rate.
All red Left hand side lights illuminate (flash On) together and then all Right side lamps and so on. Called a Wig-Wag sequence!!
Re: Fun with Arduino - a Series of Introductory Videos
Posted: Thu Feb 21, 2019 4:34 pm
by RudyB
We can do an additional video at the end of the project. With the specification and coding method we are going to use, State Transitions, it should not be too complicated to include the light sequence you described.
Fun with Arduino 17 Railway Crossing, State Transition Diagram, switch()
Posted: Mon Feb 25, 2019 9:44 am
by RudyB
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()
Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate
Posted: Thu Feb 28, 2019 9:59 am
by RudyB
In part 2 of the railway crossing project we are going to connect the servo motor that operates the gate and control it with the Arduino. With the example in the video, the gate beam is mounted directly on the servo. On a layout, the servo motor will probably be mounted under the board, and a metal rod pulls / pushes the beam up and down, through a hole. No matter how it is mounted ... we need to find the correct servo angles. We will write some code with which we can fine tune the servo to find the angles to be used in the code later on.
Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate
Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor
Posted: Thu Mar 07, 2019 10:38 am
by RudyB
There are several ways to do train detection, like sensing rail current, or a magnet under the train that triggers reed switches along the track, or with an optical sensor. The latter is used in this video, only because I had some TRCT5000's lying around and they were easy to setup for a demo. As soon as we have them working, we have some fun with them by making a train speed measurement device.
Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor
Fun with Arduino 20 Railway Crossing Putting it all Together
Posted: Sun Mar 10, 2019 11:24 am
by RudyB
We have seen the separate ingredients for a level crossing in the previous three videos: blinking LEDs, servo to operate the gate, sensors to detect the train ... it is time to put it all together now into one piece of software. We'll use the State Transition Diagram as our starting point and build up the software in 5 easy to follow steps.
Fun with Arduino 20 Railway Crossing Putting it all Together
Railway Crossing UK version
Fun with Arduino 22 Step Sequencer for LEDs with array[] and for() loop
Posted: Thu Mar 14, 2019 2:27 pm
by RudyB
A police car, fire fighter car or an ambulance with flashing lights can liven up any model railway laout. The challenge that we set ourselves is not to have to write different code any time we want another flashing pattern. We want to hav one and the same code and we only want to configure the number of stepd, number of LEDs and the flashing step sequence. Can we manage that? Yes of course we can ...
Fun with Arduino 22 Step Sequencer for LEDs