Arduino Tutorial 11: Understanding the Arduino Serial Port and Print Commands
Вставка
- Опубліковано 10 гру 2024
- You guys can help me out over at Patreon, and that will keep this high quality content coming:
/ paulmcwhorter
In this lesson we show you how to print data to the Serial Monitor using Arduino. We investigate Baud Rate settings and how to get information from the Arduino into your Serial Monitor. Enjoy!
You can get the kit I am using for this series at the following link:
amzn.to/2I7N4Ek
You can get more details on this lesson at our WEB site HERE:
toptechboy.com...
[Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. This means if you visit the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.]
#Arduino
4 years later and your series is still helping people. New Arduino user here. Yes I am the same with things being tidy and square😂😂 However, we differ in iced coffee vs iced bourbon 😂😂😅 With all seriousness, you have created by far the best series of videos on this topic. Thank you for all your time and effort.
HI boss im your new student and im here to say that, 5 years later, your series is still helping newbies like me understand arudino better! thank you very much sir!
what i like abt this guy is the cool manner in which he teaches. No useless learning but he focuses on understanding! Thanks Paul for being there beside us!🙂😇😇😇😇
agreed
Maybe an episode on how to make Paul’s Ice Coffee😄
🤣🤣🤣
Yesssssssss
string mess1=“Paul’s Ice Coffee”;
int waitT=500;
Void setup() {
Serial.begin(9600);
}
Void loop() {
Serial.print (mess1);
delay(waitT);
}
@@dannylu6230 You used variables instead of constants!
Paul: You have done well grasshopper. You will soon be ready to leave the monastery.
Coffe in ice...
Possibly the best you tube channel ever. Thankyou Paul for giving everyone the ability to turn their imagination into reality.
indeed
I am in depression, your videos helps me handle my conditions. You are a very good teacher. I love to learn new things. Thank for being there.
Check out my attributes of God videos on my Bible Boy channel . . . might help you feel better and understand purpose of life better
Paul is a national treasure I have never seen anyone that can make teaching so easy. I wish I had a teacher like him when I was in school. I have had some terrible experience because of poor teaching.
I love those parts where Mr. McWhorter inserted "misses" on working out the program, it strengthens good programming practices and showed mistakes I might myself make so I won't have to. The tutorials have indeed been very exciting and keeps on getting better. Thank you for these great contents Mr. McWhorter. I hope you could do more contents in related areas.
I have been going through all the lessons since I got my UNO, I'm really appreciating all of the info, Thanks
I watched you a few years back on your old version of this and was blown away at how good you are at teaching this. I had other things to do for a couple of years (built a recording studio/editing suite by my Mt. cabin in NC and started doing a weekly youtube live stream of old time Gospel Music) and now I'm back into having a bit of time for the arduino since my show is running smoothly now. So, I looked you up and lo and behold, a newer version of you teaching this. Love the electronic "theory" you are throwing in. So, I have been watching your play list on the arduino and have gotten to here rather quickly because it was more of a review for me. But from here on I'm learning. God gives us different gifts. Mine was music, but yours is teaching. If someone can't learn this with you as a teacher, they need to take up something else! Thank you for your efforts. You have been and are, a big help to me and I'm sure to many others. I'm thinking God is quite happy with what you have done with your gift!
Great comment! Send my love to Mt. Mitchell for me! It was my inspiration to move to western Maine. I do miss the western NC mountains though. They are a magical place. Thanks for sharing your story!
nice. best of luck for ahead.
In C++ I was able to print multiple variables at a time, I gave it a try with this ide, low and behold it worked!
example:
String myString=" + ";
int x=10;
int y=10;
int z;
z=x+y;
Serial.println(x+myString+y+" = "+z);
Code for this lesson:
int J=1;
int inDelay=1000;
int x=3;
int y=7;
int z;
String myString=" + ";
String circleA="the area of this circle is ";
float pi=3.14;
float r=2;
float area;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
z=x+y;
area=pi*r*r;
Serial.println(x+myString+y+" = "+z);
Serial.println(circleA+area);
delay(inDelay);
r=r+0.5;
}
"NO! NO!!" God i love this guy! You are a fantastic teacher!
Thats my favourite part haha
Using variables is not always better than using literals
@@m_t_t_ Maybe Paul covers it in later coding lessons, but I use the pre-processor for things such as pin numbers, min/max range values, etc.
#define bit0_LEDPin 2 // bit 0
#define bit0_Max 1 // 0-1
#define countDelay 200
pinMode( bit0_LEDPin, OUTPUT );
LightLED( bit0_LEDPin, bit0_Max );
delay( countDelay );
Great lesson again! Thank you so much, Paul. Used the print command to get something like this on serial monitor:
Voltage across 220 ohm resistor is 1.99
Voltage across 330 ohm resistor is 3.01
Code:
int readpin=A1;
int readVal;
float v1=0;
float v2=0;
int delayT=500;
String line1= "voltage across 220 ohm resistor is " ;
String line2= "voltage across 330 ohm resistor is " ;
void setup()
pinMode(readpin,INPUT);
Serial.begin(9600);
void loop()
readVal=analogRead(readpin);
v1=(5./1023.)*readVal;
v2= 5-v1;
Serial.print(line1);
Serial.println(v1);
Serial.print(line2);
Serial.println(v2);
delay(delayT);
Great work mate!
An amazing arduino course for beginners. You are a born teacher Paul. you are magician. you make boring staff so exciting.
I finished this video and immediately went on ahead to create a program that basically prints the answer of a calculation we know as " iterative solution", and all we have to do is insert the equation and starting value, and it prints the answer to each iteration. Thanks Mr. McWhorter.
3:31 awesomeness overload. Paul Mcwhorter is the best teacher to ever exist.
00:05 Learn how to print from Arduino
03:00 The program prints numbers and increments them
06:10 Printing and formatting text using serial monitor.
09:34 Printing strings in Arduino using different methods
12:47 Understanding the difference between variable names and values
16:05 Print a circle with radius and its corresponding area
19:22 A circle with a radius of 2 has an area of 12.56.
22:29 Learned about variables and their types
Crafted by Merlin AI.
Shukriya ❤
This is only lesson 11, but it feels like I have made so much progress already. Thank you Sir! Best wishes from Italy
Excellent!
i've watched a few of your old lessons to learn how to write a sketch for lights on my rc police car a few years ago, and was successful, but i didn't quite understand exactly what i was doing with the variables. watching these most excellent new lessons, i am completely grasping the idea behind them. you sir, are a true gift to the art of teaching.
Very dense learning in this one (#11). The hardest yet for me. Paused often to keep-up with you and re-runed the video at least 3 times to sink it in! Very satisfying to work on the Serial printer though and will try to keep practicing because it could be a very usefull tool. Thanks!
Excellent!
I get the feeling you may have been to a funeral or another sad occasion, i kept hearing semi condolences.......made me smile. Thanks again for another valuable lesson. Simon
Been in the EE game for decades but just now getting into Arduino with my kids. These videos are obviously aimed at electronic novices but have still been an incredibly useful resource for getting me up to speed with the Arduino overall concept, their range of boards, and the ins and outs of the ATmega328/P MCU which I hadn't come across much before I started looking at Arduino as a teaching tool for my kids.
I've been looking at beginner Arduino tutorials all over UA-cam for weeks and this series is, in my opinion, head and shoulders above anything else I've seen out there. This is professional grade teaching for free right here. It used to cost us old farts thousands in education fees to get access to this sort of well organised, easy to digest, information dense, content.
Hope you lucky bastards appreciate it.
Excellent job Paul.
*Sir your students are so lucky*
I am so thankful for those videos. I’m going to do a classtest about arduino. My teacher didn’t explain at all. Now I’m starting to understand it. Thank you very much Paul.
I am watching all 50 of your tutorials. I am a fluent C coder but everything that I know about Arduino comes from watching and listening to you. I want to master Arduino Uno.
Just getting to grips with the Arduino, for a home automation project, and found your you tube channel one of the best. Really easy to understand and love the fact that you give an introduction to the physical working of the various components. Very easy to follow and Excellent all around.
I feel like I been watching these episodes for hours.
Twenty minute videos, I'll rewind and keep studying until I get it..
Also will post some things in the comments for others after I finally understand.
I'm literally noting everything you write on a piece of paper and giving myself problems to solve therefore I truly understand whats happening rather than just jotting notes down. lol.
I'm 31, I feel like I'm back in school again. It's great. It's been ages since I've actually tested my brain to solve some of these problems.
I'm also drinking loads of coffee lmao. Just.. not iced. My ice maker is no longer with us lol.
I pause your video and just to say your are such a great teacher to me. I do not know only print and println command difference. You show the difference beautifully. Your every class has a twist and turn which really makes video interesting. It helps to learn easily where we set up us and edit our faults. Such a great teacher you are. Thank you very much.
Liking these tutorials 👍 so much that I am slightly disappointed when there is no homework assignment.... After this one, I did calculations and printed the diameter and circumference in addition to area.
You are the best teacher i have ever seen in the arduino programming. Love from Bangladesh!
Hi ! this is the first time I get an english lesson because I'm french, but I have to say that absolutely everything is cristal clear ! Thanks a lot for this because now I can play again with electronics and software programming like 40 years ago !!!
I just love it so much the extent at which you go to teach us 🤣 When you scream 'no, no!' when we use random numbers in the code is great! I feel like it really drove the point home (at least for me)
I've watched many arduino turorial and this is still my favv. Thankyou Sir for sharing ur knowledge. God bless u
Wow - I'm loving learning again! Paul explains things so well, wished you would have worked at my High School!
I noticed that writing the formula first before printing it kinda gives us a peace of mind.
Peace of mind that we know the formula is already executed...
then the thing only left to do is to print it.
On another note, it is logical to write the increment formula at the last line
so that when the code loops, the incrementing variable automatically has a new overwritten value.
Thank you Sir Paul!
Thank you so much. I just turned 13 and i know that i will be having it easier than most people in college because of you. ONLY because of you. you are amazing. and you are not even doing it for the money. Thank you. I hope you see this and it makes you happy.
Edit: I succesfully did the homework with help from your video about ohms, voltage and ressistance. I have now saved every equations you taught me. I am so greatfull. That is it from me. Peace out.
Paul - I just wanted to drop you a quick message to thank you for taking the time to make all of these videos. You’ve done (and are doing) a great job, which many of us appreciate. Thanks!!
yeah im acually learning somthing teaching stuff (besides book) unlike most stuff im really happy that im not board of doing learning stuf
Another great lesson. I work on the sketch during your lesson, then go back and add comments on every line of the sketch help remember the lesson.
excellent!! thank you!! keep on having your cold coffee. We can smell it from this end!
I’m so glad to see that good videos like these keep getting views years after they are posted.👍
I felt quite intimidated when my Arduino arrived in the mail and it just sat in a draw for a few weeks. Your videos have really given me confidence and I've begun to grow more comfortable with the Arduino's learning curve. Thanks again!
Great videos! Thanks for teaching in such an amazing way. Was I the only one who was disappointed about not getting a homework assignment in this tutorial?
Is it just me, or has this dude just jumped to level 100 since the last video?
I agree! I've lost me this time. I thought I may have missed a lesson, but I haven't
Yup, I was doing great until this lesson.
why is it so much harder
I actually can't believe I had to scroll down so far to find someone saying this. Even in the last video I was a bit lost. I was doing one or two tutorials a night until I got to the last video, and since then I was feeling too intimidated to do this one, and waited a week or two. Tonight I decided maybe it will all make sense in the next video, so I got out my Arduino and started lesson 11, only to find out it's even harder than 10, and it doesn't help lesson 10 make any more sense.
In the first 9 lessons, he explained everything very clearly, but now it seems he doesn't explain each thing and what it does so I feel like I'm just copying his code and not understanding what I'm actually writing. Quite disappointing, as everyone else here says that these are the most easy to follow lessons they have come across. Makes me wonder if it's worth continuing.
Glad to know it's not just me who thinks this though.
I’m with you all. I started off so well and then I really started to struggle when the binary came along.
Continuing on my journey through the new and improved arduino tutorials and adding to my "toolbox" every lesson.
Fantastic job Paul!
While going through the tutorial I didn't want to lose the previous examples so I continued with additional Serial.print and Serial.println lines of code. Took a bit of experimenting but found it possible to print subsequent lines by always ending the last line with a Serial.println command.
The serial monitor returns this;
number = 1
3 + 7 = 10
Circle with radius 0.00 inch(s) has an area of 0.00.
number = 2
3 + 7 = 10
Circle with radius 1.00 inch(s) has an area of 3.14.
number = 3
3 + 7 = 10
Circle with radius 2.00 inch(s) has an area of 12.56.
Awesome tutorials + chat gpt. I thought Im too old to learn any new complex things, but here i am already on video 11. Thanks to Mr. Mcwhorter for sharing knowledge with us.
As a retired electronics engineer, I enjoy your sessions.
Thank you so much, now I'm designing my senior design project and these tutorials are really helpful.
Watching right now, just another great video, thanks Mr. McWhorter!
I love your videos and they motivate me to challenge myself. I have a challenge for you using the millis function.
1. Create a program that will allow the LED to blink by controlling the high (or on) time and the low (or off) time separately using millis function only.
2. on time= 2000 and offtime =2000
3. make the program to do it over over again.
I am enjoying the series. I usually print the program shown on each lesson and add my own notes for better understanding and future use. Thank you for taking the time to make these lessons on UA-cam.
This was a tough one, Paul. Took me a few trys to "get it". Glad I perservered. My wife is laughing at me for being so proud of making LEDs blink and text scroll.
I hope all the peoples in the world just explaine the code like you.
Is there a section that addresses sound and voice programming and components needed. Just came across this channel, what a blessing this man is to our society.
This was an awesome learning video! I had to watch it several times for it all to sink in. Once applied to my Arduino programming, it was amazing to read out the commands on my laptop. Thank you Paul, you rock as a teacher!!
I am glad I am no the only one i felt thick as hell watching that lol
Another one under my belt. You forgetting the semicolons is helping me. Again, thanks! I've been shy of programing but I'm getting over it thanks to your courses.
Valeu!
Thanks! Really appreciate the support
Thank you very much Mr. Paul Mcworther! I learnt so much!
Man, I love it so much when you say NO NO NO, use variables!
i had to follow this through quite a few times but after a little playing around i finally got it. Thanks Paul
love from india , your are the best arduino teacher on youtube .
Best teacher of Arduino lecture
i've just seen tutorial 22's thumbnail on the recomendations and i'm so pumped to get from this to something so cool in so little time..
Thank you, Paul! After this video, I made a Fibonacci Series generator, and it works!
Thanks for teaching me to use print and println Paul! you could use num+=1 instead of num=num+1
Your lessons have been a Godsend; helping me feel I'm not wasting my time during this Covid lockdown here in the U.K. I'm learning a new set of skills. Thank you.
knowing how something works and why you do it is more valuable than just knowing how to do it
Hello, Paul, I did notice the lack of semicolons. You are training us well! Cheers!
Good tutorials, i like how al my middle school knowledge of electricity is being refreshed. Its been so long ago i didnt remember a lot of it. Thx for explaining everything in such great detail!
best arduino course on the internet right now. Thank you ❤❤
i really love your way to explain and to prepare us to encounter any kind of mistakes when we are writing the program, thanks a lot Teacher you are the Best best best
This video series is a Great way of teaching Arudino. Thanks Paul.
Glad you think so!
Professor, I greatly appreciate the course and its quality. I send you a cordial greeting from Mexico
great lesson. I was able to point out all your mistakes before you did and I was able to write the code before you did. I do understand this lesson.
Love to watch and listen to this over and over again 😊thanks a lot
Thank you Mr. Mcwhorter. I'm picking up what you're laying down :) great lesson!
Thank you for making your lectures so enjoyable, even after only Tutorial 11 I feel like I can write a table using Pythagorean Theorem, but not very quickly though.
Really enjoying this new series,,, keep it going and well done, very well explained.
Paul, along with all the others commenting below. Big thanks. Really enjoying learning this properly. I had been a bit scattered brained about it learning bits here and bits there. This is the real deal !!!!
Another video of yours that has helped me out with my elegoo 2560. Brilliant Work!
Really enjoying these lessons! Thanks for the education Paul!
Glad you like them!
You're keeping me up waaaaaay past my bedtime. LOL! Great job!
Thank you mr Paul, verry nice lessons, tnx from Belgium.
My dream of making my very own robot is almost becoming a reality! Luckily I started doing Arduino and found your golden channel! Plus you also do videos on other stuff such as programming and robotics which is cool!
Thank you very much. Enjoyed the lesson, also it is great that you keep us engaged and show common mistakes. Looking forward to the next lessons!
I love your lessons. I apologize for the 35 dislikes , from those that don't understand English.
Love the tutorials .You are what I have been looking for a long time.I am a teenager and one day i would love to become a robotics youtuber and you have all the tutorials i need .🤩
You can do it!
You are a great teacher Paul! Enjoy followin along with my elegoo.
once again kind ties the Python also what I'm learning all good things !!! great job
i love his tutorials
cant wait to finish this
Ah, now this is one thing I have been waiting for. A bit on how to format printing. It isnt too different from what I am used to, and it is the syntax that I need to learn. I remember pulling my hair out back in the old DOS days when we needed print forms using MS Basic. We always had lots and lots of formatting errors until they were all weeded out. ugh. Thanks again for another great video and I am looking forward to the next lesson
Yet again, another great tutorial!! I don't know if you have seen this before but at the beginning of the tutorial I was getting a duplicate for the first printed entry. It happened for the 1+1 print example as well as the first circle radius example. The serial monitor would print 1,1,2,3,4 and so on. Then for the radius example it would print 2.0,2.0,2.5,3.0,3.5 and so on. It isn't happening now with the same code. Just thought you might have an idea of how that could happen. Keep up the great content!!
Sir Paul this was another great video, I have a suggestion which is instead of using multiple print statements we can using string concatenation to include all the statements and the values in a single print statement.
I have pressed the red little bell icon😀..awesome videos..turning me into a complete engineering
I just want to say thank you sincerely for taking the time to teach us. In the future I'll send a Tesla your way ;)
Vroom, Vroom, I will be waiting. I prefer a red one.
@@paulmcwhorter kk
Great tutorial, thanks :-) Modifed the code to calculate the long side of a right angel triangle, works perfectly!
Thanx a lot for your explanation! It simple and easily to understand! Appreciate your lessons!!!
This one was fun, quite simple and enjoyable!
Superb..! I really enjoy while learning something new in every tutorial..!
One suggestion, if you are going to continue with this Arduino tutorial series, please put comments on the Arduino IDE to explain in short words what all the procedures you are using represent for example use // and explain what it is you are telling the arduino.