# Any interest in an arduino class?



## Shdwdrgn

I see several threads around here where a problem could be solved fairly easily by a cheap microcomputer and easy-to-find parts, but a lot of people seem to naturally gravitate towards the "computers are hard" beliefs. Realistically I think configuring the software on your desktop to program these little systems is the hardest part, and there are so many example of code available for arduinos that you can practically cut&paste a working solution with only a very basic grasp of programming.

Over the weekend I was contemplating the idea of starting to write a "how-to" series of using arduino computers for train-related projects. I would start with the basics or working with soldered versus plug-in wiring and getting power from the tracks, move into installing the arduino programming software, then start building on the basics with extremely cheap examples of controllers for turnouts and crossing gates, then show how I am controlling the speed of a locomotive, and move on to communicating via WIFI.

So would there be much interest in this? Should I just start writing and see how many people follow along? Or is this the wrong crowd to push my new-fangled methods on?


----------



## Lemonhawk

I've been playing with the pro mini and I was looking at the relay panel I built about ten years ago and thinking I could replace most of the wiring with the arduino and some day I might. So I've been following your exploits with interest.


----------



## RH1

New here, but well on my way to getting my latest HO layout up and running - the main trackwork is done, and just finished soldering all of the track feeders this morning before I headed into work for the afternoon (100 solder joints later, my hand was cramping...). Running it all with old school DC and a pile of DPDT switches simply because I already have them in boxes from 12 years ago. Actually, the whole layout has cost me the price of one sheet of plywood, a bottle of wood glue, and some screws. Everything else was salvaged from my old layout (12 years ago) or was materials I found laying around the house..

That being said (and following along my idea of using what I already have), I've been thinking of seeing what I can do with a couple of Arduinos (and maybe a Raspberry Pi) that I have sitting in a tool box. I got the Arduinos a couple of years ago as a test project to build some simple audio recorders (they worked fine, but ended up going with something else).

Would love to see some ideas, sketches if you have them! Will be a while before I can actually get to trying them out, but always great to have new ideas. 


Rainer


----------



## DonR

I think your idea would find several takers if you can start out with
a full explanation what an Arduino is, how it could be used, what
gear would be needed to program it and in general a 'get acquainted'
beginning for non digital people who could then realize how they
could use it.

Then, proceed for the better informed.

Don


----------



## teledoc

I would suggest just start writing, and those that are interested will definitely start asking questions. I would follow along myself, to see what different capabilities the arduino could be used for, and get a better grasp of using it in model railroading. Go for it.


----------



## RT_Coker

Shdwdrgn,
You will probably find "Introducing DCC++ ---a complete open-source DCC station and interface" interesting: http://www.trainboard.com/highball/...-open-source-dcc-station-and-interface.84800/
Bob


----------



## 2869ral

Im very interested!


----------



## Shdwdrgn

Great to see the interest in this, thanks everyone! I started writing up some notes last night about how I want to proceed with the discussion. It's obvious right off that for anyone to get started in arduinos, they will need to have some basic initial knowledge... things like DC voltages, understanding that you need a complete circuit for electricity to flow, and probably some understanding of components like diodes and resistors.

I'm trying to keep everything straightforward and provide options. For example, not everyone can (or should) solder on computer boards, but there are boards available with header pins already soldered on, and you can get sets of wires that have plug-in connectors on each end. This and a small breadboard should be enough to get most people started.

This is a really busy week for me at work, but I'll try to get the first article ready to go and possibly posted by this weekend. Once we move past the basics, I'm planning on showing examples for working with both an arduino and an ATtiny85, and explain why I would choose one or the other for each example.

And thanks again for the interest, I'm getting excited about this!


----------



## 2869ral

Im excited as well, and i have plenty of Ibuprofin on hand for when my head gets to spinnin. lol


----------



## Shdwdrgn

Haha save me some as well! I'm not much of a writer, so this will be a real challenge.


----------



## bluenavigator

I'm in as well!


----------



