miércoles, 11 de noviembre de 2015

Arduino [Intro / Introduccion] 00

Arduino [Intro / Introduccion] 00

The Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.. You can tinker with your UNO without worrying too much about doing something wrong, worst case scenario you can replace the chip for a few dollars and start over again.

PWM:  port settings pwm ~

 

Technical specs
Microcontroller
Operating Voltage
5V
Input Voltage (recommended)
7-12V
Input Voltage (limit)
6-20V
Digital I/O Pins
14 (of which 6 provide PWM output)
PWM Digital I/O Pins
6
Analog Input Pins
6
DC Current per I/O Pin
20 mA
DC Current for 3.3V Pin
50 mA
Flash Memory
32 KB (ATmega328P)
of which 0.5 KB used by bootloader
SRAM
2 KB (ATmega328P)
EEPROM
1 KB (ATmega328P)
Clock Speed
16 MHz
Length
68.6 mm
Width
53.4 mm
Weight
25 g

Power: The Uno board can be powered via the USB connection or with an external power supply. The power source is selected automatically.

Memory: The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

Input and Output: See the mapping between Arduino pins and ATmega328P ports. The mapping for the Atmega8, 168, and 328 is identical.

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions.

digitalWrite()

Description: Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) 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. See the digital pins tutorial for more information.

Syntax: digitalWrite(pin, value)

Parameters: pin: the pin number

value: HIGH or LOW



Example

int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
 pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
 digitalWrite(ledPin, HIGH);   // sets the LED on
 delay(1000);                  // waits for a second
 digitalWrite(ledPin, LOW);    // sets the LED off
 delay(1000);                  // waits for a second
}


pinMode()

Description: Configures the specified pin to behave 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.

Syntax: pinMode(pin, mode)

Parameters:

pin: the number of the pin whose mode you wish to set

mode: INPUT, OUTPUT, or INPUT_PULLUP. (see the digital pins page for a more complete description of the functionality.)

Example


int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
 pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
 digitalWrite(ledPin, HIGH);   // sets the LED on
 delay(1000);                  // waits for a second
 digitalWrite(ledPin, LOW);    // sets the LED off
 delay(1000);                  // waits for a second
}


digitalRead()

Description: Reads the value from a specified digital pin, either HIGH or LOW.

Syntax: digitalRead(pin)

Parameters:

pin: the number of the digital pin you want to read (int)

Returns: HIGH or LOW


Example

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
}










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 A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it 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.



Structure


The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.

After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.



Example setup()
int buttonPin = 3;
void setup()
{
 Serial.begin(9600);
 pinMode(buttonPin, INPUT);
}
void loop()
{
 // ...
}

Example loop()
const int buttonPin = 3;
// setup initializes serial and the button pin
void setup()
{
 Serial.begin(9600);
 pinMode(buttonPin, INPUT);
}
// loop checks the button pin each time,
// and will send serial if it is pressed
void loop()
{
 if (digitalRead(buttonPin) == HIGH)
   Serial.write('H');
 else
   Serial.write('L');

 delay(1000);
}








And finally look this tool http://fritzing.org/home/









El Arduino Uno es una placa electrónica basada en el microcontrolador ATmega328P.

Cuenta con 14 pines digitales de entrada / salida (de los cuales 6 se pueden utilizar como salidas PWM), 6 entradas analógicas, un cristal de cuarzo de 16MHz, una conexión USB, un conector de alimentación, una cabecera ICSP y un botón de reinicio. Contiene todo lo necesario para apoyar el microcontrolador; simplemente conectarlo a un ordenador con un cable USB o el poder con un adaptador de CA o la batería a CC para empezar .. Puedes jugar con tu UNO sin preocuparse demasiado por hacer algo mal, peor de los casos puede sustituir la saltar por unos pocos dólares y empezar de nuevo.


Ficha técnica
Microcontroller
Operating Voltage
5V
Input Voltage (recommended)
7-12V
Input Voltage (limit)
6-20V
Digital I/O Pins
14 (of which 6 provide PWM output)
PWM Digital I/O Pins
6
Analog Input Pins
6
DC Current per I/O Pin
20 mA
DC Current for 3.3V Pin
50 mA
Flash Memory
32 KB (ATmega328P)
of which 0.5 KB used by bootloader
SRAM
2 KB (ATmega328P)
EEPROM
1 KB (ATmega328P)
Clock Speed
16 MHz
Length
68.6 mm
Width
53.4 mm
Weight
25 g

0 comentarios:

Publicar un comentario