Sunteți pe pagina 1din 24

CENTRO INDUSTRIAL DE

MANTENIMIENTO INTEGRAL
CIMI

GC-F-004 V.01
INSTRUCCIONES EN
BÁSICAS
GC-F--004
GC-F-004 V.01
ARDUINO
https://create.arduino.cc/
https://www.arduino.cc/

GC-F-004 V.01
ESTRUCTURA DE UN SCRIPT

void setup()
{ Espacio para Configuraciones en
la placa.
}

void loop()
{
Espacio para el código.
}
Fuente: https://www.arduino.cc/ GC-F-004 V.01
DIGITAL INPUT/ OUTPUT

Letra correspondiente al puerto


(A,B,C,D,E,F,G,H)

1 para Salidas
DDRx=0x0F; 0 Para Entradas

Fuente: https://www.arduino.cc/ GC-F-004 V.01


DIGITAL INPUT/ OUTPUT
Configuración
OUTPUT/INPUT

# del Pin en la placa

pinMode(x,OUTPUT);

Fuente: https://www.arduino.cc/ GC-F-004 V.01


DIGITAL INPUT/ OUTPUT

Letra correspondiente al puerto


(A,B,C,D,E,F,G,H)

1 = 5V
PORTx=0x0F; 0 = 0V

Fuente: https://www.arduino.cc/ GC-F-004 V.01


DIGITAL INPUT/ OUTPUT

# del Pin en la placa

digitalWrite(x,x);
1 o HIGH=5V
0 o LOW=0V

Fuente: https://www.arduino.cc/ GC-F-004 V.01


EJEMPLOS DE I/O

void setup() void setup()


{ {
DDRB=0xFF; pinMode(x,OUTPUT);
} }

void loop() void loop()


{ {
PORT=0xFF; digitalWrite(13,HIGH);
} }
Fuente: https://www.arduino.cc/ GC-F-004 V.01
DIGITAL INPUT/ OUTPUT

# del Pin en la placa

digitalRead(x);

Fuente: https://www.arduino.cc/ GC-F-004 V.01


EJEMPLOS DE I/O
int led=13;
int pin=7;
int val=0;

void setup()
{
pinMode(pin,INPUT);
pinMode(led,OUTPUT);

void loop()
{
val=digitalRead(pin,HIGH);
digitalWrite(led,val);
}
Fuente: https://www.arduino.cc/ GC-F-004 V.01
INSTRUCCIONES DE RETARDO

Unsigned int

delay(x);
delayMicroseconds(x);
Unsigned int

Fuente: https://www.arduino.cc/ GC-F-004 V.01


OPERADORES ARITMETICOS

= (assignment operator)
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulo)

Fuente: https://www.arduino.cc/ GC-F-004 V.01


OPERADORES DE COMPARACIÓN

== (equal to)
!= (not equal to)
< (less than)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)

Fuente: https://www.arduino.cc/ GC-F-004 V.01


OPERADORES DE LÓGICOS

&& (and)
|| (or)
! (not)

Fuente: https://www.arduino.cc/ GC-F-004 V.01


OPERADORES COMPUESTOS

++ (increment)
-- (decrement)
+= (compound addition)
-= (compound subtraction)
*= (compound multiplication)
/= (compound division)
%= (compound modulo)
&= (compound bitwise and)
|= (compound bitwise or)
Fuente: https://www.arduino.cc/ GC-F-004 V.01
EJEMPLOS

x += y; // equivalent to the expression x = x + y;


x -= y; // equivalent to the expression x = x - y;
x *= y; // equivalent to the expression x = x * y;
x /= y; // equivalent to the expression x = x / y;
x %= y; // equivalent to the expression x = x % y;

Fuente: https://www.arduino.cc/ GC-F-004 V.01


ESTRUCTURAS DE CONTROL
if ( )
{
Sentencia A
if ( )
{ }
Sentencia
else
{
} Sentencia B

}
Fuente: https://www.arduino.cc/ GC-F-004 V.01
ESTRUCTURAS DE CONTROL
if ( )
{
Sentencia A
}
else if ( )
{
Sentencia B
}
else
{
Sentencia C
}
Fuente: https://www.arduino.cc/ GC-F-004 V.01
ESTRUCTURAS DE CONTROL
while( )
{
Sentencia
}
int A=1; int A=0;
while(A) while(A<200)
{ {
Serial.print('A'); A++;
} }
Fuente: https://www.arduino.cc/ GC-F-004 V.01
PUERTO SERIAL
Cantidad de bps

Serial.begin(XXXX);
Valor a visualizar

Serial.print(XXXX);
Fuente: https://www.arduino.cc/ GC-F-004 V.01
EJEMPLOS DE SERIAL MONITOR

void setup() void setup()


{ {
Serial.begin(9600); Serial.begin(9600);
} }

void loop() void loop()


{ {
Serial.print('A'); Serial.println('A');
} }
Fuente: https://www.arduino.cc/ GC-F-004 V.01
EJEMPLOS DE SERIAL MONITOR
int dato = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
if (Serial.available() > 0)
{
dato = Serial.read();
Serial.print(“Recibiendo: ");
Serial.println(dato, DEC);
}
} Fuente: https://www.arduino.cc/ GC-F-004 V.01
GRACIAS
GC-F--004
GC-F-004 V.01

S-ar putea să vă placă și