Estructura y flujo
Estructura básica del programa
void setup() {
71 Corre una vez cuando el
77 programa inicia
3
Void Loop) £
11 Se ejecuta reperidanente
Estructuras de control
if <5) Con, à ee {
title el
Bo...) mile (x <5):
for (int 4 2 05 4 < 18; 48e) (u...)
break; //sate se bucle Imesiatonente
Suite (nivariable) {
case I
Breaks
case 2
break
defaut
>
return x; // 0 *return;* para vacíos
Operadores
Operadores generales
operador de asignación)
(adición) =" (sustracción)
(auttipticacién)
(división) N (ndaulo)
igual a) 1 (desiguat a)
(enor que) > (mayor que)
(igual 0 menor que)
(eayor o igual que)
I! (negacien)
Operadores compuesten
(decremento)
(suma conpuesta)
(resta compuesta)
(mottipLicación compuesta)
(Slvisión compuesta)
(40 binario compuesto)
(OR binario Compuesto)
Operadores a nivel de bit
& (AO binario) | (OR binario)
= (OR binarie) (NOT binario)
<< (desplazamiento a la Izquierdo)
5 (desplazamiento a 1a derecha)
Variables, vectores y datos
Tipos de datos
void vacio
boolean (0, 1, true, false)
char (ej, la? 128-9 127)
int (732068 à 32967)
Yong (2147483648 a 2147483647)
unsigned char. (0 a 255)
byte 255)
(0 à 65535)
(0 à 65535)
unsigned Long, (0 a 4294967205)
Float (-3.40280138 à 3.40280+38)
double (igual que tos flatantes)
Calificadores.
static //persiste entre Uonadas
Wolatite //052 1a RAN
const" 115810 lectura
PROG //usar la lash
Vectores y matrices
int aylnts[6]; /Jvector de 6 enteros
int meinst (2, 4, 8, 3, 6)
int mySensvals[6j={2, 4, -8, 3, 2);
mints[oled2; //osigno at prinero
mints[6le12; Tremor: EX indice vo
constants
man | Lo
UT | OUTPUT
true | false
15 //Pecinat
0173 7/0etat(conenzando en 6)
nenn //Binario
GB (Mex (hexadecimat)
m ‘Uforzar unsigned
1 //ferzar ong
1SüL //forzar Long unsigned
xo. ‘U/forzar Hosting posnt
2aes 17240009
Punteros.
& (referencia: obtener puntero)
= ator: seguir puntero)
Cadenas
char S118) =
CA Usa}:
‘eaten sin’ terminación
Hipuese producir error
char S218) =
ATACAN E
[/sneaye terminación nula Y
char S3[)="arduino"
char SAÍ8J="arduino"
Funciones
ES Digital
PinfodeLpin, INPUT, OUTPUT))
figitatwrite(pin, valor)
int digitatresd(psn)
Escribe HIGH en entrados para
Par Vos putt-ups
EIS Analógicas
analogheterence( (DEFAULT,
TINTERUAL,EXTERNAL])
nt anatogRead(pin)
anatogurite(pin, valor) //Pt
Advanced 10
‘one(pin, Freghz)
tone(pin, Freghz, duracion ns)
moTone pin)
Shirtout(pirdatos, pinkelo),
(NSBFIRST,LSBFIASTI, valor)
unsigned Long pulsetnipin,
(HIGH, LOW)
Tiempo,
unsigned Long mitlist)
//destardaniento en 50 dias.
unsigned Long micros()
//destordantento en 70 minutos
delay (es)
‘elayticroseconds(us)
incluídas
Matemáticas
mind, y) mex(x, y) abst)
Sin(rod) cos(raó) tan(rad)
sart(0_ pomíbase, exponente)
constrain(x, valtin, val)
maplval, deBAJO, JeALTO
38400, Otto)
Números aleatorios
randonSeed(sesi1la) //Long 6 int
Tong randoa(eax)
Long randentain, max)
Bits y Bytes
Yow@yte()_highoyte(x)
bieReodtx, bien)
biturite(s, itn, bit)
Bitserix, bita)
Bitclearix, itn)
Bit(bitn) 77 Bitn: OLSB 7468
Conversiones.
ar bytel)
into) werd)
Vongt) float)
interrupciones Externas.
etachinterrupt(interrup, func,
LOW, CHANCE, RISING, FALLING])
detachinterrupt(interrupcién)
rterrupts()
olnterrupts()
ra own)
Bibliotecas
Serie
begint1300, 1200. 2400, 4800,
3006, 14460. 19200, 26000
38006, 57606, 1182601)
(fede ser cialguier número
end)
‘nt avaitabte()
byte read’)
Byte packt)
Flash)
Print (aisbatos)
Printin(eisbatos)
Er (nisaytes)
EEPROM (include <EEPROA. ho)
byte read(dirinterna)
welte(airinterna, aldyte)
Servo (#include Servo.)
attach(pin, [min uS, max 45))
weite(anguio) // 8, 180
riteNicroseconds (LS)
7/1886-2000; 1500 es en medio
read) 4/0 188
attached() //regresa boleano
detach()
SofewareserialfRxin, TIN)
(include <ofbareSerial.19)
begin(long velocidad) //hasta 9600
char read) //espera Los datos.
printínisbatos)
Printin(eisbatos)
Wire (#inelude <tire.he) lpara PC
begin) 7/50 one » estro
Begin(addr) Use une a esclavo estr
requestrrom(dirección, cuenta)
begintransmission(dir) // Paso 1
send(niByte) 17 Paso 2
Send(char * miCadena)
Send(byte * datos, tasaño)
endtransmission!) // Paso 3
byte availabte() 77 mn de bytes
byte receiver) //negresa el sig byte
OnReceive(sonejador)
OnRegquest (sanejador)
por Mark Liffiton
‘Taduccién de Antonio Maldonado
Adaptado de
Idea original por Gavin Smith
Versión SVG por Frederic Dufourg
Dibujo del rduno de Frizing rg