UNO board IO pin introduction

UNO board IO pin introduction

UNO Technical spacs:

Input and Output
Each of the 14 digital pins on the Uno can be used as an input or output to exert pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive 20 mA as recommended operating condition and has an internal pull-up resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that shouldn’t  be exceeded on any I/O pin to avoid permanent damage to the microcontroller.
In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.
LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.
The Uno has 6 analog inputs, labeled as A0 to A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, however it is possible to change the upper end of their range using the AREF pin and the analogReference() function.
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

Digital I/O
Configures the specified pin to use either as an input or an output. See the description of digital pins for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.
pinMode(pin, mode)
pin: the number of the pin whose mode you wish to set

Write a HIGH or a LOW value to a digital pin.
If the pin has been configured as an OUTPUT with pinMode(), its voltage should be set to the corresponding value: 5V for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor.
NOTE: If you don’t set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(HIGH), the LED may appear dim. Without explicitly setting pinMode(), digitalWrite() will enable the internal pull-up resistor which acts like a large current-limiting one.
digitalWrite(pin, value)
pin: the pin number
value: HIGH or LOW

Reads the value from a specified digital pin, either HIGH or LOW.
pin: the number of the digital pin you want to read (int)

Sets pin 13 to the same value as pin 7, declared as an input.

int ledPin = 13; // LED connected to digital pin 13
int inPin = 7;   // pushbutton connected to digital pin 7
int val = 0;     // variable to store the read value

void setup()
pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
pinMode(inPin, INPUT);        // sets the digital pin 7 as input

void loop()
val = digitalRead(inPin);     // read the input pin
digitalWrite(ledPin, val);    // sets the LED to the button’s value

Analog I/O
Reads the value from the specified 1analog pin. The Arduino board contains a 6-channel, 10-bit analog  digital converter, which will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.

It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

pin: the number of the analog input pin read from 0 to 5
int (0 to 1023)

If the 1analog input pin is not connected to anything, the value returned by 1analogRead() will fluctuate based on a number of factors (e.g. the values of the other 1analog inputs, how close your hand is to the board, etc.).

int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0;            // variable to store the value read

void setup()
Serial.begin(9600);          //  setup serial

void loop()
val = analogRead(analogPin);    // read the input pin
Serial.println(val);             // debug value


Writing an 1analog value (PWM wave) to a pin can light the LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). this function works on pins 3, 5, 6, 9, 10, and 11.

You don’t need to call pinMode() to set the pin as an output before calling analogWrite().
The analogWrite function has no linkage to the analog pins or the analogRead function.
analogWrite(pin, value)
pin: the pin to write to.
value: the duty cycle: between 0 (always off) and 255 (always on).
Notes and Known Issues
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 – 10) and may result in a value of 0, not fully turning off the output on pins 5 and 6.

Sets the output to the LED proportional to the value read from the potentiometer.
int ledPin = 9;      // LED connected to digital pin 9
int analogPin = 3;   // potentiometer connected to analog pin 3
int val = 0;         // variable to store the read value
void setup(){
pinMode(ledPin, OUTPUT);   // sets the pin as output
void loop(){
val = analogRead(1analogPin);   // read the input pin
analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255

124 Replies to “UNO board IO pin introduction”

  1. Pingback: psiholog
  2. Pingback: Suicide Squad 2
  3. Pingback:
  4. Pingback:
  5. Pingback:
  6. Pingback:
  7. Pingback: KremlinTeam
  8. Pingback: link
  9. Pingback: A3ixW7AS
  10. Here at Leslie’s Pugsland Breeder, Our beautiful fawn pug has given birth to 4 healthy Pug puppies.
    She is our beloved family dog and this is her 1st litter.
    Both mum and dad are AKC registered with 5 gen pedigree certificate. Both from Top Champion bloodlines.Mum and Dad can be seen. Puppies have been wormed weeks 2,4,6,8 and will have had a flea preventative treatment before leaving us.
    They will have their vet check, 1st vaccinations and microchip.
    To view all available puppies and recent pictures, Search us in google as LESLIE’S PUGSLAND BREEDER or click on our website link bellow :

    Pug Puppies for sale | pug for sale near me | pug puppy for sale | pug puppy | pug for sale | pug puppies for sale in va | black pug puppies for sale

  11. Pingback: ukraine
  12. Pingback: vechernyy urgant
  13. Pingback: Porno
  14. Pingback: 66181
  15. Pingback: chernaya vodova
  16. Pingback: blogery_i_dorogi
  17. Pingback: bender na4alo 2021
  18. Pingback:
  19. Pingback: chelovek-iz-90-h
  20. Pingback: is cialis safe
  21. Pingback: rx pharmacy viagra
  22. Pingback: top
  23. Pingback: cialis 20mg usa
  24. Pingback: site
  25. Pingback: Ukrainskie-serialy
  26. Pingback: video
  27. Pingback: topvideos
  28. Pingback:
  29. Pingback: projectio-freid
  30. Pingback: psy2022
  31. Pingback: psy
  32. Pingback: news news news
  33. Pingback: 4569987
  34. Pingback: Zakhar Berkut hd
  35. Pingback: buy cheap cialis
  36. Pingback: viagra
  37. Pingback: Trecator SC
  38. Pingback: viagra substitute
  39. Pingback: cialis and alcohol
  40. Pingback: tadalafil online
  41. Pingback: online cialis
  42. Pingback: help with an essay
  43. Pingback: Glock 19 Gen 5
  44. Pingback: GLOCK 48
  45. Pingback: boyaqq
  46. Pingback: sahabatpoker
  47. Pingback: click this link
  48. Pingback: bai chan online
  49. Pingback: fresh dump
  50. Pingback: Bukit Timah Condo
  51. Pingback: sex toys
  52. Pingback: game pc
  53. Pingback: CBD Spray
  54. Pingback: webbforsenate
  55. Pingback: pptp vpn
  56. Pingback: uniccshop.bazar
  57. Pingback: How to lose weight
  58. Pingback: سایت پوکر
  59. Pingback: weight loss
  60. Pingback: look here
  61. Pingback: cach choi bau cua
  62. Pingback: w888 club
  63. Pingback: W88
  64. Pingback: Attitude Seeds
  65. Pingback: lire l'article
  66. Pingback: additional reading
  67. Pingback: 바카라
  68. Pingback: 먹튀검증
  69. Pingback: tutoring online
  70. Pingback: pr jobs
  71. Pingback: Muschi

Leave a Reply