Last Updated: 27/11/2024

Welcome to Digital Town

 

Welcome to Digital Town. This site was started to help teach some youngsters how to program Arduinos and acted as a resource to some YouTube videos I had created.

Since then the site has grown as more videos and content has been added and is slowly being restructured to deal with the extra volume of content.

The site is now in 5 sections.

Home has a list of the latest content added.

Arduino/C++ Lessons are various tutorials on learning how to use and program using the Arduino IDE and is aimed at beginners.

Components is about how to use an individual component with some sample code to help you use them.

Projects focuses more around putting multiple components together as well as looking at the issues around building projects. The Model Railway projects are included in this page.

Reviews & Links
is just a link to items or websites I have found useful

I do try to add content as often as possible but this is a hobby so be patient.

Latest Updates

Latest LCD Touch screen controller for use with DCC-EX or NCE Cab Bus via nowRail

nowRail resource page

nowRail loco controller

nowRail 1.1.0 has now been released and includes the ability to have slow motion servos.

nowRail resource page

nowRail PCA9685 servos

8 - Project design, choosing sensors for railway speedometer project

In this lesson I will go through the steps and considerations when choosing sensors for a project, in this case a speedometer for a model railway.
The project will use the LCD screen from lesson 17, a debounced button from Lesson 5 and the IR sensors from Lesson 7.

Download the code for Lesson 18

Click image for larger version
Lesson 18 Railway speedometer

1602A I2C LCD Screen with Arduino UNO

Using the 1602A I2C LCD screen with the Arduino UNO including how to
deal with string padding to get a better display.

1602A I2C LCD Screen

Download the code for Lesson 17

Click image for larger version1602A I2C LCD Screen with Arduino UNO Circuit diagram

1602A I2C LCD Screen

DY-HV8F, DY-HV20T, DY-SV8F and DY-SV5W integrating buttons and leds

DY-HV8F, DY-HV20T, DY-SV8F and DY-SV5W MP3 Players with Arduino UNO, Mega 2560 and ESP32.

WARNING: If using with 5v UNO or Mega 2560 use a voltage divider as shown in the ciruit diagram, this can be omitted for 3.3v boards such as the ESP32

DY-HV8F, DY-HV20T, DY-SV8F and DY-SV5W boards have 3.3v logic pins.

The boards give 4 Ohm/20W or 8 Ohm/10W sound output.


This project shows how to play a background set of tracks triggered by a button while using a 2nd button to interrupt and play a single track. The project also shows how to integrate a flashing LED into the code as an example of adding lighting sanimations to go with the sound.

This can be used as a basis for a lot of Model railway sound projects.

As my project is for few background sounds for a model railway the 8mb storage was just about enough.

Click Image for larger Version

DY-HV8F DY-HV20T DY-SV5W DY-SV8F integrating buttons and LED's Arduino UNO Mega 2560 ESP32

Click to download sketches.


Click to download Datasheet (Uses same system as DY-SV5W)

IMPORTANT: DIP switch Positions

1 OFF
2 OFF
3 ON

DY-HV20T DY-HV8F

JQ8900 MP3 Player Arduino ESP32

DY-HV8F and DY-HV20T MP3 Player with Arduino UNO, Mega 2560 and ESP32.

WARNING: If using with 5v UNO or Mega 2560 use a voltage divider in the same way as with the JQ8900

The DY-HV8F and DY-HV20T boards have 3.3v pins.

The boards give 4 Ohm/20W or 8 Ohm/10W sound output.

WARNING: This board is a 3.3v IO pins so for 5v boards such as the Arduino UNO/Mega 2560 you will require a voltage divider.

Ideal for short project sounds including voice commands.
Also ideal for model railway sounds.

The main difference between the boards is that the DY-HV8F has a built in 8mb USB storage system while the DY-HV20T allows SD cards up to 32GB to be used to store tracks so is better if you want to run lots of larger tracks.

As my project is for few background sounds for a model railway the 8mb storage was just about enough.

Click Image for larger Version

DY-HV8F DY-HV20T ESP32 circuit UNO Mega 2560

Click to download sketches.

An extra sketch has been added with improved random play time as well as a bug fix on sketch 2 line 131


Click to download Datasheet (Uses same system as DY-SV5W)

IMPORTANT: DIP switch Positions

1 OFF
2 OFF
3 ON

DY-HV20T DY-HV8F

Lesson 16 - Arduino Multi Mode Button

