Show Posts
|
|
Pages: 1 [2] 3 4 ... 9
|
|
18
|
Using Arduino / Programming Questions / SD Card Read -uint8_t from memory - help
|
on: April 09, 2013, 05:09:34 pm
|
Hello, I have installed an SD formatted to FAT32, and I am reading a txt file with data 0-255. the problem is not how to read these numbers, because the function that reads, memory reads as bytes. "read ()" #include <SPI.h> #include <SD.h>
File myFile;
union { // This Data structure lets byte asBytes[4]; // us take the byte array uint8_t asint[1]; // sent from processing and } // easily convert it to a foo;
void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
Serial.print("Initializing SD card..."); pinMode(10, OUTPUT); if (!SD.begin(10)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); myFile = SD.open("data/R0.txt"); if (myFile) { for(int i=0;i<1;i++){ int index=0; while(index<4) { foo.asBytes[index] = myFile.read(); Serial.println(foo.asBytes[index]);
index++;
} if(index==4 ) { Serial.println(foo.asint[0]);
} } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } }
void loop() { // nothing happens after setup }
I was reading in this way, but the serial port from the processing. but I think that happens to be similar, but not them. / / data from txt this: 184,179,179,179,179,179,179,179,179,179,179,179,179,179,179,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,
|
|
|
|
|
19
|
International / Software / SD Card leer -uint8_t desde la memoria--help
|
on: April 09, 2013, 04:43:13 pm
|
Hola, tengo instalado una SD formateada a Fat32, y estoy leyendo un archivo txt, con data entre 0-255. el problema que no se como leer estos numeros, ya que la funcion que lee ,hacede a la memoria los lee como bytes. "read()" #include <SPI.h> #include <SD.h>
File myFile;
union { // This Data structure lets byte asBytes[4]; // us take the byte array uint8_t asint[1]; // sent from processing and } // easily convert it to a foo;
void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
Serial.print("Initializing SD card..."); pinMode(10, OUTPUT); if (!SD.begin(10)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); myFile = SD.open("data/R0.txt"); if (myFile) { for(int i=0;i<1;i++){ int index=0; while(index<4) { foo.asBytes[index] = myFile.read(); Serial.println(foo.asBytes[index]);
index++;
} if(index==4 ) { Serial.println(foo.asint[0]);
} } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } }
void loop() { // nothing happens after setup }
yo venia leyendo de esta forma, pero por el puerto serial desde el processing. pero no que pasa yo creo debe ser similar, pero no consigo. //data del txt de esta forma: 184,179,179,179,179,179,179,179,179,179,179,179,179,179,179,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,
|
|
|
|
|
20
|
Using Arduino / LEDs and Multiplexing / Re: WS2803 versus WS2801
|
on: March 31, 2013, 11:49:14 pm
|
|
good, so long as you start this project.
I have a problem and do not know how to fix it. the problem is the issue of data storage.
for example, for an image of 24bits generarar, I have 3bytes separately for RGB. the image is 54 * 360Pixels. LedsRGB 54, which R for a single channel, the data amount is 19440.
arduino which says that I have occupied 74% of the memory.
Would there be any way to store this data in a more efficient? one could compress the image and then decompress when painting?
uint8_t R [] = {number of data = 19440}. uint8_t G [] = {249,149,49,149,149,249,449, ............................ amount of data = 19440} uint8_t B [] = {}
|
|
|
|
|
23
|
International / Software / funcion :millis()- help
|
on: March 29, 2013, 11:06:45 pm
|
|
buenas, se cuando se invoca a esta funcion no para de contar el time . y cuando se la invoca de nuevo te da el tiempo que trancurrio. valga la redudancia.
pero.. puedo hacer que deje de contar ??, que solo tome el tiempo o empiese a contar ,cuando yo le pida , una especie de pause o stop.
|
|
|
|
|
24
|
International / Software / Re: Partir cadena (char)
|
on: March 20, 2013, 12:06:32 pm
|
|
que tenes conEctado ?? ETHERNET ??
ALGO ASI ESTAS LEYENDO ??
if (client.available()) { char c = client.read(); Serial.print(c); }
NO SE POQUE PUBLICAS UN ARRAY CUANDDO NO LO TENIAS
|
|
|
|
|
25
|
Development / Suggestions for the Arduino Project / Re: Watchdog in Arduino Library - or at least support by bootloader
|
on: March 19, 2013, 08:04:02 pm
|
hello, I need the strech by bluetooth shit, and I get it, but I must be attentive to press the reset arduino-one. when bleutooch connects, there squeezed reset and this loads the strech. I tried to use the wacthdog, when this is connected to a reset, but I can not load the strech, someone has done something similar to what comment? #include <avr/wdt.h>
int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by void setup () { Serial.begin (115200); pinMode(led, OUTPUT);
// Serial.println ("Restarted."); while(!Serial){ ; } wdt_reset (); wdt_disable();
} // end of setup
void loop () {
analogWrite(led, brightness);
// change the brightness for next time through the loop: brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30);
} // end of loop
http://www.ebay.com/itm/Wireless-Bluetooth-Transceiver-Module-RS232-TTL-/200520318414?_trksid=p2047675.m1850&_trkparms=aid%3D222002%26algo%3DSIC.FIT%26ao%3D1%26asc%3D11%26meid%3D6299423035725889752%26pid%3D100011%26prg%3D1005%26rk%3D4%26sd%3D320968741708%26
|
|
|
|
|
26
|
International / Software / Re: Partir cadena (char)
|
on: March 19, 2013, 06:57:45 pm
|
#include <String.h>
void setup() {
Serial.begin(9600); char str[] = "uno;dos;tres;cuatro;"; char *pch; int i=0; pch = strtok (str,";"); String buff[sizeof(str)]; while (pch != NULL) { buff[i]=(pch); pch = strtok (NULL, ";");i++; } for(int x=0;x<i;x++){ Serial.println( buff[x]); } i=0;
}
void loop () {
} By Omni
|
|
|
|
|
27
|
International / Software / Re: Operaciones con float
|
on: March 19, 2013, 01:49:30 pm
|
|
podria ser desbordamiento de variable o algo asi se llama, es decir por ejemplo si tienes un variable de tipo int y un uint8_t
int a= 300; uint8_t b ; b=a;
como el el tipo uint8_t usa solo un byte , es decir 0-255, y el tipo int usa dos bytes de range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).
es claro si pongo el 300 al uint8_t, no calza por lo que se desvorda y te coloca por ejmplo 20, o algo asi.
tambien debes tener en cuenta que si pones un float en un int siempre hay trucamiento, no aprace la parte decimal
|
|
|
|
|
28
|
International / Software / Re: Partir cadena (char)
|
on: March 19, 2013, 01:16:27 pm
|
debes buscar una funcion slip o parecido, lo que hace es buscar un delimitadorr , en tu caso es el ' ;' y te se lo separa para este caso encontre pero para string, deberias convertir el cgar a string. void setup() { // put your setup code here, to run once:
}
void loop() { // put your main code here, to run repeatedly: String split = "hi this is a split test";
String word3 = getValue(split, ' ', 2); Serial.println(word3);
}
String getValue(String data, char separator, int index) { int found = 0; int strIndex[] = {0, -1}; int maxIndex = data.length()-1;
for(int i=0; i<=maxIndex && found<=index; i++){ if(data.charAt(i)==separator || i==maxIndex){ found++; strIndex[0] = strIndex[1]+1; strIndex[1] = (i == maxIndex) ? i+1 : i; } }
return found>index ? data.substring(strIndex[0], strIndex[1]) : ""; }
|
|
|
|
|
30
|
International / Software / Re: Solo para mentes creativas
|
on: March 19, 2013, 10:49:01 am
|
|
men asi como lo describes no se puede. porque si el boton esta apagado, por mas que actives la salida por sofware no se completa el circuito.
como describes en tu titulo, ponete a pensar un poco usted, asi no vas a nigun lado
|
|
|
|
|