Fun with Arduino - a Series of Introductory Videos

A series of tutorial videos for those who wish to learn more.
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Fun with Arduino 09 Variables byte int long unsigned

#21

Post by RudyB »

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


Image
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Fun with Arduino 10 Show Cycle Status and Time with Serial.print

#22

Post by RudyB »

Now that we have our code working, by using the correct data type or by typecasting, we can continue the work on our User interface. The goal in this video is to display the status of our day / night cycle on screen ... is it switched on or off, is it day or night, and what is the currently used day / night time. All this will be dynamically updated.

Fun with Arduino 10 Show Cycle Status and Time with Serial.print


Image
User avatar
Brian
Posts: 2171
Joined: Thu Oct 04, 2018 3:49 pm
Location: SE Kent
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#23

Post by Brian »

Says the video is unavailable?
Image << Click the Icon to go to my website
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#24

Post by RudyB »

Strange, it does not do that here with me ...
User avatar
RogerB
Posts: 1355
Joined: Thu Oct 04, 2018 9:17 pm
Location: Dorset
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#25

Post by RogerB »

Yup, same here. When you go to play it you get the "unavailable" message. It is fine if you go directly to YT though. R-
Young at heart. Slightly older in other parts.
User avatar
Brian
Posts: 2171
Joined: Thu Oct 04, 2018 3:49 pm
Location: SE Kent
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#26

Post by Brian »

Its OK now but this is what was displayed..

Image
Image << Click the Icon to go to my website
User avatar
RogerB
Posts: 1355
Joined: Thu Oct 04, 2018 9:17 pm
Location: Dorset
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#27

Post by RogerB »

I reckon Rudy jumped in quick and fixed it. All working now. R-
Young at heart. Slightly older in other parts.
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Fun with Arduino 11 Keyboard Input via Serial Read and ParseInt

#28

Post by RudyB »

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


Image
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Fun with Arduino 12 Analog Input, analogRead(), Change Range, map()

#29

Post by RudyB »

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


Image
User avatar
RudyB
Posts: 100
Joined: Fri Jan 04, 2019 2:26 pm
Location: Netherlands
Contact:

Fun with Arduino 13 Timer with millis(), no delay(), Multitasking

#30

Post by RudyB »

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


Image
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests