see analog value with cdc

51 views
Skip to first unread message

christian valdivieso

unread,
Dec 17, 2013, 1:08:09 PM12/17/13
to pingui...@googlegroups.com
To watch the value of reading the analog input into a penguin and so we need to calibrate the value I have this code below.

The value is always less than 1024, then to an integer, we separate the last 4 digits and join in a character vector and finally we sent by CDC.

#define entrada 13 //analogic entry

char arreglo[3]; //character vector

int numero;

void setup(){

}

void loop() {

numero = analogRead(entrada);

arreglo[0]=48+(numero/1000);

arreglo[1]=48+((numero/100)%10);

arreglo[2]=48+((numero/10)%10);

arreglo[3]=48+(numero%10);

CDC.print(arreglo,4);

//CDC.print("\n",2);

delay(1000);

}

Sergio Alvarez

unread,
Dec 18, 2013, 8:47:28 AM12/18/13
to pingui...@googlegroups.com
hola
Debes arreglar el dimensionamiento  del arreglo (o vector) con capacidad para 4 elementos.
You should fix the array declaration. You have 4 elements

char arreglo[4]; //character vector


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Pinguino.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse pinguinocard...@googlegroups.com.
Pour envoyer un message à ce groupe, adressez un e-mail à pingui...@googlegroups.com.
Visitez ce groupe à l'adresse http://groups.google.com/group/pinguinocard .
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .

Reply all
Reply to author
Forward
0 new messages