Skip to content

Instantly share code, notes, and snippets.

@topshed
Last active April 20, 2018 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topshed/e4e821dd1d106199ccc7bbdd8e79459c to your computer and use it in GitHub Desktop.
Save topshed/e4e821dd1d106199ccc7bbdd8e79459c to your computer and use it in GitHub Desktop.

Getting started with Arduino

Introducing Arduino Uno

An Arduino is a really useful microcontroller. The one shown below is an Uno, but you can use most other models with the same code and circuit (althought you may need to search up the pinout to work out which pins to use).

The Arduino is connected to your computer via USB. You create programs - called sketches - using the Arduino IDE and download them to the device using this cable.

To successfully connect you need to select the correct Board and Port from the Tools menu.

Imgur

Hello World

Try the sketch below to make the built-in LED on the arduino Uno blink.

Any line starting with // is a comment.

Imgur

Arduino Sketches

Every sketch must have a 'setup()' and 'loop()' block, enclosed by {}. The setup() block runs only once, when the sketch begins. You typically do “housekeeping” tasks in the setup() block to get things ready for the main part of the sketch. For example, you can set the modes of the input/output pins that you will need.

After the setup() block runs once, the sketch enters the loop() block. When we hit the } at the bottom of the loop() block, the sketch returns to the top and runs the lines over again. This continues as long as the Arduino is powered up.

Challenge

Can you change the code to make the LED blink faster?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment