Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 11336

Criar movimento suave com bitshift operators

$
0
0
Bom, após algumas tentativas e alterações ao código, a coisa ainda não está a funcionar. O código está assim: #include <time.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 10, 9, 8, 7); uint8_t memOffset = 0, dir = 1, col = 0, lin = 0; byte customChar[8] = {0}; void CreatePrintCustomChar(uint8_t memOffset, byte* customChar){ //<-- changed line for(uint8_t i = 0; i < 8; i++) customChar[i] = rand() % 32; lcd.createChar(memOffset, customChar); Serial.println("memOffset:"); Serial.println(memOffset); lcd.write(byte(memOffset)); } void setup(){ srand(time(NULL)); Serial.begin(9600); lcd.begin(20, 4); lcd.setCursor(lin, col); } void loop(){ for(uint8_t i = 0; i < 80; i++){ // lcd.setCursor(lin, col); // Serial.println("Linha:"); // Serial.println(lin); // Serial.println("Coluna:"); // Serial.println(col); // Serial.println("----------\n"); CreatePrintCustomChar(memOffset, customChar); if( !(col % 19) && lin == 3){ col = 0; lin = 0; }else if( col == 19 ){ col = 0; lin++; }else col++; if(dir) memOffset += 1; else memOffset -= 1; if (memOffset < 0) { dir ^= 1; memOffset = 1; }else if (memOffset > 7) { dir ^= 1; memOffset = 6; } delay(500); } } E a variável memOffset está assim:

Viewing all articles
Browse latest Browse all 11336

Trending Articles