23 December 2014

Nativity scene light effects with Arduino - the code

And here is the code of my simple light effects. As shown in the previous post I used an Arduino-compatible board called "Pro Micro", compatible with "Leonardo". But any other variant will do.

 Nativity scene lights

 This code controls two LEDs used to animate a Nativity scene.
 A normal LED connected at lampPin goes off during the simulated day.
 A high power LED (use an appropriate driver out of sunPin) simulates
 daylight, including sunrise and sunset fading.

 The circuit:
 * 5mm LED attached lampPin through a 1k resistor and 5V
 * high powered LED driven with an IRF510-like out of sunPin. It
   connects to Vcc through a limiting resistor (do your math and
   take heat dissipation into account).

 Created 20 Dec 2014
 By Paolo Cravero IK1ZYW

 Based on the official Arduino example "Fading":

 This code is in the public domain.


int sunPin = 3;  
int lampPin = 9;

void setup()  { 
  pinMode(lampPin, OUTPUT);
  digitalWrite(lampPin, LOW);

void loop()  { 
  // fade in from min to max in increments of 1 point:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(sunPin, fadeValue);         
    // wait for 50 milliseconds to see the dimming effect
    // adjust to your taste
    // lampPin trigger is at 50
    if (fadeValue > 50) {    
      digitalWrite(lampPin, HIGH);

  // duration of the day, 20 seconds
  // fade out from max to min in increments of 1 point:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(sunPin, fadeValue);         
    // wait for 50 milliseconds to see the dimming effect    
    // adjust to your taste
    // lampPin trigger is at 50. Feel free to have hysteresis
    if (fadeValue < 50) {    
      digitalWrite(lampPin, LOW);

  // duration of the night, 20 seconds


Nativity scene light effects with Arduino

It's Xmas time again. At home we deployed our usual nativity scene that had been joined by a simple 3V lamp for the barn, a couple of years ago. I wanted something more lively for my daughters, as well as something that originated from my hobby interests.

The idea: build a day/night simulation and switch on/off the barn lamp accordingly. Simple enough with an Arduino-like board and few lines of code.

How to simulate the Sun light, dimmable with PWM? The most intense light emitter I could find at home is a 1W warm white LED mounted on the "star" heatsink.

Step 1. If I let little Sun_LED draw 150 mA it doesn't warm up (to the touch), so I don't need a bulky extra heatsink. But I need an interface out of the Arduino board, because it cannot supply that much current. A good old IRF510 does the job (without heatsink).

Step 2. The 3V incandescent lamp drains 120 mA! I am lazy, in a hurry, and I don't want to add extra components to deal with it: a white LED does the job with 1/20th of electrons.

Last but not least, the whole thing is powered with a variable voltage wall-wart adapter. Since the Sun_LED is tied to the main Vcc supply through a limiting resistor, I can control Sun_LED maximum brightness with a flip of a switch.

Code and video will follow.

Improvements. My daughter asked for a moving figure: we will try to buy one during after Xmas clearout, possibly that works with DC. "I myself" though of simulating not only the fading of sunlight, but the color excursion too. I will buy a power RGB LED and play with it during 2015.

21 December 2014

ESP8266 really works on 802.11n?

Now that I got acquainted with ESP8266 WiFi module peculiarities, I have been asked if it works on newest 802.11n wireless networks. According to the datasheet, the ESP8266 chip supports 802.11b/g/n standards.

So I am setting up to test it against an "n only" access point. I will report my findings, since my home AP only does b and g.

09 December 2014

My best DX on 23 cm so far

My usual DX on 23 cm is 136 km during the monthly activity contest. Last Sunday there was the 50th anniversary of the Vecchiacchi V/U/SHF contest and I wanted to pay my tribute to the event.

All I could do was to spend the last contest hour on the air on 23 cm SSB. I was logged to the on4kst chat and got a request from a station 368 km away.

My 23 cm setup consists of a transverter with about 15 W out, 5 metres of SAT-TV coax and a 23 cm Yagi on the balcony, with "hand-rotor". The DX station was checking aircraft positions so that we could attempt an Aircraft Scatter QSO. At the first try my antenna was beaming too North. Then I adjusted it to what should have been the right direction and ... BINGO! The QSO was completed. We used three airplanes, that made a very long opening on our path.

Luckily I guessed how much off-frequency my transverter is!!

It is amazing how well AS works. Much similar to MS, but much more predictable!