## Shdwdrgn

All right, so here's the outline I've been working on for how to proceed. I'd like to try and hit one section every week, then see where the questions lead and if I need to add any intermediary sections to fill in where I may have taken too large a leap. I'm still trying to decide on the order of sections 2 and 3, it may make more sense to reverse them?

1) The basics
- what can computers do for you?
- anti-static
- soldering vs headers (what is your skill level)

2) software setup
- install arduino IDE
- quick explanation of compiling and uploading code
- install support for ATtiny

3) Power to the world
- Diode bridges
- LM7805
- DC-DC buck converters
- Getting power from the rails

4) Lets do something
- Intro to an arduino
- basic I/O
- first code: control LED with switch

5) ATtiny and the turnout
- Intro to an ATtiny
- basic motor control
- L293D
- stepper motors
- control the direction, speed, and duration of stepper motor

6) ATtiny at the crossing
- A4988 to control crossing gates
- add LED flashing lights
- show non-blocking delays

7) Arduino the engineer
- control motor speed/direction with L293D
- use smooth transitions between speeds
- introduce constants for min/max speed

8) Talk to the world
- Intro to the ESP8266
- install support in IDE
- control loco from the web
(will need to set up a web interface for everyone to connect to)

9) More power in a teensy package
- introduction to the Teensy
- explain why cpu speed and flash space are important
- discuss multiple platforms available to use


----------



## 2869ral

I just bought some of these stepper motors, i hope they will work.


----------



## 2869ral

Here are the measurements


----------



## gregc

Shdwdrgn said:


> All right, so here's the outline I've been working on for how to proceed. I'd like to try and hit one section every week, then see where the questions lead and if I need to add any intermediary sections to fill in where I may have taken too large a leap. I'm still trying to decide on the order of sections 2 and 3, it may make more sense to reverse them?


The problem with any programming class for people who have never programmed before is the need to both learn to program as well as the syntax of the language and learning how to run the program.

based on all the sections related to electronics, are you assuming those interested know how to program.

If most are interested in learning to program using an Arduino, I think the first section should show people how to load and run a program that flashes an LED. Think of the "hello world" program.


----------



## Shdwdrgn

@2869ral -- wow those are some nice looking steppers! Much better quality than what I've found in floppy drives. Also that fine thread screw means you will have very precise control over the position. Great find!

@gregc -- I'm assuming a lot of people here do NOT have any programming experience, so I am trying to focus on simple examples of making things happen plus trying to show how you can find examples on the web to handle a lot of tasks. Programming comes from experience, and the best way to get that experience is with some hands-on time using code that is provided and a good description of what exactly the code is supposed to be doing. Some people will understand the code better, some will understand the electronics better, but as a community working together we can come up with working solutions for every problem.

Item #4 is basically my 'hello world' program, but including input from a switch. Everything we do here will be using both input and output, so we want to get a handle on those concepts early.

Maybe I'll proceed with 1, 2, 4, 3, so we get to an actual example fairly early, but in #5 I intend to show a stand-alone unit that runs from track power, so #3 needs to come before #5.


----------



## gunrunnerjohn

Always useful to include an actual link or at least the eBay item number. Here they are for 70 cents, free shipping. 252246110151


----------



## gregc

Shdwdrgn said:


> Item #4 is basically my 'hello world' program, but including input from a switch. Everything we do here will be using both input and output, so we want to get a handle on those concepts early.


i think there are quite a few coding concepts that can be discussed before there is a need to enhance the electronics.

simply getting a program the sets some output to known states is quite a challenge for a beginner.

there are several ways to implement a loop or use timers to flash an LED

having code that can flash multiple LEDs at different rates is another step

finally handling input or inputs to control whether one or more LEDs is on/off, or flashing or flashing at different rates is another step.

