David Prieto
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Starting with Arduino. Installing and first blink ###### tags: `IB` `Computer Science` `Arduino` [ToC] ## What is this about Since Computer Science is about _thinking_ we're going to see how an arduino thinks and let's try to see if it works. The menu is as follows * I give you this brief explanation * You install the software to talk to arduino * We test an example called "blink" * We explain a little further * We do more examples about functions (in other pages) The final project here that we're going to do together (probably not in the same day) is a program that converts a text message into morse code. ## So what's an arduino In brief we can say **Arduino is a easy-to-program microcontroller board**. But if we dig up a bit, Arduino can stand for 6 different things and we're going to refer mainly to 2 of them. These things can be: - Arduino the physical microcontroller that you have. "My arduino doesn't work" usually is refering to this part. There are several models and the most common and easy to use is arduino uno r3. (but we can finde arduino nano, micro, leonardo, etc) ![](https://i.imgur.com/JQObLhb.png) - Arduino the architecture of that hardware and their specifications. ![](https://i.imgur.com/9EIFf3z.png) - Arduino IDE (IDE means Integrated Development Enviroment, we'll get to that later). The software that can program the microcontroller (and other microcontrollers!). We are going to use Arduino IDE to program arduino but we could use other IDEs with the proper plugins. ![](https://i.imgur.com/GjDMUOi.png) - Arduino the toolchain. This is the list of things that has to do the Arduino IDE (or other program) to upload our code into the Arduino. ![](https://i.imgur.com/CI6YCl0.png) - Arduino the company. ![](https://i.imgur.com/OEt6Efy.png) - Arduino the library of C++ that we need to use commands like "digitalWrite()". By default the program language C++ doesn't have the tools to interact and use the commands that an arduino has. There is a library that handles that (put by default by Arduino IDE so we don't have to worry about it) ![](https://i.imgur.com/0BCLyoH.png) We usually are going to refer to Arduino as the **Arduino IDE** and the **Arduino the hardware**. So if it's so *easy to program* let's try to do something with it! ## Start downloading Arduino IDE So you should have your arduinos by now. To talk to them you will need arduino software. It can be online or downloaded. I recommend to download it at least in Windows OS. https://www.arduino.cc/en/software There are 2 options to download. The 2 should be fine and work. But the 1.8.19 (the old one) has more support and more help that you can find easily. If you're in doubt, choose this one. ![](https://i.imgur.com/DpcYOTl.png) You don't have to contribute. You can "just download" ![](https://i.imgur.com/makcRrj.png) Once you have it downloaded you open the installer: ![](https://i.imgur.com/8j3CCEk.png) If windows says something like "do you allow Arduino to make changes in the system?" you say yes. ![](https://i.imgur.com/xV6snhL.png) Here you say that you agree to the EULA (End User License Agreeement) ![](https://i.imgur.com/PnDvinj.png) You can uncheck the dekstop if you don't like it but I suggest to keep the start meno shorcut. *Please, install the USB driver and associate .ino files* ![](https://i.imgur.com/Amc5nbK.png) You can change the place where you install this package and check if you have enough space. Then you clic install. ![](https://i.imgur.com/PeHMBTv.png) Then you open it up from the Start (you can look for it or write "Arduino" and windows will find it) ![](https://i.imgur.com/1Eddy4H.png) If it opens this, you're done installing! ### Variant of version 2.0.0 rc9.2 In the website there is also the option to download the _new_ version of Arduino IDE. Version 2.0 ![](https://i.imgur.com/q0CQmR5.png) This is not a stable version (yet) but it's moving to do it. That's why is an "RC", "release candidate". There have been other Released Candidate versions before each of them with less bugs and more stable than the former. ![](https://i.imgur.com/iPQrGxx.png) To install we use the same process as in 1.8. If you're confused by the windows that are slighlty different, you should keep with the 1.8 version. It may ask you for permissions like these: ![](https://i.imgur.com/OgeMph7.png) ![](https://i.imgur.com/wfqnWwJ.png) You have to allow it. If you're done you should have this window: ![](https://i.imgur.com/49a3DBh.png) ## Load (and modify) the first program If you don't have the Blink program, you can easily load it using the menus: File -> examples -> 0.1 Basics -> Blink ![](https://i.imgur.com/HhhJ7gj.png) It will open a new window with that program. You might close te former window if you want. ## The first program it's already loaded in the IDE! Ok, so now let's try to program our arduinos to check if the hardware and the software is ok. ## Change the Blink program If you plug your arduinos out of the box they seem to have preinstalled the "Blink" program. You should check what happens if you plug the arduino with the USB. There is a small led that is blinking. That's why we're going to use a modified version of the program. To change this we're going to tweak a bit the default blink program. In the part that says "void loop(){}" we're going to put this code in the brackets ```C++ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a tenth of a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for a tenth of a second ``` This chunk of lines that you copy and paste is called a **snippet** of code. We're substituting the 1000 in the delays for 100. Then we have to set up the correct port once the arduino is pluged in to the computer we're using. To do that we go to the menu tools -> port and we select the one that says "Arduino Uno" ![](https://i.imgur.com/hkXac7G.png) It can be COM1, COM3, COM4 depending on the circunstances. Then we have 2 buttons that we have to know in arduino. The button "compile" and the button "upload" ### The verify button ![](https://i.imgur.com/z0TpVL6.png) The button verify is just a check that saves the file and runs the compiler, checking any problems with the syntax of the program. Something like writing "digitalwrite" instead of "digitalWrite" is a common mistake detected by this since C++ is case sensitive (the good one is "digitalWrite"). **This button doesn't interface with the arduino board** ### The upload button ![](https://i.imgur.com/fDcAGif.png) This button first compiles the program and then attempts to upload it using the the full toolchain. **We need to press this button in order to make the program work in the arduino board.** Once we press it it's going to do stuff in the bottom part of the window. If everything goes well you should have something like this that says "Subido" or "Uploaded": ![](https://i.imgur.com/fFn1XEV.png) ### Common errors In the bottom screen you might see some errors. Here you can find some of the basics that you can find today. **"Expected something"** ![](https://i.imgur.com/Hmd1IhM.png) It usually means that you missed a semicolon or a bracket or a parenthesis. You can check in what line is the error and change it. Here in the last delay there is no semicolon. **"Somehting was not declared in the scope"** ![](https://i.imgur.com/deJYyk8.png) Usually it means that you misspelled something. Be aware of the upper and lower case that you have to use. You can check in what line is the error and change it. Here I wrote "digitalwrite" instead of "digitalWrite" (also it changed the color) **"Problem uploading to board"** ![](https://i.imgur.com/KYlwiCe.png) It usually means that either your arduino is not connected or maybe you didn't defined the port properly. Check both things. ## Try to tweak it by yourself! Change the values and I'll explain on the board what is happening in this simple program. ### Next step: Coding Morse Code. https://hackmd.io/2OLbqEc6SnuhkR-RcrGRDA ## References: Class of Fabacademy 2022 on embedded programming https://vimeo.com/689983001

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully