Well actually the code I wrote does work and I DO have to create every char because they are 3 different drawings of an arrow.
so the part:
byte arrowA1[8] = {B00000,B11000,B10100,B10010,B10010,B10100,B11000,B00000};
byte arrowA2[8] = {B00000,B00000,B11000,B10110,B10110,B11000,B00000,B00000};
byte arrowA3[8] = {B00000,B00000,B00000,B11110,B11110,B00000,B00000,B00000};
has to stay.
It is the part where I try to put the chars on the LCD I want to simplify. I tried this, but it doesn't work:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte x = 0; //set row on LCD
byte y = 0; // set column on LCD
int z = 250; // set animation speed (actual the delay between each frame of the animation)
byte arrowA1[8] = {B00000,B11000,B10100,B10010,B10010,B10100,B11000,B00000}; // set up arrow 1
byte arrowA2[8] = {B00000,B00000,B11000,B10110,B10110,B11000,B00000,B00000}; // set up arrow 2
byte arrowA3[8] = {B00000,B00000,B00000,B11110,B11110,B00000,B00000,B00000}; // set up arrow 3
byte arrowA[]={1,2,3,2}; // set up each animation step: arrow 1, arrow 2, arrow 3, arrow 2
int character = 0; // set up the character number (we can only have 8 characters at the same time on the display, but now we only need one, 0 in this case)
void setup() {
lcd.begin(16, 2);
}
void loop() {
for(int i=0; i<3; i++)
{
lcd.clear();
lcd.createChar(character, arrowA[i]); //here we actually create the character on position character
lcd.setCursor(x,y); // here we set the cursor on location x and y (row and column)
lcd.write(character); // write the "characterpos" we defined in lcd.createChar to the LCD
delay(z); // wait for z millisecs
}
normally the
for(int i=0; i<3; i++)
should write each arrow on the same location with a delay of 250 millisecs and do this accordingly to
byte arrowA[]={1,2,3,2};
this should be: arrowA1, arrowA2, arrowA3, arrowA2, but it gives me:
sketch_mar07a.cpp: In function 'void rotatingarrow()':
sketch_mar07a:16: error: invalid conversion from 'int' to 'uint8_t*'
sketch_mar07a:16: error: initializing argument 2 of 'void LiquidCrystal::createChar(uint8_t, uint8_t*)'
one would think arrowA[] would be replaced by 1 then 2 then 3 and then 2 again.