A crossing gate with flashing LEDs combines several coding coding concepts. The input triggers the flashing of the LEDs and the closing of the gate. The closing of the gate could be controlled by a servo using a single PWM output. But that signal slowly transitions from an open state to a closed state. When the detector input goes away, there may be some short period of time during which the gate remains closed. Then there is the transition during which the gate is opened and when fully opened the LEDs stops flashing.

the crossing gate is a relatively interesting program that involves multiple timing loops and transitions while constantly monitoring some input. There are 5 states and a different behavior in each state. And there's more than one way to code this.


----------



## 2869ral

gunrunnerjohn said:


> Always useful to include an actual link or at least the eBay item number. Here they are for 70 cents, free shipping. 252246110151


I just clicked on the ones that say .70 cents, but they are still totaling .99 cents. Not sure why. But i found a set of 5 for $4.52 free shipping.


----------



## Shdwdrgn

@john, that's a great link, I just ordered 10 of them because with the framework they look really useful!

@2869ral, check your conversion rates. The 0.99 price is for the Chinese value, when you go to check out from payal you will see a conversion rate. The total on my order for 10 pieces was $7.12 US.

@gregc, absolutely to everything you said. There are a lot of concepts to cover, and I know there will be a lot of questions to answer along the way. Depending on how it goes, some of the articles may have a 2-week spread due to questions. I will try to keep things as straightforward as possible, but as with anything of this nature and audience, some people are going to be sleeping at the pace while others are going to be completely lost. I'll do my best to make sure everyone is up to speed before proceeding to the next article.


----------



## gunrunnerjohn

2869ral said:


> I just clicked on the ones that say .70 cents, but they are still totaling .99 cents. Not sure why. But i found a set of 5 for $4.52 free shipping.


Look again.

Price:C $0.99
Approximately US $0.70


----------



## 2869ral

gunrunnerjohn said:


> Look again.
> 
> Price:C $0.99
> Approximately US $0.70


Yes i seen that, i didnt commit to buy maybe that would show me the adjusted total.


----------



## 2869ral

Yep i bought the last 3, it adjusted my total when i committed to buy.


----------



## gunrunnerjohn

There you go.


----------



## bluenavigator

These steppers will work fine with Arduino. They only use 166 mA, which is good without needing the stepper module.


----------



## 2869ral

I also found these PT modules, if you haven't seen my post in the home made crossing thread. I soldered 4 photo resistors together in series to accommodate 2 mains and they work great. They activate a relay for controlling another circuit.


----------



## 2869ral

2869ral said:


> Yep i bought the last 3, it adjusted my total when i committed to buy.


Well my total for 3 was $2.14, i just checked my paypal transaction and $2.97 is pending.


----------



## Shdwdrgn

If these stepper motors actually work, anything under a buck a piece is a steal.


----------



## ogaugenut

Count me in as someone very interested in this. I will be following with interest. Which model of Arduino should I buy to get started on this?

Thanks
Bill


----------



## Shdwdrgn

If I do my job right in explaining things, you should be able to follow along with just about any model. However I think the two boards I will be focusing on are the arduino 3.3v pro-micro and a variation of the attiny85. The boards I use both have USB ports built on, which not only makes it very easy to program them, but it also provides direct power without adding any more hardware. The pro micro has the available inputs to follow along with every example I show (note you will want the 3.3v version if you want to also work with wifi later on), but I will introduce the attiny85 for a couple of projects due to its lower cost.

I will try to cover a list of materials in the first article.


----------



## ogaugenut

Wow. I started google searching and reading about Arduino boards. What a bewildering array of choices. Very confusing. Guess I will slow down and wait to read your first instalment. 

Thanks
Bill


----------



## fcwilt

ogaugenut said:


> Wow. I started google searching and reading about Arduino boards. What a bewildering array of choices. Very confusing. Guess I will slow down and wait to read your first instalment.
> 
> Thanks
> Bill


There have been many different boards created over time. Some have proved popular and remain, some have not lived up to expectations and are gone.

It can be confusing to be sure.

Here is a chart that may help. 

https://www.arduino.cc/en/Main/Products


