Saturday 13 March 2021

Arduino - Hardware - Getting started

Some basic Arduino info to get things started.
There are plenty of different types of Arduino board. 
Here is a comparison of the Leonardo to the Uno
The Uno is the most popular, but the Leonardo is still a good choice


Arduino Leonardo Arduino Uno
Microcontroller ATmega32u4 ATmega328
Digital I/O Pins 20 14
Analog Input Pins 12 6
PWM Channels 7 6
Flash Memory 32 KB of which 4 KB used by bootloader 32 KB of which 0.5 KB used by bootloader
SRAM2.5 KB 2 KB
  Arduino Uno
This is the most common type of Arduino

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Analog Pins
A0 to A5
These are analog pins but can also serve as digital ins/outs
On the Arduino Uno they can sense a range of input voltages. 
You might use this to read the position of a potentiometer or 
another input with a smoothly variable input.  
 
These pins are connected to a ADC (analog to digital converter) .
The ADC has 10-bit resolution, meaning it can represent analog voltage by 1,024 digital levels. 
The ADC converts voltage into bits which the microprocessor can understand.
0V = 0 bits
5 V = 1023 bits

Pins A4 & A5 are also the I2C connections.
SCL on A5, SDA on A4
The I2C bus allows connection of multiple modules, allowing communication between them.
With I2C there are 2 wires referred to as SCL and SDA.
  • SCL is the clock line which is designed to synchronize data transfers.
  • SDA is the line used to transmit data.
 
 
Digital pins
Pins 0-13 of the Arduino Uno serve as digital input/output pins.
Digital is a way of representing voltage in 1 bit: either 0 or 1.  (High/Low).
When the digital pins are configured as outputs, they output either 0 or 5 volts.
When the digital pins are configured as inputs, the input voltage is converted into either 0 or 1.
Any input voltage below 0.8v - considered as 0.
Any input voltage above 2v - considered as 1.
 
D0 - Serial TTL (RX)
D1 - Serial TTL (Tx)
D2
D3 - PWM Pin
        PWM allows you to control the voltage of the output by switching the output 
         between high and low very very quickly. 
        The percentage of time the pin is high is called its 'duty cycle' 
          the PWM enabled pins produce a constant frequency of ~ 500Hz,
         while the duty cycle changes according to the parameters set by the user.
          This pin does "analogWrite" as do pins 4,5,9,10,11
          These pins allow you to simulate analog voltages
D4
D5 - PWM Pin
         +This pin does "analogWrite"
D6
D7
D8
D9 - PWM Pin
D10 - PWM Pin
D11 - PWM Pin
D12
D13 
The Arduino Uno R3 has an LED with its own resistor attached to pin 13. This means that even if you don't attach any LEDs to your board, if you set pin 13 to an output and set it high, you should see an LED on the board come on. Digital pin 13 is harder to use as a digital input than the other digital pins because of this LED and the resistor attached to it
 
-------------------
 
SPI Pins: SS on 10,  MOSI on 11, MISO on 12, SCLK on 13.
Serial Peripheral Interface (SPI) is a serial data protocol used by microcontrollers to communicate with one or more external devices in a bus like connection. The SPI can also be used to connect 2 microcontrollers. 
  • MISO (Master In Slave Out) - A line for sending data to the Master device
  • MOSI (Master Out Slave In) - The Master line for sending data to peripheral devices
  • SCK (Serial Clock) - A clock signal generated by the Master device to synchronize data transmission.
 
 
Arduino Leonardo
Regular
Microcontroller: ATmega32u4 with built-in USB communication.
It has double the number of analog input pins. 
A0-A5 are dedicated for analog, and A6-A11 are on digital pins.
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Analog Pins
A0 to A5 - these are on the analog in header
A6 to A11 - they are located among the digital pin headers.
These analog pins can also be used for digital I/O.
 
