Diferencia entre revisiones de «byte()»

De ArduWiki
Saltar a: navegación, buscar
(Vea también)
 
(No se muestran 6 ediciones intermedias del mismo usuario)
Línea 14: Línea 14:
  
 
== Advertencias ==
 
== Advertencias ==
Nada.
+
No funciona con cadenas [[string]] ni objetos [[String]].
  
 
== Ejemplo ==
 
== Ejemplo ==
 
<syntaxhighlight lang="c++">
 
<syntaxhighlight lang="c++">
 +
char a = 'A';
 +
byte b = 123;
 +
 +
void setup(){
 +
  Serial.begin(9600);
 +
 +
  byte valor1 = byte(a);
 +
  Serial.println(valor1);        //65
 +
 +
  int valor2 = long(b);
 +
  Serial.println(valor2);        //123
 +
 +
  unsigned int valor3 = word(b); //123
 +
  Serial.println(valor3);
 +
 +
  long valor4 = long(b);        //123
 +
  Serial.println(valor4);
 +
}
 +
 +
void loop(){
 +
  //Nada.
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Vea también ==
 
== Vea también ==
* [[int()]]
+
<categorytree mode=all>Funciones conversion</categorytree>
* [[long()]]
 
* [[float()]]
 
* [[char()]]
 
* [[toInt()]]
 
* [[getBytes()]]
 
  
== Referencias ==
+
== Referencias externas ==
 
* [https://www.arduino.cc/reference/es/language/functions/time/millis/ Guia de referencia de Arduino]
 
* [https://www.arduino.cc/reference/es/language/functions/time/millis/ Guia de referencia de Arduino]
  
[[Category:Funciones]]
+
[[Category:Funciones conversion]]

Revisión actual del 19:45 11 jun 2019

Descripción

Convierte un valor en un dato tipo byte.

Sintaxis

byte(variable);

Parametros

variable
una variable de tipo String.

Retorna

Retorna un numero tipo byte.

Advertencias

No funciona con cadenas string ni objetos String.

Ejemplo

char a = 'A';
byte b = 123;

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

   byte valor1 = byte(a);
   Serial.println(valor1);         //65

   int valor2 = long(b);
   Serial.println(valor2);        //123

   unsigned int valor3 = word(b); //123
   Serial.println(valor3);

   long valor4 = long(b);         //123
   Serial.println(valor4); 
}
 
void loop(){
   //Nada.
}

Vea también


Referencias externas