I currently find myself using the UNO, the MEGA and the PRO MINI for most projects.


----------



## fcwilt

Shdwdrgn said:


> However I think the two boards I will be focusing on are the arduino 3.3v pro-micro and a variation of the attiny85.


Not the boards I would chose for educational purposes.


----------



## ogaugenut

Based on Fcwilt's input I looked further. I was looking at the mega, as I typically want to buy more capacity than I initially need. So now I see there are Arduino brand boards and compatible boards. The Mega is about $38 at Amazon, but there are several brands of Arduino compatible boards under $20. Is this a case where you want the name brand or are the compatible boards ok?

Thanks
Bill


----------



## gunrunnerjohn

2869ral said:


> Well my total for 3 was $2.14, i just checked my paypal transaction and $2.97 is pending.


Look again. I bought five of them.


----------



## fcwilt

ogaugenut said:


> Based on Fcwilt's input I looked further. I was looking at the mega, as I typically want to buy more capacity than I initially need. So now I see there are Arduino brand boards and compatible boards. The Mega is about $38 at Amazon, but there are several brands of Arduino compatible boards under $20. Is this a case where you want the name brand or are the compatible boards ok?
> 
> Thanks
> Bill


I would have to rely on the customer ratings. 

Mostly I have stuck with Arduino brand products as well as products from SparkFun and Adafruit. But I have purchased a few things from other sources and so far have had no issues. 

Arduino makes it fairly easy for 3rd parties to produce boards that are basically identical to the Arduino boards.


----------



## Shdwdrgn

@ogaugenut -- compatibles are just as useful as the official arduino boards. In fact, I buy Chinese knock-offs because they are cheap. And I will be showing that you don't even need to stick with the same microprocessors. One board I really like is the ATtiny85 with a USB port. I pick these up for under $2 each. The board is only 3/4 x 1 inch, and you program it the same way as any arduino. It only has 5 I/O ports on it, but if you're just doing crossing gates you don't need much!

So obviously there's a HUGE interest in using microcomputers around here! I'm trying to reorganize my outline to break things into smaller sections, and I'll post the introduction to the class as soon as I have time to write it up.


----------



## bluenavigator

Good boards to start with are UNO and MEGA. They are actually same but MEGA has more I/O connections to use. Once one understand how it works, then pick which board that is suitable for the project.


----------



## fcwilt

For those of you starting from nothing you might want to consider something like:

https://www.adafruit.com/products/170

https://www.adafruit.com/products/68

These will give you everything you need to get started with enough parts to do a number of basic projects for learning purposes.


----------



## bluenavigator

Couldn't agree more! They are nice starter kits.

There are some good starter kits on the eBay as well. Just lot of them are actual Arduino clones. They still work fine. I have two UNO and one is actual fake Arduino. They both still work the same as I tested them.


----------



## Lemonhawk

*Arduino set up*

Here is a picture of my Arduino set up. On the left side of the test board is a 5v and 3.3v regulated Power supply ( any 9-15 v wall wart powers it), there's a ultrasonic range finder plugged in the middle and the Pro mini is board on the right. A 2 line by 16 character LCD screen displays what ever (in this test I show the sonar range). The cable that goes between the pro mini and the USB port on my computer is on the right. The regulated PS and the proto board with wires I think was around 10$, from China. They are used there to teach electronics to the Chinese, so there is a vast market just in China for them. The Arduino Pro Mini was around $2 and the sonar module around $3. the LCD with the serial board was $5 I think. Just when I though electronics tinkering was dead all this shows up! GRJ I still can't figure out how make the picture show up instead of just a link -- just can't find the right button!


----------



## 2869ral

gunrunnerjohn said:


> Look again. I bought five of them.
> 
> View attachment 132769


I looked again, they charged me 0.99 each. Not a big deal.


----------



## gunrunnerjohn

You got ripped.


----------



## 2869ral

gunrunnerjohn said:


> You got ripped.


Yes i did! lol


----------



## Shdwdrgn