Digital pins (18 digital pins)
D0 - Digital In & Serial In,  RX
       Because this is a digital input, it can only read if a signal is on or off.
       It can receive digital info from another module, and can allow two arduino modules
       to talk to one another.
D1 - Digital out & Serial out, Tx
        Both the TX and RX pins have LEDs associated with them so show
        the status of Serial communication between the board and the computer.
D2
D3 - PWM Pin
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14 – MISO – PB3
       Its also a ground.
D15 – SCK – PB1
D16 – MOSI – PB2
        Also I2C's SDA
D17 – SS – PB0
       Also I2C's  SCL
 
Pin D17 (SS) does not have a corresponding pin on the ICSP header, nor anywhere on the board. In order to use it, you must solder a wire to either the end of the Rx LED or the via attached to it 
 
 
Little Bits (leonardo)
This is a really easy way to get into Arduino.
Korg released this a few years ago and these modules are geared towards analog synths.
Though they may look like toys, the modules are a fun way to do DIY without needing to touch a soldering iron.
 
All the inputs are on the left.
The outputs are on the right.
 There are 3 inputs & 3 outputs.
 
Little bits reads voltages a bit differently than a standard arduino.
The input voltages are the same (zero to 5Volts) but
little bits reads a 5V voltage as 99 bits, where as an arduino reads it as 1023 bits.
So in the code, if you wish to convert to little bits remember 5V = 99

With output voltages its the same deal.
With little bits, the output is 0 to 99
In arduino, the output values are 0 to 255
 

 
 








Analog/Digital In/out Pins
A0 - Analog input
         It can be used in analog or digital read.
A1 - Analog Input
          It can be used in analog or digital read.
A2 - A4 - solder a header to this to allow external connections.
       These 3 pins are GPIO (general-purpose input/output) analog 
A5 - (N/C... not connected)        
 
Digital pins
D0 - Digital In & Serial In,  RX
       Because this is a digital input, it can only read if a signal is on or off.
       It can receive digital info from another module, and can allow two arduino modules
       to talk to one another.
D1 - Digital out & Serial out, Tx
        Both the TX and RX pins have LEDs associated with them so show
        the status of Serial communication between the board and the computer.
 
D2 - I2C Bus Digital I/O
D3 - I2C Bus Digital I/O
         The I2C bus allows connection of multiple modules, allowing communication between them
          without needing the bitsnap connectors
         The top side of the PCB has two pads which break out pins D2 and D3 from the ATmega32U4. 
         These are the SDA and SDL lines used in I2C communications so multiple boards can be 
         chained together. 
         There are unpopulated pads for 10K pull up resistors if I2C implementation is needed. 
          These pins can also be used as GPIO (general-purpose input/output).
 
D4 - (N/C)
D5 - Digital PWM Out 
        This output has a output mode switch that allows you to select between PWM vs analog config.
        In analog mode, the output is sent through a LPF (Low Pass filter) to improve compatability with
        analog signals in the littlebits system.... basically, it simulates an analog DC voltage
D6 - (N/C)     
D7 - (N/C)     
D8 - (N/C)     
D9 - Digital PWM Out 
         This output has a output mode switch that allows you to select between PWM vs analog config.  
D10 - Digital I/O - solder a header to this to allow external connections.
D11 - Digital I/O - solder a header to this to allow external connections.
D12 - (N/C)     
D13 - Digital I/O - solder a header to this to allow external connections.
 
ICSP header - 6 pins
ICSP stands for In-Circuit Serial Programming.
Allows you to change the bootloader or program the module directly from this header with an AVR programmer.

When connecting an output little bits module (W9 proto):

Links (Paul McWhorter)

+ Basic blinking LED video and starter programming

Understanding Arduino Variables  
 
Understanding and Working With Binary Numbers
 
Building a binary counter with LEDs
 
AnalogWrite command
 
Understanding PWM and the AnalogWrite command
 
Understanding How To Read Analog Voltage using analogRead Command
 
 
 ---------------------------------
-------------------------------------

No comments:

Post a Comment