This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › for (i=0; i<7; i=i+1)

 Pages: 1 2
 for (i=0; i<7; i=i+1) (Read 57448 times)
 Reply #15 - 11/29/05 at 00:37:26
 boppyer   Offline YaBB Newbies London Posts: 39
 Cheers David, it's works brilliantly much appreciated   IP Logged
 Reply #16 - 07/28/10 at 22:20:39
 Tiago_D   Offline YaBB Newbies Posts: 7
 hi i made this function to scroll the text in my code for my Matrix, everything works as it should be but there is a space between letters that I wanted to remove i tried everything but I do not know what to doI'm a little inexperienced in programming and therefore normal that the code is not best donesomeone can help me please?sorry my bad english. Code:```void scroll (Sprite ch) { for(int i=-8;i<=8;i++) { myMatrix.write(1, i, ch); myMatrix.write(1 - 8, i, ch); delay(200); myMatrix.clear(); } } ```   IP Logged
 Reply #17 - 07/28/10 at 22:52:34
 barragan   Offline YaBB Administrator Posts: 939
 Could you please post your complete code? I cant´t see what you´re doing. This example might be a reference: http://wiring.org.co/learning/libraries/spriteanimation.html   IP Logged
 Reply #18 - 07/29/10 at 00:26:05
 Tiago_D   Offline YaBB Newbies Posts: 7
 1ªpart Code:```#include #include /* create a new Matrix instance pin 0: data (din) pin 1: load (load) pin 2: clock (clk) */ Matrix myMatrix = Matrix(10, 12, 11,1); //letras (acabar de escrever todas) Sprite letra_A = Sprite(8,8, B11110000, B00101000, B00100100, B00100010, B00100100, B00101000, B11110000, B00000000 ); Sprite letra_B = Sprite(8,8, B10000010, B11111110, B10010010, B10010010, B10010010, B10010010, B01101100, B00000000 ); Sprite letra_C = Sprite(8,8, B00111000, B01000100, B10000010, B10000010, B10000010, B10000010, B10000010, B00000000 ); Sprite letra_D = Sprite(8,8, B10000010, B11111110, B10000010, B10000010, B10000010, B01000100, B00111000, B00000000 ); Sprite letra_E = Sprite(8,8, B11111110, B10010010, B10010010, B10010010, B10010010, B10000010, B10000010, B00000000 ); Sprite letra_F = Sprite(8,8, B11111110, B00010010, B00010010, B00010010, B00010010, B00000010, B00000010, B00000000 ); Sprite letra_G = Sprite(8,8, B00111000, B01000100, B10000010, B10010010, B10010010, B10010010, B11110010, B00000000 ); Sprite letra_H = Sprite(8,8, B11111110, B00010000, B00010000, B00010000, B00010000, B00010000, B11111110, B00000000 ); Sprite letra_I = Sprite(8,8, B10000010, B10000010, B10000010, B11111110, B10000010, B10000010, B10000010, B00000000 ); Sprite letra_J = Sprite(8,8, B01000000, B10000000, B10000000, B10000010, B10000010, B10000010, B01111110, B00000000 ); Sprite letra_K = Sprite( B11111110, B00010000, B00010000, B00101000, B01000100, B10000010, B10000010, B00000000 ); Sprite letra_L = Sprite(8,8, B11111110, B10000000, B10000000, B10000000, B10000000, B10000000, B10000000, B00000000 ); Sprite letra_M = Sprite(8,8, B11111110, B00000010, B00000010, B00001100, B00000010, B00000010, B11111110, B00000000 ); Sprite letra_N = Sprite(8,8, B11111110, B00000100, B00001000, B00010000, B00100000, B01000000, B11111110, B00000000 ); Sprite letra_O = Sprite(8,8, B00111000, B01000100, B10000010, B10000010, B10000010, B01000100, B00111000, B00000000 ); Sprite letra_P = Sprite(8,8, B00000010, B11111110, B00010010, B00010010, B00010010, B00010010, B00001100, B00000000 ); Sprite letra_Q = Sprite(8,8, B00111000, B01000100, B10000010, B10000010, B10100010, B01000100, B10111000, B00000000 ); Sprite letra_R = Sprite(8,8, B00000010, B11111110, B00000010, B00010010, B00110010, B01010010, B10001100, B00000000 ); Sprite letra_S = Sprite(8,8, B10001100, B10010010, B10010010, B10010010, B10010010, B10010010, B01100010, B00000000 ); Sprite letra_T = Sprite(8,8, B00000010, B00000010, B00000010, B11111110, B00000010, B00000010, B00000010, B00000000 ); Sprite letra_U = Sprite(8,8, B01111110, B10000000, B10000000, B10000000, B10000000, B10000000, B01111110, B00000000 ); Sprite letra_V = Sprite(8,8, B00011110, B00100000, B01000000, B10000000, B01000000, B00100000, B00011110, B00000000 ); Sprite letra_W = Sprite(8,8, B01111110, B10000000, B10000000, B01111100, B10000000, B10000000, B01111110, B00000000 ); Sprite letra_X = Sprite(8,8, B10000010, B01000100, B00101000, B00010000, B00101000, B01000100, B10000010, B00000000 ); Sprite letra_Y = Sprite(8,8, B00000010, B00000100, B00001000, B11110000, B00001000, B00000100, B00000010, B00000000 ); Sprite letra_Z = Sprite(8,8, B10000010, B11010010, B10110010, B10010010, B10011010, B10010110, B10000010, B00000000 ); //numeros Sprite numero_1 = Sprite(8,8, B00000000, B00000000, B10000000, B11111111, B10000010, B00000000, B00000000, B00000000 ); Sprite numero_2 = Sprite(8,8, B00000000, B10000110, B10001001, B10010001, B10100001, B11000001, B10000110, B00000000 ); Sprite numero_3 = Sprite(8,8, B00000000, B01111100, B10010010, B10010010, B10010010, B10000010, B10000010, B00000000 ); Sprite numero_4 = Sprite(8,8, B00000000, B11111111, B00010000, B00010000, B00010000, B00010000, B00011111, B00000000 ); Sprite numero_5 = Sprite(8,8, B00000000, B01001111, B10001001, B10001001, B10001001, B10001001, B01110001, B00000000 ); Sprite numero_6 = Sprite(8,8, B00000000, B01111110, B10001001, B10001001, B10001001, B10001001, B01110010, B00000000 ); Sprite numero_7 = Sprite(8,8, B00000000, B00000111, B00001001, B00010001, B00100001, B11000001, B00000001, B00000000 ); Sprite numero_8 = Sprite(8,8, B00000000, B01101100, B10010010, B10010010, B10010010, B10010010, B01101100, B00000000 ); Sprite numero_9 = Sprite(8,8, B00000000, B01111110, B10001001, B10001001, B10001001, B10001001, B01000110, B00000000 ); Sprite numero_0 = Sprite(8,8, B00000000, B01111110, B11000001, B10010001, B10001001, B10000011, B01111110, B00000000 ); //simbolos Sprite simbolo_ponto = Sprite(8,8, B00000000, B00000000, B00000000, B11000000, B11000000, B00000000, B00000000, B00000000 ); Sprite simbolo_traco = Sprite(8,8, B00000000, B00000000, B00000000, B01111100, B01111100, B00000000, B00000000, B00000000 ); void setup() { myMatrix.setBrightness(10); //intencidade da matriz } void scroll (Sprite ch) //scroll do texto (com problemas) { for(int i=-8;i<=8;i++) { myMatrix.write(1, i, ch); myMatrix.write(1 - 8, i, ch); delay(200); myMatrix.clear(); } } ```   IP Logged
 Reply #19 - 07/29/10 at 00:27:10
 Tiago_D   Offline YaBB Newbies Posts: 7
 2ªpart Code:```void scrollString(char * s) //passagem por parametros das letras para a função scroll { int i=0; while(s[i]) { //letras if(s[i]== 'a') scroll(letra_A); if(s[i]== 'b') scroll(letra_B); if(s[i]== 'c') scroll(letra_C); if(s[i]== 'd') scroll(letra_D); if(s[i]== 'e') scroll(letra_E); if(s[i]== 'f') scroll(letra_F); if(s[i]== 'g') scroll(letra_G); if(s[i]== 'h') scroll(letra_H); if(s[i]== 'i') scroll(letra_I); if(s[i]== 'j') scroll(letra_J); if(s[i]== 'k') scroll(letra_K); if(s[i]== 'l') scroll(letra_L); if(s[i]== 'm') scroll(letra_M); if(s[i]== 'n') scroll(letra_N); if(s[i]== 'o') scroll(letra_O); if(s[i]== 'p') scroll(letra_P); if(s[i]== 'q') scroll(letra_Q); if(s[i]== 'r') scroll(letra_R); if(s[i]== 's') scroll(letra_S); if(s[i]== 't') scroll(letra_T); if(s[i]== 'u') scroll(letra_U); if(s[i]== 'v') scroll(letra_V); if(s[i]== 'x') scroll(letra_X); if(s[i]== 'y') scroll(letra_Y); if(s[i]== 'z') scroll(letra_Z); //numeros if(s[i]== '1') scroll(numero_1); if(s[i]== '2') scroll(numero_2); if(s[i]== '3') scroll(numero_3); if(s[i]== '4') scroll(numero_4); if(s[i]== '5') scroll(numero_5); if(s[i]== '6') scroll(numero_6); if(s[i]== '7') scroll(numero_7); if(s[i]== '8') scroll(numero_8); if(s[i]== '9') scroll(numero_9); if(s[i]== '0') scroll(numero_0); //simbolos if(s[i]== '.') scroll(simbolo_ponto); if(s[i]== '-') scroll(simbolo_traco); i++; } } void loop () { scrollString("abcdfghijklmnopkrstuvwxyz123456789"); //onde se insere a palavra letras ou numeros } ```   IP Logged
 Reply #20 - 07/29/10 at 00:55:15
 barragan   Offline YaBB Administrator Posts: 939
 cual es el problema que estás tendiendo exactamente?   IP Logged
 Reply #21 - 07/29/10 at 01:33:44
 Tiago_D   Offline YaBB Newbies Posts: 7
 http://www.youtube.com/watch?v=lM_22OGfx-Qsee the video is more easy and that the problem can not remove the space between letters   IP Logged
 Reply #22 - 07/29/10 at 02:41:36
 barragan   Offline YaBB Administrator Posts: 939
 drawing always in position 1 and 7 (1-8)?myMatrix.write(1, i, ch);myMatrix.write(1 - 8, i, ch);   IP Logged
 Reply #23 - 07/29/10 at 03:00:15
 Tiago_D   Offline YaBB Newbies Posts: 7
 I based myself in this code Code:```#include #include #include Matrix myMatrix = Matrix(0, 2, 1); /* create a new Sprite instance 8 pixels wide, 4 pixels tall */ Sprite wave = Sprite( 8, 4, B00011000, B00100100, B01000010, B10000001 ); void setup() { } int x = 0; void loop() { myMatrix.write(x, 2, wave); // place sprite on screen myMatrix.write(x - 8, 2, wave); // place sprite again, elsewhere on screen delay(75); // wait a little bit myMatrix.clear(); // clear the screen for next animation frame if(x == 8) // if reached end of animation sequence { x = 0; // start from beginning } x++; // advance x coordinate to the right } ```   IP Logged
 Reply #24 - 07/29/10 at 03:01:10
 barragan   Offline YaBB Administrator Posts: 939
 I see, but as you can see x is changing for moving the sprite, in your case it is fixed.   IP Logged
 Reply #25 - 07/29/10 at 03:23:26
 Tiago_D   Offline YaBB Newbies Posts: 7
 yes I am using i to sprite I'm changing the position of y for sprite text   IP Logged
 Reply #26 - 07/29/10 at 06:31:37
 barragan   Offline YaBB Administrator Posts: 939
 then it should be something like myMatrix.write(1, i, ch); myMatrix.write(1, i-8, ch); ?   IP Logged
 Reply #27 - 07/29/10 at 14:19:37
 Tiago_D   Offline YaBB Newbies Posts: 7
 still not working well thanks anyway but I will try to resolve it if I can't I come back here to postthanks for the help   IP Logged
 Pages: 1 2