I agree, those are some great starter kits! I hadn't seen them before, thanks for sharing the links.

Things are finally starting to slow down at work, maybe I'll be able to stabilize my head long enough to write a few lines for the first article. I've collected some links for breadboards (looks like the same one as in the $85 kit above), pre-made jumper wire packs, and other parts. I figure if anyone is comfortable with soldering, they can get one of the small clones off ebay and solder the header pins on, otherwise one of these Uno boards is perfect and will provide plug-in support with the jumper wires. I actually ordered a pack of male-female jumpers and one of those breadboards for myself (my breadboards are all about twice that size or more).


----------



## 2869ral

I just ordered my starter kit from ebay, i should have it in a week or so.


----------



## Shdwdrgn

All right, it's obvious I need to stop worrying so much about my writing style, and just start getting the information out there. So, with my apologies if I lose anyone right off the bat (and please ask questions, I do a lot better at answering specifics instead of writing about a broad topic!), I will be posting the first article shortly...


----------



## 2869ral

Well, i just bought some more electronics from a Chinese seller that uses the currency exchange rate. Again i have been over charged. My total in US currency should have been $18.02 and my total was actually $24.65! I looked into it deeper and found that i have been being charged Canadian currency rate. I live in Arizona USA! I hope they fix this issue, i dont want to cancel my order.


----------



## Shdwdrgn

That sounds more like a problem with ebay/paypal rather than the seller. definitely push them on getting it fixed.


----------



## gunrunnerjohn

That's never happened to me, and I buy a ton of stuff from the Far East.


----------



## 2869ral

I have bought a fair amount myself, this is the second time it has happened. It must have something to do with my zip code? Not sure.


----------



## gunrunnerjohn

Maybe they think you won't notice.


----------



## Shdwdrgn

We were speaking much earlier in this thread about miniature stepper motors and the uses for them. While digging around, I came across these even smaller versions... Just arrived today, and I measure the body at 4mm diameter by 4.5mm long, without a 5mm throw for the carrier on the threaded shaft. I don't have any specific plans, but couldn't pass up something so tiny. One thought that occurred to me was working semaphore signals, although I think you'd still have to put the motors underneath the board (the 4mm body would require a scale 15" wide pole in HO). I dunno, I'll find something to add motion to that stands out in the open.


----------



## rva1945

Hi, I am interested in this topic.

In fact, I wrote a code that controls my train in a very simple way. By detecting IR sensors, I know the train is arriving to the station so the Arduino decreases its speed to a full stop; after a while, it accelerates again. The minimum and top speeds can be set, as long as the aceleration rate and stop times. Plus it can be controlled in manual mode.

This is a VERY SIMPLE APPROACH, I know that a full DCC control can be made, though I still need to know about it.

Here you can see it in operation, so far I built a signals gantry to hid the IR sensor, the pedestrian bridge is finished though paitnting is pending and still its IR sensor is not installed:

https://picasaweb.google.com/105403795492677221295/6251731456643778433

The controller at work:






Regards,
Robert


----------



## Shdwdrgn

Check the "introduction to arduino" threads I've posted since this one, I think there are three of them so far. Interest seemed to wane after the last one, I'm guessing because it's summertime now (?), plus I'm busy with my own outdoor projects right now. I will pick back up again with the series once I have free time.

I built my arduino controller with a wifi chip and can run the loco from a web interface, however I have some new hardware on hand -- much smaller and more powerful -- but I haven't had time to even hook it up. I also just received some bags of IR LEDs that I want to try and use for simple collision avoidance. If I didn't have to waste so much time sleeping, I could get a lot more done!


----------



## crusader27529

*Arduino block detection*

Check out MY thread on trainboard.....it has video.

The videos at the end are better than the early ones, but still not great.

Everything is Arduino based, and public domain....

http://www.trainboard.com/highball/index.php?threads/different-way-to-do-detection.91951/


----------



## rva1945

Great, lots o of info there. I'll see it later, thanks!


----------

