Welcome to Arduino Day 2016 An Intro to Arduino From Zero to Hero in an Hour !

Paul Court (aka @Courty) Welcome to the SLMS Arduino Day 2016

Arduino / Genuino ?! What ?? Part 1 – Intro

Quick Look at the Uno Board and Arduino IDE Software What is Arduino ?

+

Hardware Software

• Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists and anyone interested in creating interactive objects or for just learning about microcontrollers. Other Members of the Arduino Family

Arduino’s come in all sorts of shapes and sizes Anatomy of the UNO R3 Digital Input and Outputs R2

Microcontroller ‘ATMega328P’ Microcontroller ?

A microcontroller is a small computer (SoC - System on a Chip) on a single integrated circuit containing a processor core, memory and programmable input/output peripherals. Programmable input/output peripherals ?

Sensors With some simple code, the Arduino can control and interact with a wide variety of sensors - things that can measure light, temperature, degree of flex, pressure, proximity, acceleration, carbon monoxide, radioactivity, humidity, barometric pressure, you name it, you can sense it!

Shields Additionally, there are these things called shields – basically they are pre-built circuit boards that fit on top of your Arduino and provide additional capabilities – controlling motors, connecting to the internet, providing cellular or other wireless communication, controlling an LCD screen, and much more. The Arduino Software (IDE) Factoid !

The name Arduino comes from a bar in , Italy where some of the founders of the project used to meet. The bar was named after Arduin of Ivrea, who was the margrave of the March of Ivrea and from 1002 to 1014 ! Part 2 – The Arduino UNO

Deeper Look at the Uno Board Anatomy of the UNO

Output

Input

Digital = Light Switch Analog = Dimmer Switch Arduino Benefits

• Easiest to get started with of all the kit boards • Huge global community sharing ideas, code and help • Great support for all sorts of sensors and gadgets • Very flexible, Loads of options and ways to configure it • Most of the Pins are programmable – You tell the board what each pin should do • Fairly robust and hard to break (this is not a challenge !) • Fast, up to 16 million instructions per second • Great leader into other microcontrollers and to Electronics Part 3 – The Arduino IDE

Deeper Look at the Arduino Software Quick tour of the IDE 1. Verify: Compiles and approves your code. It will catch errors in syntax (like missing semi-colons or parenthesis). 2. Upload: Sends your code to the Uno. When you click it, you should see the lights on your board blink rapidly. 3. New: This buttons opens up a new code window tab. 4. Open: This button will let you open up an existing sketch. 5. Save: This saves the currently active sketch. 6. Serial Monitor: This will open a window that displays any serial information your Uno Board is transmitting. It is very useful for debugging. 7. Sketch Name: This shows the name of the sketch you are currently working on. 8. Code Area: This is the area where you compose the code for your sketch. 9. Message Area: This is where the IDE tells you if there were any errors in your code. 10. Text Console: The text console shows complete error messages. When debugging, the text console is very useful. 11. Board and Serial Port: Shows you what board and the serial port selections Arduino IDE Benefits

• Based on the industry standard “C” language (mostly English) • Hides most of the complexity from the user so focus on job in hand • Manages code and libraries for you • Lots of examples built in • Help system and code reference built in • Starting to have support for other platforms (Esp8266 for example) • Can accept advanced machine level commands too Ready ? Lets get started..

https://www.arduino.cc/en/Main/Software Part 4 – Lets Code !

Your first project Two Core Functions

Power On

setup()

loop() void setup() and void loop()

There are two special functions that are a part of every Arduino sketch: setup() and loop(). The setup() is called once, when the sketch starts. It's a good place to do setup tasks like setting pin modes or initializing libraries or for code that only runs once.

The loop() function is called over and over in a loop and is heart of most sketches.

You need to include both functions in your sketch, even if you don't use them for anything. ‘Blink’ Sketch Example – Line by Line

** On your UNO, Pin 13 has a small LED attached to it Anatomy of the UNO

Output

Input

Digital = Light Switch Analog = Dimmer Switch Only Four Commands in the ‘Blink’ Sketch int – tells Arduino to treat the item as a whole number only and sets up the name (variable) pinMode() - Configures the specified pin to behave either as an INPUT or an OUTPUT digitalWrite() - Writes a HIGH (on) or a LOW (off) value to a digital pin (+5v or 0v) delay() - Pauses the program for the amount of time (in miliseconds, 1000 milliseconds in a second)

Select your board from the ‘Tools’ menu Select your board:- ‘Tools’ ‘Board’ ‘Arduino UNO’

Select your Port:- ‘Tools’ ‘Serial Port’ ‘Comx’ **Number is normally the last one Open the ‘Blink’ Example

Open the Following Sketch :- ‘File’ ‘Examples’ ‘01 Basics’ ‘Blink’ Upload your Sketch ! Your Turn

Task 1 – Get your LED flashing by successfully uploading ‘Blink’ to your Arduino UNO

Task 2 – Now make your LED flash at ½ second intervals instead of 1 second

Task 3 – Make your LED flash 3 times and then stop until the reset button is pressed Other Sketches to play with

• Button • SerialEvent Congratulations ! Resources: Web

• SLMS Forum and Events https://discourse.southlondonmakerspace.org/ Thank You for Participating in

Paul Court (aka @Courty)