This semester we were to pick something for our digital learning project. I chose to focus on learning the microcontroller computer language Arduino. The point of this post is to highlight the things I learned, the tools that I used to learn them, and what I plan to do with this going forward.
In the beginning I already knew a little about Arduino because I had already used other microcontrollers. This meant that I already knew what a PIN was and that there were digital and analog pins, also that they can act as inputs or outputs. I also knew about the fundamentals that are common to all languages like conditional statements and different kinds of loops, like do while loops.
What I did not know was the syntax of this language, the specifics of how different components behaved when connected to the board, etc.
The Learning Goal:
The reason that I had chosen this project in the first place, other than the fact that I would get to play with electronics, was that I wanted to help a student learn how to program a robot for a competition in March. In order to do that I needed to know how to use this kind of hardware and software myself. I knew that learning it would be time intensive so by having it count towards my masters class I knew that I would be able to justify the time it would take. So I decided that I would declare my learning a success if I could by the end of the semester control the motors for the robot with some sort of sensor input. I knew that this would likely be challenging as even with the other microcontroller that I was familiar with I had not been able to do this. Also I knew that one of my previous students had found that to be extremely challenging and he was much better at programming than I was.
The Learning Plan:
I started by mapping out for myself the steps that I would need to be able to do if I was going to be able to make this work. In order to have the motor move I needed to be able to do the following:
Send a simple signal to a PIN
Control the signal sent to a PIN with a button.
Control multiple signals with multiple inputs.
Send a signal to the motor.
Send a signal to the motor controller to control the motor.
The Resources I used:
With this in mind I started to experiment. The major resources that I ended up using online were:
I will not recount each individual component that I learned to program here, or each unique function that I learned. Those are detailed clearly in my project posts. Instead what I will talk about here that I did not always talk about in my post is the pedagogy of learning on your own, online.
A Thought About Online Pedagogy:
In a traditional classroom you have someone who is an expert or at least knowledgeable helping to guide you. If they are any good at their job they are presenting you with challenges and content that is just above your current capability to make you stretch and grow towards it. If they give you something too difficult you become discouraged, too easy and you become passive and disengaged. A good teacher will keep you in that sweet spot and will keep increasing the challenges with your ability, until you are doing things that you never thought possible. Online learning does not have that. You need to challenge yourself enough to maintain your own interest, but you need to also pick something that is not impossible or else you will hit a wall and stop. I found this to be the greatest challenge to online learning, the idea of flying without a net. If I hit a wall there was not going to be anyone to help me, or so I thought.
It turns out that there are plenty of people online who are willing and capable of helping. The forums for the Arduino led me to many discussions that answered questions that I had. When I was hitting a wall with the tinyESC controller reaching out by email to the manufacturer turned out to be a good way to also get help. So the key to online learning is to not rely on only yourself. Find a like minded community and join the forums. Ask the questions and also answer questions for other people. In other words contribute to the community. As you do this at times you will get to play the role of teacher and this will help cement your own understanding. At other times you will be the one who receives instruction. Also post about your progress using appropriate hashtags to Twitter, you never know who will answer your questions.
Well, the project has been a lot of fun. I expect that over the Christmas break that I am likely going to outright build a working prototype to show to my students. I plan on posting that here. I do not expect this category on my blog to die out anytime soon. The Arduino bug has bit me hard and I plan on doing a lot more with this.
Thanks for journeying with me and be sure to stop by in the future.
One last thing:
While typing this up I found an ultrasonic sensor. This is a sensor that allows for you to measure distance using sound. (Kind of like a bat). I quickly hooked it up to the arduino, googled online for a tutorial and within 5 minutes had it up and running. Definitely not something that I would have been able to do at the beginning of the semester. I plan on incorporating this to the robot later. Come back in the next few weeks for a post on how it works. For now here is where I found the tutorial.
So my final project is a playful remix of The Legend of Zelda for NES. It is an unusual approach so I thought that I should unpack why I did it this way and what I was hoping to achieve with each scene. To begin with the idea for the project came to me as a result of wrestling with the realization that I would not have time to explore my learning this semester and still have time to talk about my personal learning project of learning to program the Arduino. I knew that we would have a final post to explain our personal learning project, but I wanted something of it to be in my presentation as well. I played around with ideas of somehow working the Arduino into the project, but try as I might I could not figure out a good way that would not distract from the summary of my learning. So I decided that I would instead use programming in a different way, and that I would use it to animate the story. I also wanted something that was original and uniquely me. That was when I decided that it would be neat to have my learning represented as a quest. I knew that creating an animation with all of the sprites (characters in a game are called sprites) would take way too long so I decided to use an existing game that had already been heavily remixed before and go with it. I also decided that even though I focused on learning Arduino this semester that I would program in Scratch, since it is a platform that I am very familiar with, and that I knew would be capable of this kind of project. So that is where the idea for the Zelda adaptation came from.
The first thing I did even before settling on the approach was to go through notes from each class and to look for themes and commonalities. After I found my major themes I went back and started to look at connections and did a concept map. A website that I discovered this semester for creating concept maps with my science students is sketchboard.io I was able to create the following concept map to help me organize my thoughts.
The green circles are my key ideas that most things connected to and branched out of. I decided then that if I did do my learning as a quest that I would need to find a way to visually represent my learning in each of these 8 main areas. I thought about what I had learned in each of these areas and I wrote my transcript of what I wanted to say. I recorded these using my cell phone and made sure that it came to less than 7 minutes. Then I started to think about how to animate each scene.
Part 1 and 2: The title card and the crawl.
The game of Zelda is a genre game, it follows a defined format and that includes providing the player with a backstory. In modern video games this would be done with a cut scene before the player could take over, but there was not enough memory available to the writers of an NES game to include an animation like that. Instead they did what Star Wars did and many other movies before that, they provided the player with a scrolling text that could fill them in. I decided to do the same. So in this part my goal was to explain a little about what the viewer could expect of the learning summary, and then with the crawl to provide a starting point for the beginning of my learning.
Part 3 and 4: The opening scene and the cave.
In part 3 you first get to see the game and the little character that represents me. During this part I explain about how my personal learning network (PLN) was analog and not digital and I symbolized this by having it as a life meter up in the corner of the screen. It is full health, but it is not digital and you will see this change to developing and growing a digital PLN as the game goes on. Also you will see that I have a SAMR level indicator at the top that shows that much of my technology in the classroom at this point is substitutionary. As for social media I have Twitter but hardly used it and that was represented with the spiderweb on the logo. Finally my two inventory boxes are shown as empty to begin the course with.
Then I enter into the cave. Here Dr. Couros tells me that I am going to need to learn about these different social media platforms and that I will need to be doing this a lot. My little character receives a phone to do social media on. I feel that I should point out that I did not receive a free phone in this class. Pizza yes, phone no. Also I was pretty pleased with my little 8-bit version of Alec Couros. So anyway, the point of this scene was to highlight the platforms that we used in the course. The other reason I did it was because the original game starts with Link (not Zelda) receiving his sword from a man in a cave to go on his quest with.
Part 5: The Twitter storm.
In this part I talk about how Twitter was originally intimidating to me and how Dr. Couros taught us about how to use hashtags and tools like tweetdeck to help make sense of everything. I show this by having my little character fire hashtags out of his phone at the twitter birds that are swarming me. As I do this they quit attacking me. You will also notice in this part that the spiderweb leaves the twitter logo and I also get followers below the twitter logo. This is to show the success that I found as I started to use twitter properly. You will also notice that with the addition of Twitter followers that my digital PLN life meter increases.
Part 6: Digital Citizenship and Social Activism.
In this next part I wanted to show the things that we learned from our guest lecturer Katia Hildebrandt about digital citizenship and social activism. I tried to show a digital world with another version of my character in a blue part of the screen surrounded by scenery made of binary. This I hoped would be the clue that it was the digital version of me. When I first enter the scene it is moving up and down independent of my character. As Katia speaks she tells us to take control of our digital identities, so I do and it starts to mirror my offline movement. I can only do this so much though as the digital me hits the wall and stays behind as I leave the screen. If I had had more time I would have had this character continue to follow me throughout the rest of the game, but I could not figure out a good way of doing that so I settled for it only being on this screen. Some of you might have noticed that the sprite I used for Katia is a modified version of Princess Zelda. The other thing that happens in this scene is that as I take control of my digital identity my social media platforms jump to include Google+, WordPress, and Chrome, I also give my digital PLN a half a heart to show growth.
As I leave this screen to the next I encounter a monster who is shouting at me. In the next three screens my purpose is to show the moral wrestling I have done with the idea of social media activism. I can see the logic behind the idea that your digital self should be representing those things that you believe in and that you should be speaking up about issues. My concern that I am still wrestling with is that so often what wins an argument is not the facts, but the relationship and the facts. You can tell someone they are wrong, but if they do not care about the relationship with you they will just ignore you, and in fact thanks to the backfire effect may even become more polarized to your position. Instead by talking with someone as if you are in a partnership in which you are both desiring to seek truth you are more likely to see a change in belief and behaviour. I am convinced that this happens better in private conversations than public ones. So for myself I think that my kind of social activism is to discuss the issue with the other party in a direct message. This has worked sometimes and not others. I show it working as a I change the mind of the troll.
Part 7 and 8 Open Education Resources.
In this scene I wanted to present the concept of open educational resources, OERs. These are not locked away behind some kind of paywall so I show them being open by having my character unlock the room that they are in. Also I want people to remember that it is important to contribute and not just to take. I do this by having my character build a lesson and leave it in the OER room. Then I leave the screen with a book in my inventory and I head to the next screen. In the cave on that screen is a man who wants to buy the OER off of me. I use this to explain the attribution rules that exist on many OERs. I end up giving the OER resource to the man in the cave after he agrees to the rules of attribution for the document.
Part 9 SAMR.
The SAMR principle of how to use technology in the classroom is something that I have fallen in love with. The idea that many people at first only use technology as a substitute for the analog way that they used to use it, until they become more familiar with the technology and then they begin to adapt their approach. But to truly use technology well we need to use technology to modify/change, with the best use of the technology being when it completely redefines how learning takes place in our classes. The analogy that we talked about in class was someone exploring the ocean. Substitution and adaptation are shallow water explorations. Modification and redefinition are deep ocean exploration. I tried to show this by having my character put on scuba gear and head out into the water. When he goes below the water the whole screen goes dark blue and he finds and amazing resource at the bottom of the ocean. I am not completely happy with this scene because I do not know if anyone else will get that visually from it. I hope they do but I could not animate it better in the time that I had. In the end I had to say good enough and include the scene as is. Oh yeah, the SAMR level moves over each level as I go deeper and deeper into the ocean in this scene.
Part 10 and 11 Fake news, 4 Moves, and Filter bubbles.
I really like the visual for this metaphor. My character comes onto the screen and sees two ponds with apples floating into each pond. He cannot tell which is good or bad so he uses the four moves and a habit and heads upstream to check out the source. He finds the one stream has an apple tree growing and dropping good fruit into the stream. The other stream has a monster who is reform balls of dung to look good before putting them in the stream. I think the metaphor for how fake news is produced and repackaged works well.
Then I head upstream even more and find that there is other good fruit that I am not being exposed to. This represents news that is true that I might not agree with, or that falls outside my areas of interest, etc. My character investigates and sees that there is a dam acting as a barrier, this is a metaphor for the filter bubble that we all live in.
Part 12 LaFOIP and THINK.
The final part that I present before the closing credits is about LAFOIP and the acronym T.H.I.N.K. I show this by having a monster be the legal department demanding that I take care of students properly online. I reassure the troll that I am teaching my students how to evaluate if something is true,helpful or honest, inspiring or illegal, necessary or kind before posting. I also explain the four key points of LAFOIP. My favourite part of this scene is when my character unlocks a record that he is done with and destroys it by burning it. Deleting things on the computer is not nearly as fun as burning it, oh well.
In the credits I thank everyone and I need to apologize for something here. I mispelled Katia’s name. I called her Katie. I am really sorry. I went based on memory and should have looked your name up. I plan on fixing it in the next week, so if you ever want to link to it in the future you will see your name spelled correctly, I just do not have time before the class it over to re-edit the two places in the video where the mistake are.
In the credits I thank everyone in the class and I also talk a little about the idea of remixing. I really, really, really enjoyed the Everything is a Remix website. I was engaged by it and inspired by it. I hope that my remix of the Legend of Zelda into the Learnings of Chris, was enjoyable for you.
For those of you who have not seen the entire summary video from my previous post, I have put it below.
Hi everyone. This post is about my summary of learning for my ECI 831 class. For those of you that might be reading this, who are not in the course with me this assignment was to be about all of the things that we had learned throughout the course. For myself I also wanted to allude to my learning project on computer programming a little without it becoming the focus of the video. For myself I decided to use my programming in the making of the video. I used the language Scratch that was created by MIT. I chose this language because everything that is done on this website is available to others for remixing. In this way I also felt that it fit with the idea of open education, which did get its start partially through the open education at education movement at MIT.
I will include a making of post in the next week, but for now here is the project. I hope you enjoy.
This week in ECI 831 we were tasked with finding a tool or an app that we had not regularly used for education, and reviewing it. The very next day I was talking with an amazing math teacher at my school and he said, “Check out this app Chris. You take a photo of your math question and it solves it.” I was impressed and then he said, “Just wait. You cannot even get around this by telling the students to show their work, because this app shows it step by step. I am going to have to change how I do assignments.” Then the bell rang and we both went to class. I knew immediately that I was going to have to review this app.
The app in question is Photomath, it is available for a free download for both Android and Iphone.
Does it work as claimed?
The first thing I wanted to do was test if the app worked as it claimed.
I tested this by printing off some math worksheets for multi-step equations. I also went to their website where they have a list of equation examples that you can print off. I also wanted to test it on hand written samples to see how good it was at picking up printing. Here is how it did on each of these hurdles.
Addition and subtraction = It had no problems at all and showed really detailed step by step instructions.
Multiplication and Division = It again had no problems and that includes testing it with fractions. The step by step instructions also could be expanded to include more detail if you needed.
Complex arithmetic operations = Worked perfectly again.
Factorization and Algebraic fractions = It worked through some complex problems without issue.
Linear equations with restrictions = Again no problem and it graphs the solutions as well.
Systems of linear equations = Here it does a couple of things. It solved the equation using multiple methods, it gave you options about which method you wanted to look at. It also of course graphed the solution.
Integrals and derivatives = No issues. Also the step by step was really helpful to me since it has been a few years and my calculus is rusty.
So yeah, It had no problems with the questions they provide as an example, but that makes sense. It better have no problems with their own stuff.
I ran it through a selection of worksheets from a program that I had purchased years ago. It did not matter that the questions were laid out in a different format, that the variables used were different letters other than x, y, a, b, and c, or that the font was different. It did it just fine.
I did not do an exhaustive test of its handwriting detection. I just wanted to see if reasonably neat handwriting would be recognized. It did pretty well. Some things that I noticed were that you need to remember the little things like putting the degrees sign on your trigonometric functions. It liked sin(30 degrees) but treated sin (30) as a different question. Also it handled both forms of 4, with the closed and open top, it handled curved 9 and straight 9, and normal 7 and crossed (drafting) seven. It thought a crossed (drafting) zero was a theta, which to be honest looks exactly like a theta and more often than not is a theta.
For any mistake that the photo part made there was a manual equation editor that you could use to fix it, and then it would solve the new fixed equation.
Photomath works as stated. While there are some math questions that it could not handle yet, like graphing systems of inequalities, the app is continually being revised and I would be very surprised if within a couple of years if could do every kind of math equation that any high schooler would ever face. (minus the word problems, maybe.)
I wanted to know if my math colleagues thought this was a good or a bad thing. Also, I was curious how the existance of this app was affecting the math class that my colleague teaches. So on Friday during lunch I tracked him down and asked him about it. The first thing he asked was if I had shown any students. I hadn’t. That calmed him. He said that he knows that students are going to come across this app likely sooner rather than later so he is trying to figure out what he is going to do. He already has his gradebook setup and is halfway through the semester. There is work that he expects to be done at home, and for at least this semester some of that work counts for marks. He said that he already suspects that there are some students that might be using it because their homework is so much better done than their in class work, but he does not think it is widespread yet. He thinks this since so many students are still doing poor quality homework (a good thing in this case?).
When he said all of this, I then became curious how he had heard about the app. He said that he was searching for math apps to create practice quizzes, and focused study help for students that were struggling. That when he came across it last week. He uses a lot of the kinds of programs that we have talked about in class, things like Kahoot, Socrative, and more. So I am not surprised that he found this app before many others.
He also said that while it is causing him to rethink how homework works, that this was more of a wakeup call than an all out crisis. He says you already have no guarantee that the student is the one doing the homework, and that spotting plagarism in math is next to impossible, whereas in other subjects you at least have a chance of spotting it. The homework portion of his mark setup is relatively low, with in class work and tests making up 80% of the students mark at this time. He was already leaning towards removing any mark for work done at home, but now he knows that this is the last semester he will ever give marks for homework.
So now what?
If you are a math teacher this kind of uncomfortable truce with technology is nothing new. Many of us grew up with teachers telling us to put away the calculators and to learn things by rote. Many of the current generation is growing up with a calculator that they literally carry everywhere with them. There is a lot of debate/soul searching happening around math curriculums in Canada and the world right now. So what is the solution? If you asked this question in a coffeeshop everyone would have an opinion and many of them would focus around the idea of back to basics, or doing more practice. You would even here a lot of the phrase back in my day we . . . The problem is that we are not back in anyone’s day. The tools available to students now make earlier approaches unpracticle, and unreliable. Especialy since the student is very unlikely to avoid the use of these tools. So how do we work with the tools available?
I know that photomath is too new to have any studies done on it, but I remembered that Wolfram Alpha was a computational search engine that could do similar things, and I remembered that the creator of it felt that math education needed to change. So I went looking for what he had to say, because I knew that he would be thinking about the issue. Was he ever! In fact he gave a TED talk about this way back in 2010.
There is a lot to process in this talk. In fact he did more than just give a talk about this. He started a whole organization about this called computerbasedmath.org which looks at how to teach math better using computers. I think that teaching computer based math was an option in 2010, in 2017 (soon 2018) it is essential.
I think that teaching computer based math was an option in 2010, in 2017 (soon 2018) it is essential!
I recommend you watch the TED talk if you teach anything like math or science. I also suggest you download the Photomath app because you are going to want to start to understand how students could use this as a positive thing. I know that for myself I am already thinking that next semester’s physics is going to look at lot different than last spring’s physics class because of the existance of this kind of stuff. I am only one person in a whole school though. I need to make sure that what I do is not going to cause huge headaches for others. So I need to, in the next month, talk with all the math and science people in my school and figure out now what? I think that Conrad Wolfram might just have a possible path forward for us.
Well, thanks for stopping by. Let me know how this affects you. I forsee good things potentially, but it will require us to change. Continuing as is, is definitely not the correct option.
My teaching career has been made possible by sharing. I will give a, not so brief, brief summary.
As a first year teacher I moved to a small town and taught in a k-12 school. I mostly relied on the resources from my own highschool experience. I was that student that never threw away my stuff and that first year I basically taught as I had been taught 5 years previously in my own high school. The notes and assignments that had been used on me I used on my students and this made it possible for me to have enough time to innovate some new stuff. Which I did digitally so that I would not lose it.
Then I got married and moved across the country to Victoria BC and could not find teaching work for a few years. When I did it was in a small private k-9 school looking to expand to highschool. I was hired as the grade 10 everything teacher. That year was a lot of work. I did not have resources that I could borrow from others. It was a different curriculum than the Saskatchewan one, and since it was a small private school I was not part of a union that could provide me with supports. I had to develop a lot of stuff. I remember we went to a teacher conference late in the year with other private schools and I took a USB stick and basically hunted down everyone who taught anything similar to what I taught and I asked them for their resources, their lessons. They delivered. I still had a lot of work to do, but I was given whole year plans for the maths and sciences that I was teaching.
The next few years at the school I would go on to develop many resources of my own and I remembered the help that I had received from others so I would take my USB stick full of information to conferences to share. As cloud storage and high speed internet became more prevalent I started to use dropbox and eventually google drive to share everything between multiple devices. By my 5th year at the school my wife and I were feeling it was time to return to Saskatchewan. I told the school, and in that final year I kept a careful digital record of every lesson for each class to give to my replacement. I knew that my job was a hard one and that being able to tell a potential employee that this resource existed would make it easier for them to find a replacement. (I was teaching 12 separate courses, some of them splits between different subjects of different grades because that is all that would work for the schedule of the small school.)
When I arrived in Regina at a much bigger school, although still k-12 and private, I found a very different environment than what I left behind. I was a part of a department here. The private school was an associate school so we actually work very closely with the public system helping them when we can, and receiving help from them. The science teachers of Regina meet about once a month at the board office to share resources. We call this the Science Curriculum Advisory Council. These meetings often have any or all of us sharing what has worked, what hasn’t, and how to prepare lessons for new curriculum, etc. That first year I was handed so many full year plan resources, by amazing teachers who have sat on curriculum writing boards. Within a few years I was piloting courses for Regina public and did the same for other teachers. I shared whole year plans of the courses that I had taught.
The sharing is not just limited to Regina though. My cousin is an amazing science teacher in the Saskatoon region, and when she was starting I handed her the full chemistry and physics year plans. She has in turn shared stuff that she has developed back with me. There is also a provincial shared google drive by all of the science teachers in the province. Anyone is allowed to contribute and take from it. It is moderated by three amazing teachers and I will occasionally put things into it, and get contacted by other teachers asking for clarification or help understanding a lesson, but never criticism.
So there is a sharing culture that exists in the sciences in this province, and I love it. So why does this exist in Saskatchewan for me, and why didn’t it in BC to the same extent? What was different about the architecture of the environment as Steven Johnson likes to call it? The biggest difference was isolation. In my little school in BC we were not part of any larger body except for 2 days a year. We were not part of the school division, we were so small that I was the entire math and science department, and I had no professional body of colleagues to call upon. In Regina my school has mulitple science teachers to share ideas with, I belong to a division that has purposefully built a program and environment of sharing. While I was able to innovate to a certain extent while working in BC, it was those times that I connected with others and shared resources at conferences that really gave me the ideas and the room to innovate more. Here in Saskatchewan it has been the cross pollination of ideas at council meetings, and seeing what others do with my stuff that has helped me be more creative. There is also an accountability factor. I produce better stuff and hold myself to a higher standard knowing that someone else will someday likely look at and want to use my materials.
I found myself really agreeing with everything that Steven Johnson said in his TED talk: Where do Good Ideas Come From. Also I think I have a new favourite mantra that I can take from it. “Chance favours the connected mind.” So, with that in mind I have been reflecting on my sharing and what things have helped me share more and less in the past. Sharing for me requires the following:
Be prepared to share. Whenever I develop a lesson or a worksheet, or anything I want to be able to reuse it so I store it digitally in a common format that can be edited later. I give it a useful name so that I can search for it later, and I file it in a subject folder sorted by year and semester. So often I have been able to find a resource to share with a colleague with a quick directory search for the keyword in the name, or by looking in the subject folder from the semester I think I did that lesson in.
Ask others for resources by offering your own. I have found that if I offer what little I have I will often get much more back. In that first year in Regina at that first meeting I remember giving away a simple little vocabulary worksheet creation tool that could work for any subject that I had programmed in excel. I got back an entire biology 30 and physics 30 course. It was easier to start the conversation by offering than asking.
Share what you got, even incomplete stuff. You never know if your half-baked idea will help someone come up with something else. The year that I piloted health science 20 I shared everything that I developed. Even the lessons that flopped. Teachers could go through the stuff, and if they did not like something they just would not use it. The partial share gives them the room to innovate.
Give credit where credit is due. I share stuff that I did not create with others, but I always ask permission first. The easiest way to do this is to ask the person that you are getting something from if you can share it with others in the future, and if you can share their contact information with others. Most people will just say to share it and not worry about mentioning them, others will say yeah and you can direct anyone with questions about it back to me. If they say don’t share it, then I mark the file as un-sharable. (Very rare). This makes it easier than tracking down people later to ask.
So my whole career has been made possible by sharing. The things that I have learned this semester about open education resources, and about better ways to connect using social media only excite me more. I am now looking for how best to share digitally in the digital world. Most people do not have time to look through a stack of resources and instead use quick searches to find what they need online. I would like to find an online open community that I could post my work into to help contribute, and also to be able to make withdraws from.
Well those are my thoughts on how sharing has impacted me and my career. Let me know what you think, and thanks for stopping by and taking the time to read all of that.
So in part 1 I explain the plan for the motor controller and get the hardware configured correctly. In part 2 I go through the program and realize that I cannot make it work for my equipment. This is not the fault of the program or programmer, I just have different equipment than they do. Also without going through that step I would not have learned all sorts of stuff about libraries, servos, and how the serial port works. Now in part 3 I decide to start fresh. My new plan is to try to see what others did and to try to write the code myself based rather than trying to rewrite someone else’s code.
I had spent a long time searching the internet to try to find another example of how to write the arduino code for using ESCs with DC motors and I kept getting nothing expect the one that I had already tried. I decided to try youtube. I came across this video with +80K views so I figured he likely knew what he was talking about.
Some things you will notice if you actually watch this video. He talks about the need to use the servo library as well. He also talks about the need to arm the ESC. Some things that he mentions that I did not know about with arduinos are PWM (pulse width modulation) aparently you need to have the motor attached to a PWM pin. He also mentions that you can tell if a pin is a PWM because it will have a ~ beside it. I tried his code, it did not work for my equipment.
So I decided to go back to the manufacturer’s site and read more carefully through all of the documentation. So some things I noticed.
They do not mention arming, but they do talk about how to calibrate the ESC.
They mention pulse lengths.
I decide that I need to know more about how pulse lengths work on the arduino. I have used PWM in other languages, but I need to know a few specifics about how the arduino does it. For example, how long is a full pulse? PWM works buy turning the pin on and off quickly so that is it only on for a fraction of the time. Since this is happening so quickly it is like turning the power level down to that level. So an LED that is on a PWM pin of 50% would be dimmer than one on a PWM pin of 100%. So I look for an example and I find a tutorial on the Arduino website on PWMs.
In this tutorial they mention that most pins on the arduino have a frequency of 500hz and that the period of time is the inverse of this. They also mention that you do this using a function called analogWrite(value). So I look up the reference material for analogWrite(value) and find that pin 9 is a 480 hz pin which means that the inverse is 2083 microsecond. This would be above the 2000 microsecond threshold for full forward according to Fingertech so I should be able to use this pin to send signals to the ESC.
After reading how analogWrite() works I decide to write a simple code to test and see if I can get away without arming the ESC. The way that it works is that it sends a value between 0 and 255. So I need to divide 2083 (full pulse width) by 255 to find out how many microseconds each step of analogWrite is. 2083/255 = 8.16. So 2000 microseconds is 2000/8.16 = 244 and 1000 microseconds is 1000/8.16 = 122 and neutral is 1500/8.16 = 183.
So, I wrote a code that sent a 244 signal to the motor for 2 seconds. Then a neutral signal of 183 for a tenth of a second, followed by a 122 signal for 2 seconds. Then another neutral signal for a tenth of a second. I put this in a simple loop and loaded it. IT WORKED!
It worked and the code is ridiculously simple. All that time messing around loading libraries, trying to arm it, etc wasted. Well not truly wasted, I did learn how to load a library, and also how to run the serial monitor. That will come in handy soon I am sure. But still, look at how short this code is. It took me 15 hours to get to this?! AHHH.
Okay so the last little bit should be easy. I want to have the potentiometer control the motor. I already was able to make it control the LED blinking as I mentioned in part 1 of this series. So I just need to take the input of the potentiometer and put it into analogWrite. There is the small problem that the potentiometer generates values between 0 and 1023. So I need to do some math. The largest value I want is 244 and the smallest is 122. That is a difference of 122. If I divide 1023 by 122 I get 8.4. So my analogWrite could should look like this: analogWrite(RightMotor, (122+(potentiometer/8.4))). This should give me a 122 value when the potentiometer is 0 and a 244 value when the potentiometer is 1023. I try this in the code and IT WORKS FIRST TRY! I actually giggled at this point. Here is the video of it working.
For anyone who is interested here is the link to the code in my google drive account. It is yours, have fun. You will need to setup the potentiometer on pin 5, the two LEDs on pins 12 and 13, and the motor on pin 9. This code will likely only work for the FingerTech tinyESC. For anyone interested I did email the company about the arming process and heard back after all of this that it auto-arms, so yeah, that is cool. This is likely the best ESC on the market, and it is a Saskatchewan company. So shout out for home grown talent!.
In part one of figuring out how to program the motor controller I made the motor move. I figured it would only take me a little bit of poking around to modify the program that I found. I mean I have programmed in other languages before so I should be able to figure it out, right? Well it turns out as I went through the program I discovered that a lot of the assumptions that the people on the internet made were not true for my equipment, and a lot of assumptions that I was making were not true either. I will take you through the process of how I figured out that I was not figuring it out.
So the first thing I did was to start to read through the code that I had copied. It is somewhat lengthy, but you can read through it here if you want. I will just refer to pieces as I go and I will talk about the things that I learned from them.
Analyzing the code:
1. The first thing that I came across in the code was this.
This is called a library. I had heard of libraries in other programming languages, but had never actually used one. An analogy that might help is to think of it as a language extension. Lets say you are going on a trip and you learn the basics of a language for the country that you are travelling to. How to ask for directions, where the bathrooms are, etc. A library would be like learning a new set of vocabulary words that apply to a specific situation. For example you might learn a whole bunch of winter and skiing words if you were travelling to a winter resort. This particular set of words you would not normally need if travelling to another country, but you needed them for this specific trip. That is like a library in programing.
There are some basic functions (words) that are already loaded into the memory of the arduino, but for some jobs you need more specific, specialized words. So in this case it looked like I was going to need to load a library that deals with servos. So I loaded the library and spent a few minutes reading through the list of functions that it added.
2. So what is a servo? Well servos are like motors but they turn a precise number of degrees. You can control how many degrees that they change. Some servos are continous rotation and instead you can control how fast they turn. At least that is my current level of understanding. I know that the motor I am using is not a servo, it is a DC motor. I am not sure why I need a servo command in the program. But the motor turned so I will keep looking at what the program does.
3. The next thing in the program that I did not understand fully was the serial window.
You probably have heard about serial ports before. They are the things that you use to connect printers, etc to your computer. Basically my understanding of it was that it was the port that the computer uses to send and recieve information to the device on. I know that in theory, but now for the practical questions I had. How does the device know which information to send back to the computer to display? You might have mulitple sensors attached. How can you see the information from just one of them? This meant more reading. So I read through all of the serial functions in the arduino library.
Okay I figured out how to control which information gets displayed. It is really nice and simple. You say serial.println(pin or variable name). This means that if I want to see why my motor is turning the way it is that I can say serial.println(motorname) and it will show me the information that my motor is receiving. You would add a delay(10) or something like that after to make it so that you have time to read the information.
If you want to use the serial port you CANNOT use pins 0 or 1 for digital input of output pins.
The other really important piece of information that I came across was that I should make sure to avoid using pins 0 and 1 for inputs or outputs. They are dedicated pins for the arduino to recieve (RX) and transmit (TX) information to and from the computer with. Normally you could use them, but not if you want to use the serial port. Since I know that I will want to use the serial port for debugging in the future I will make a habit of never using these pins and will use other pins whenever avaialable.
4. The next thing that I did not understand was the purpose of the code that I was reading. I understood what instructions it was telling my arduino to do, but I did not understand why it wanted to tell the arduino to do it. As far as I could tell it had to do with something called arming the ESC (see step 5). Everywhere I looked everyone kept talking about arming their ESC before doing anything else. Also they kept saying to check with your manufacturer to see how to arm it. Well I did that, nothing. Hmm. I thought maybe calibration and arming were the same thing, nope. Many forums on the internet talk about the two as separate things. I probably wasted a couple of hours trying to figure out this step. Turns out that the tinyESC doesn’t need this. Still not sure why? If anyone knows let me know.
5. Okay so no matter how long I play with this code I cannot make it turn the motor at any different speed and I think it has something to do with arming. I am frustrated and I do not want to see this code anymore. So I tried a different approach. Join me in part three as I explain what I tried next.