Hello very simple problem I have a piece of code given by Nick Gammon I have it working with changing the 'showString(HELLO WORLD, 650);'
This sends off the data to flash letters on a matrix driven by a 7219 max chip. I am very new and I want to change the hello world to a serial input from the computer I then might try do this wirelessly or some thing but for now I will keep it simple. So here is the original code that works by just changing the string in the void loop at the bottom:
#include <Boards.h>
#include <Firmata.h>
#include <SPI.h>
#include <avr/pgmspace.h>
#include "font.h"
char* myStrings[]={"This is string 1", "This is string 2", "This is string 3",
"This is string 4", "This is string 5","This is string 6"};
// define max7219 registers
const byte MAX7219_REG_NOOP = 0x0;
const byte MAX7219_REG_DIGIT0 = 0x1;
const byte MAX7219_REG_DIGIT1 = 0x2;
const byte MAX7219_REG_DIGIT2 = 0x3;
const byte MAX7219_REG_DIGIT3 = 0x4;
const byte MAX7219_REG_DIGIT4 = 0x5;
const byte MAX7219_REG_DIGIT5 = 0x6;
const byte MAX7219_REG_DIGIT6 = 0x7;
const byte MAX7219_REG_DIGIT7 = 0x8;
const byte MAX7219_REG_DECODEMODE = 0x9;
const byte MAX7219_REG_INTENSITY = 0xA;
const byte MAX7219_REG_SCANLIMIT = 0xB;
const byte MAX7219_REG_SHUTDOWN = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;
void sendByte (const byte reg, const byte data)
{
digitalWrite (SS, LOW);
SPI.transfer (reg);
SPI.transfer (data);
digitalWrite (SS, HIGH);
} // end of sendByte
void letter (const byte c)
{
for (byte col = 0; col < 8; col++)
sendByte (col + 1, pgm_read_byte (&cp437_font [c] [col]));
} // end of letter
void showString (const char * s, const unsigned long time)
{
char c;
while (c = *s++)
{
letter (c);
delay (time);
letter (' '); // brief gap between letters
delay (400);
}
} // end of showString
void setup () {
Serial.begin(9600);
SPI.begin ();
sendByte (MAX7219_REG_SCANLIMIT, 7); // show all 8 digits
sendByte (MAX7219_REG_DECODEMODE, 0); // using an led matrix (not digits)
sendByte (MAX7219_REG_DISPLAYTEST, 0); // no display test
// clear display
for (byte col = 0; col < 8; col++)
sendByte (col + 1, 0);
sendByte (MAX7219_REG_INTENSITY, 7); // character intensity: range: 0 to 15
sendByte (MAX7219_REG_SHUTDOWN, 1); // not in shutdown mode (ie. start it up)
} // end of setup
void loop ()
{
showString ("Hello World", 650);
} // end of loop
Like I saiud this works like a treat and I really like it. So here is what I would like to change and for some reason just cannot do it :/:
(I shall only contain the void loop here)
void loop ()
{
Serial.begin(9600); //Setup up the baud rate etc
while (Serial.available()== 0); //Infin loop until serial data comes in
showString (Serial.read() , 650); //Output the input to the matrix
} // end of loop
I get this error that [invalid conversion from 'int' to 'const char*']
Can any one spot the problem? It would mean a lot to me if any one helps Thank you!