We introduce this Do-It-Yourself Technology subseries in our blog to help make computer coding or programming more accessible to everyone even if you're not particularly tech-savvy. Writing code to instruct a computer on what to do may sound intimidating, but it doesn't have to be. There's a ton of resources online and the possibilities of what you can do with code are endless, especially with home automation.
Tip 1: Code with an end goal in mind
Before you start your coding journey, it helps to have an end goal in mind. Ask yourself, what problem can I solve to make my life easier? For example, when you’re online shopping, are you frustrated by having to repeatedly refresh the webpage to check if an item you desperately want is back in stock? Or do you wish your Google Home would also turn on your sound system every time it turns on your TV? Whatever the mundane task may be, wouldn’t it be great if you can automate the boring things in life? Yes, of course, you can! While it may not sound exciting, but automating a task that is personal to you, gives you a reason to keep at it. Trust us, there will be moments you would want to give up programming because your code is not working. But once you overcome that hurdle and it's finally working, you'll feel a sense of accomplishment.
Tip 2: Don’t fret over what language to learn
You may find yourself asking, what programming language should I learn? This depends on your end goal. If you want to create an iPhone app, then learn Swift. If you want to create a video game, learn C++. If you want to automate a certain task, learn Python. But oftentimes, choosing a language is not always so clear-cut. For example, if you want to automate clicking through a website, learning Python is definitely useful, but to interact with the web browser, you may need to know some HTML and JavaScript. Think of programming languages like a tool in your toolbox. To fix a wobbly table, usually, a screwdriver is all you need, but if the screw becomes stripped, you would need to also use a wrench or even a drill. As a result, you need more than one tool to repair the table. Coding works the same way, sometimes you need to use multiple languages because there isn't a one-size-fits-all.
Tip 3: Python is a good first language
Although we did say to not fret over what language to learn, generally speaking, learning Python is easier than other languages. Much like English is easier to learn than German. You can start understanding English sooner because you are not bogged down with grammar rules like you are with German or other languages. Python reads quite like English. The syntax is easy to read and you will find that you understand the gist of the Python code even if you don't understand everything.
This makes it easy to start writing your own code or leveraging code written by others. That's another great thing about Python. A lot of the code is readily available and saved in libraries. This eliminates the need to write code from scratch. All you need to figure out is what libraries to use and how to use them.
Once you get the hang of Python and understand the basic programming concepts such as loops, conditionals, and functions, you can pick up other languages more easily because the concepts are the same.
Since our DIY Tech subseries will focus on home automation, Python is best suited for these tasks. But we will touch on other languages where appropriate.
How to install Python
To get started, download and install Python onto your computer for the version appropriate for your operating system from www.python.org/downloads.
After installation, if you are using Windows, you can start using Python directly in Command Prompt by simply typing "python" as shown below.
For simplicity, we will be using Window's Command Prompt to run our Python code. But as you get more experienced and work on more complex projects, you may want to use development tools such as PyCharm to make coding easier.
How to install Python libraries
We mentioned that one advantage of Python is the wealth of libraries. You can search what libraries are available on https://pypi.org. For example, Selenium is a powerful library used for automation because it allows you to interact with a website entirely by code.
Once you have Python installed, you also have to separately install any third-party library before you can use it. In Command Prompt, type "pip install" followed by the name of the library. For example, to install Selenium, type the following as shown below.
Stay tuned!
Now that you have Python up and running, stay tuned for our future blogs on our DIY home automation projects. We have some exciting things in store for using Python to search for new construction homes and customizing Google Home to do a lot more around the house. Stay tuned!
Comments