Jump to content
 

Fun with Arduino - how to get started, and more


RudyB
 Share

Recommended Posts

I would classify an Arduino and the various flavours as microprocessors or micro controllers. I wouldn’t class them as computers until they have an OS on them that allows them to be programmed natively, I.e. you don’t have to use something else to write the programme which you then upload into said device for it to perform the function which you have designed it for.

 

Actually much of the stuff used in DCC is slightly more ‘intelligent’ in that you can change what it does through changing parameters such as CVs, but in reality the DCC stuff is also just micro controllers which have several preprogrammed alternative scenarios built in that you choose by changing one of the parameters - but like using the IO pins :)

 

Whether they are separate from DCC or whether there is an overarching computing section in which DCC, computer Control, Arduino Programming, etc all have separate sections (my preference) is the subject of another debate.

Link to post
Share on other sites

  • RMweb Premium

I would classify an Arduino and the various flavours as microprocessors or micro controllers. I wouldn’t class them as computers until they have an OS on them that allows them to be programmed natively, I.e. you don’t have to use something else to write the programme which you then upload into said device for it to perform the function which you have designed it for.

 

Actually much of the stuff used in DCC is slightly more ‘intelligent’ in that you can change what it does through changing parameters such as CVs, but in reality the DCC stuff is also just micro controllers which have several preprogrammed alternative scenarios built in that you choose by changing one of the parameters - but like using the IO pins :)

 

Whether they are separate from DCC or whether there is an overarching computing section in which DCC, computer Control, Arduino Programming, etc all have separate sections (my preference) is the subject of another debate.

It's all "computing" in the general sense so maybe there should be a Forum heading for that?

 

What Rudy has demonstrated so far in his thread could be applied to a model railway but in no way is connected (as yet) with DCC.

I assume that will come later.

 

Keith

Link to post
Share on other sites

I must say I was pleased to see this topic started and have found the posted videos very interesting - so interesting that I may well have to spend some money. RudyB has done me a favour by showing his videos and I thank him for the clarity of the presentation, introducing me to some fascinating possibilities of which I was previously only dimly aware.

 

Frankly I can't see that it matters that much what we call this branch of electronics, whether we call the Arduino a computer or not or indeed exactly where the topic fits on the forum. 

 

Chaz

  • Like 2
Link to post
Share on other sites

I must say I was pleased to see this topic started and have found the posted videos very interesting - so interesting that I may well have to spend some money. RudyB has done me a favour by showing his videos and I thank him for the clarity of the presentation, introducing me to some fascinating possibilities of which I was previously only dimly aware.

 

Frankly I can't see that it matters that much what we call this branch of electronics, whether we call the Arduino a computer or not or indeed exactly where the topic fits on the forum. 

 

Chaz

 

Hi,

 

If this topic were located under electronics I would not have questioned its location. This is a forum that includes technical topics so do not all people need to be able to navigate it?.

 

If someone on a forum like this was to describe a locomotive on its own as a train would there not be confusion, if not forum discussion ?.  Words maybe don't matter but surely their relationship to other words does especially for the new entrant to a forum. Isn't there a lot of choice in railway modelling at present, perhaps more prototype information than ever before - would it not be a good idea to make navigation to topics as clear as possible?.

 

 

Regards

 

Nick 

Link to post
Share on other sites

Hi,

 

If this topic were located under electronics I would not have questioned its location. This is a forum that includes technical topics so do not all people need to be able to navigate it?.

 

If someone on a forum like this was to describe a locomotive on its own as a train would there not be confusion, if not forum discussion ?.  Words maybe don't matter but surely their relationship to other words does especially for the new entrant to a forum. Isn't there a lot of choice in railway modelling at present, perhaps more prototype information than ever before - would it not be a good idea to make navigation to topics as clear as possible?.

 

 

Regards

 

Nick 

 

 

Well Nick, you have a point, but I found this topic through the VNC link. Had I have been looking for Arduino topics (rather than a bit of casual browsing) a search on that keyword would have done the job - would it not?

 

As for forum discussion, yes of course there is room for everyone to express opinions. It's one of the strengths of a forum. However I am more interested in real content from which I can learn - less so in whether a topic would be better moved to a different area. 

 

Chaz

Link to post
Share on other sites

 

If this topic were located under electronics I would not have questioned its location. 

Then nobody would find it - maybe that's what you really want.

 

You have just started a pointless discussion that has sidetracked a series of helpful contributions by the OP.

 

...R

  • Like 1
  • Agree 1
Link to post
Share on other sites

Then nobody would find it - maybe that's what you really want.

 

You have just started a pointless discussion that has sidetracked a series of helpful contributions by the OP.

 

...R

 

 

...so now we just wait for the next of RudyB's excellent postings. 

 

Chaz

Link to post
Share on other sites

@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.

Edited by RudyB
Link to post
Share on other sites

Then nobody would find it - maybe that's what you really want.

 

You have just started a pointless discussion that has sidetracked a series of helpful contributions by the OP.

 

...R

 

Hi,

 

If its under a commonly agreed topic then couldn't anyone find it?. When I said under electronics I meant as a sub topic of electronics.

I hope the OP isn't put off posting. His contributions might reach an even wider audience if they were located under a commonly agreed topic.

 

 

Regards

 

Nick

Link to post
Share on other sites

  • RMweb Premium

@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.

Hi Rudy

Thanks for the update, I was wondering how far you would be going on the RMWeb thread.

 

I found plenty of tips in your previous TrainController series

 

Keep up the good work.

 

Cheers

 

Keith

Edited by melmerby
Link to post
Share on other sites

You seem to be the only person who disagrees with their present location, so I reckon they are already in a "commonly agreed topic"

 

...R

 

Hi,

 

Perhaps most people haven't found the topic so can't give an opinion.

 

I'm going to go back to my Arduino - where is it? - its near my computer.

 

 

Regards

 

Nick

Link to post
Share on other sites

You seem to be the only person who disagrees with their present location, so I reckon they are already in a "commonly agreed topic"

 

...R

 

I think you need to read all the posts in the various fora, not just the ones that agree with your isolated opinion ;)

Edited by WIMorrison
  • Like 1
Link to post
Share on other sites

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.


34932647jl.jpg
 

 

  • Like 2
Link to post
Share on other sites

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

 

...R

  • Informative/Useful 1
Link to post
Share on other sites

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


34986161sw.jpg

  • Like 2
Link to post
Share on other sites

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()


35016651zo.jpg

  • Like 2
Link to post
Share on other sites

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


35036320hc.jpg

  • Like 1
Link to post
Share on other sites

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


35064128sm.jpg

  • Like 1
Link to post
Share on other sites

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


35088670bd.jpg

  • Like 1
Link to post
Share on other sites

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()


35120672uf.jpg

  • Like 1
Link to post
Share on other sites

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()


35150263is.jpg

  • Like 2
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...