In this lesson a single button will be used to change the mode in the Arduino sketch allowing the Arduino to change the LED pattern depending on the mode.

The sketch shows how to combine the a debounced button with millis() being used to control the LED pattern timings.

Download the code for Lesson 16

Click image for larger version
Lesson 16 Multi mode button circuit

Arduino C++ Lesson 5B, Arduino UNO with toggle switches

This is an extra lesson that has been added to show how to control items with toggle switches with the Arduino UNO, rather than the usually push to contact switches that come in most kits.

As always the code is non blocking (state machine) style code and in the example a pair of LED's are turned on and off although the code can be easily adated to control other items.

Download the code for Lesson 5b

Technical explanation of the different types of toggle switches

Click image for larger versionLesson 5B Circuit Diagram

JQ8900 MP3 player resources

JQ8900 MP3 Player Arduino ESP32

Lesson 14 - External Interrupts part 1 - Rotary Encoder

How to set up and use External Interrupts with the Arduino UNO.

Part 2 deals with reading signals from devices and shows the basics of how to process the signals.

Download the code for Lesson 15

There is no circuit diagram for this lesson. However the following links may be useful.

Understanding FIFO buffers

DCC decoder circuit for Arduino UNO/ESP32

Lesson 12 - 28BYJ-48 ULN2003 Arduino UNO tutorial

Arduino UNO with ULN2003 and 28BYJ-48 Stepper motor tutorial using non blocking (State Machine) examples.


This is the first part of how to use a stepper motor in Arduino projects.
This lesson focuses on the basics of creating non blocking code.

Download the code for Lesson 12

Click image for larger version
Lesson 12 Circuit Diagram UNO and ULN2003 28BYJ-48 Stepper Motor

#99 ESP32mac address issues 08/06/2024

Lesson 1 Getting Started

In 2024 the ESP32 library was updated to version 3.0.0 (now at 3.0.1)

Although there are some obvious changes that break code such as the esp_now_register_recv_cb(OnDataRecv);

I discovered other issues that failed silently, setting a custom mac address is one of them.

This video shows how I set a custom mac address using ESP32 board library v3.0.1


Code Download New and old custom mac address code

#96 ESP-NOW Changes 03/06/2024

Lesson 1 Getting Started

In 2024 the ESP32 library was updated to version 3.0.0

This was much more than a bug fix and has changes that will break existing code. As I have discovered this includes ESP-NOW.
I first noticed this with the the line:

esp_now_register_recv_cb(OnDataRecv);

Producing the error:

Compilation error: invalid conversion from 'void (*)(const uint8_t*, const uint8_t*, int)' {aka 'void (*)(const unsigned char*, const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void (*)(const esp_now_recv_info*, const unsigned char*, int)'} [-fpermissive]

This video shows how I fixed thse issues using the version 3.0.0 library.

Code Download Example receive and transmit code from the video

#89 Arduino C++ Arduino Starter Course

Lesson 1 Getting Started

nowRail resource page

nowRail 1.0.1 MP3 player implementation

PCA9685 controlling multiple servos direction and speed with millis() 25/04/2024

PCA9685 controlling multiple servos direction and speed with millis()

ESP32 or Arduino DCC Accessory Decoder Circuit 03/04/2024

ESP32 or Arduino DCC Accessory Decoder Circuit

#70 ESP-NOW Broadcast Mode 06/03/2024

PCA9685 servos controlled by buttons

#69 Fail Safe project planning 21/02/2024

PCA9685 servos controlled by buttons

Windows 11 CH340 driver problems Solved 10/02/2024

DY-SV5W MP3 Player

Fixing a Slow IDE 10/02/2024

Fixing Slow Arduino IDE

DY-SV5W MP3 Player
ESP32 Dev Module and ESP8266 D1 mini
09/02/2024

DY-SV5W MP3 Player

#60 Arduino Connectors and Plugs 15/01/2024

PCA9685 servos controlled by buttons

#58 Model railway crossing with Servo Barriers, LED lighting and sound 08/01/2024

PCA9685 servos controlled by buttons

DFmini player & MP3-TF-16P v3.0 Player 21/12/2022

PCA9685

Arduino UNO and ESP32 controlling LED's with PCA9685 05/05/2022

PCA9685

Comments

Why is this site called Digital Town?
I owned the domain name so it seemed a waste not to use it.


If you have any projects you would like videos on please email the address in this image: and use Welcome to Digital Town as a reference.