ATmega328 GPIO & Digital Input Output

Introduction to Arduino General Purpose Board

Arduino_General-Purpose-Board



Starting clockwise from the top center:

  • Analog Reference pin (orange)
  • Digital Ground (light green)
  • Digital Pins 2-13 (green)
  • Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o (digitalRead and digitalWrite) if you are also using serial communication (e.g. Serial.begin).
  • Reset Button - S1 (dark blue)In-circuit Serial Programmer (blue-green)
  • Analog In Pins 0-5 (light blue)
  • Power and Ground Pins (power: orange, grounds: light orange)
  • External Power Supply In (9-12VDC) - X1 (pink)
  • Toggles External Power and USB Power (place jumper on two pins closest to desired supply) - SV1 (purple)
  • USB (used for uploading sketches to the board and for serial communication between the board and the computer; can be used to power the board) (yellow)

ATmega328P (used on most recent boards)

Digital I/O Pins14 (of which 6 provide PWM output)
Analog Input Pins6 (DIP) or 8 (SMD)
DC Current per I/O Pin40 mA
Flash Memory32 KB
SRAM2 KB
EEPROM1KB

Video Tutorial


Not able to watch this Video Tutorial, Don't worry !
To watch this video you have to purchase Video Tutorial Series Subscription of Arduino Part (Total - 37 Video's Package @ Rs. 300/-). Call 8830002899 for more details
This Video Tutorial Series covers all the topics of Arduino Part with Questions & their Answers



Arduino Digital and Analog I/O Pins

ATmega328P


Digital Pins

PinsFunction

 0 to 7

PORT D [0:7]

 8 to 13

PORT B [0:5] 

14 to 19

PORT C [0:5] (Arduino Analog Pins 0 to 5)

Digital pins 0 and 1

RX and TX for serial communication

Digital pin 13Connected to the base board LED

Digital Pin Input / Output Functions

FunctionWhat does it do?

pinMode(pin, mode)

  • Sets pin to INPUT or OUTPUT mode
  • Writes 1 bit in the DDRx register

digitalWrite(pin, value)

  • Sets pin value to LOW or HIGH (0 or 1)
  • Writes 1 bit in the PORTx register

int value = digitalRead(pin)

  • Reads back pin value (0 or 1)
  • Read 1 bit in the PINx register

Analog Pins

Input/ OutputPin Numbers
Analog Input pins0 to 5
Analog Output pins3, 5, 6, 9, 10, 11 (digital pins)

Analog Input / Output Functions

Input Functions
int val = analogRead(pin)
  • Converts 0 – 5v. voltage to a 10-bit number (0 – 1023)
  • Don’t use pinMode
analogReference(type)
  • Used to change how voltage is converted (advanced)
Output Functions
analogWrite(pin, value)
  • Value is 0 – 255
  • Generates a PWM output on digital pin (3, 5, 6, 9, 10, 11) @490Hz frequency  

Video Tutorial

Not able to watch this Video Tutorial, Don't worry !
To watch this video you have to purchase Video Tutorial Series Subscription of Arduino Part (Total - 37 Video's Package @ Rs. 300/-). Call 8830002899 for more details
This Video Tutorial Series covers all the topics of Arduino Part with Questions & their Answers


Video Tutorial

Not able to watch this Video Tutorial, Don't worry !
To watch this video you have to purchase Video Tutorial Series Subscription of Arduino Part (Total - 37 Video's Package @ Rs. 300/-). Call 8830002899 for more details
This Video Tutorial Series covers all the topics of Arduino Part with Questions & their Answers


References


Last modified: Wednesday, 16 October 2019, 11:16 PM