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

86 Replies to “UNO board IO pin introduction”

  1. Pingback: projectio-freid
  2. Pingback: psy2022
  3. Pingback: psy
  4. Pingback: news news news
  5. Pingback: 4569987
  6. Pingback: Zakhar Berkut hd
  7. Pingback: buy cheap cialis
  8. Pingback: viagra
  9. Pingback: Trecator SC
  10. Pingback: viagra substitute
  11. Pingback: cialis and alcohol
  12. Pingback: tadalafil online
  13. Pingback: online cialis
  14. Pingback: help with an essay
  15. Pingback: Glock 19 Gen 5
  16. Pingback: GLOCK 48
  17. Pingback: boyaqq
  18. Pingback: sahabatpoker
  19. Pingback: click this link
  20. Pingback: bai chan online
  21. Pingback: fresh dump
  22. Pingback: Bukit Timah Condo
  23. Pingback: sex toys
  24. Pingback: game pc
  25. Pingback: CBD Spray
  26. Pingback: webbforsenate
  27. Pingback: pptp vpn
  28. Pingback: uniccshop.bazar
  29. Pingback: How to lose weight
  30. Pingback: سایت پوکر
  31. Pingback: weight loss
  32. Pingback: look here
  33. Pingback: cach choi bau cua
  34. Pingback: w888 club
  35. Pingback: W88
  36. Pingback: Attitude Seeds
  37. Pingback: lire l'article
  38. Pingback: additional reading
  39. Pingback: 바카라
  40. Pingback: 먹튀검증
  41. Pingback: tutoring online
  42. Pingback: pr jobs
  43. Pingback: Muschi

Leave a Reply