Fun with Arduino - a Series of Introductory Videos

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

Fun with Arduino 09 Variables byte int long unsigned

#21

Post by RudyB » Sun Jan 27, 2019 10:10 am

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: 34
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 » Thu Jan 31, 2019 2:17 pm

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
Site Admin
Posts: 621
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 » Thu Jan 31, 2019 2:34 pm

Says the video is unavailable?
Image << Click the Icon to go to my website

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

Re: Fun with Arduino - a Series of Introductory Videos

#24

Post by RudyB » Thu Jan 31, 2019 2:37 pm

Strange, it does not do that here with me ...

User avatar
RogerB
Site Admin
Posts: 586
Joined: Thu Oct 04, 2018 9:17 pm
Location: Dorset
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#25

Post by RogerB » Thu Jan 31, 2019 2:39 pm

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-
Not sure if I have plenty of time on my hands - or I’ve simply forgotten to do something really important.

User avatar
Brian
Site Admin
Posts: 621
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 » Thu Jan 31, 2019 2:40 pm

Its OK now but this is what was displayed..

Image
Image << Click the Icon to go to my website

User avatar
RogerB
Site Admin
Posts: 586
Joined: Thu Oct 04, 2018 9:17 pm
Location: Dorset
Contact:

Re: Fun with Arduino - a Series of Introductory Videos

#27

Post by RogerB » Thu Jan 31, 2019 2:41 pm

I reckon Rudy jumped in quick and fixed it. All working now. R-
Not sure if I have plenty of time on my hands - or I’ve simply forgotten to do something really important.

User avatar
RudyB
Posts: 34
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 » Sun Feb 03, 2019 8:48 am

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: 34
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 » Thu Feb 07, 2019 10:42 am

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: 34
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 » Sun Feb 10, 2019 9:37 am

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 1 guest