I am a newbie, I have just bought the Arduino board for my project
Because I do not know C/ C++ very well, I have a question about the following code.
my problem is i'm trying to display serial input to my dot matrix display
i'm having the following errors and i don't know what's the reason of it.
sketch_feb20a.ino: In function 'void loop()':
sketch_feb20a.ino:182:12: error: incompatible types in assignment of 'int' to 'char [180]'
Error compiling.
Many thanks in advanced!
Please find the attachment for the complete code.
msg= Serial.read();You have declared msg as an array of character. You need to assign the character to an element of msg, like msg[2] for example. In order to build up the message you need to keep track using a variable of the next position in which the character will be placed.
hi friend,
Thanks for your fast reply by following your instruction i did solve it using the following code and it did compile
if(Serial.available())
{
//inform that Arduino heard you saying something
Serial.print("Arduino heard you say: ");
//keep reading and printing from serial untill there are bytes in the serial buffer
while (Serial.available()>0){
for (int i=0; i<40; i++)
{
msg[i]= Serial.read(); //read Serial
Serial.print(msg[i]); //prints the character just read
}
but unfortunately nothing is being displayed. i once try the parola library but it's not compiling with lots of errors as a beginner in programming i can't figure it out why. the code in the attachment is only one working. so can you please advice me how to modify the code i uploaded to display a serial input to the dot matrix display or how to use the parola library for the same purpose. in the attachment i also include a picture of the type of max7219 that i'm using which i bought on ebay.
Once again thanks a lot for your help.
Parola already has an example that displays messages from the serial input.
Character array 'strings' in C must always be terminate with the '\0' character - it tells the software that that is the end of the string. You need to make sure that you terminate properly. Also if you have 10 characters in a string they are numbered 0 through 9 and string[9] is where the '\0' should be, so you only get 8 characters you can use.
When debugging compiler errors, you rally only need to look at the first one and fix that, one error at a time. Don't be confused by all the other errors until you get more experienced.
hi again;
thnxs for your help again i was trying parola library and i got the following errors while compiling was trying to fix it but in vain. i can't figure out wats wrong.
Arduino: 1.6.0 (Windows 7), Board: "Arduino Uno"
Using library MD_Parola in folder: C:\Program Files\Arduino\libraries\MD_Parola
Using library MD_MAX72xx in folder: C:\Program Files\Arduino\libraries\MD_MAX72xx (legacy)
C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files\Arduino\libraries\MD_Parola\src -IC:\Program Files\Arduino\libraries\MD_MAX72xx C:\Users\GANESHA\AppData\Local\Temp\build2147118178296078298.tmp\Parola_Scrolling.cpp -o C:\Users\GANESHA\AppData\Local\Temp\build2147118178296078298.tmp\Parola_Scrolling.cpp.o
In file included from Parola_Scrolling.ino:15:0:
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h: In member function 'void MD_PZone::zoneClear()':
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:329:63: error: no matching function for call to 'MD_MAX72XX::clear(uint8_t&, uint8_t&)'
inline void zoneClear(void) { _MX->clear(_zoneStart, _zoneEnd); if (_inverted) _MX->transform(_zoneStart, _zoneEnd, MD_MAX72XX::TINV); };
^
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:329:63: note: candidates are:
In file included from C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:208:0,
from Parola_Scrolling.ino:15:
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:483:8: note: void MD_MAX72XX::clear()
void clear(void);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:483:8: note: candidate expects 0 arguments, 2 provided
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:668:8: note: bool MD_MAX72XX::clear(uint8_t)
bool clear(uint8_t buf);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:668:8: note: candidate expects 1 argument, 2 provided
In file included from Parola_Scrolling.ino:15:0:
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:329:134: error: no matching function for call to 'MD_MAX72XX::transform(uint8_t&, uint8_t&, MD_MAX72XX::transformType_t)'
inline void zoneClear(void) { _MX->clear(_zoneStart, _zoneEnd); if (_inverted) _MX->transform(_zoneStart, _zoneEnd, MD_MAX72XX::TINV); };
^
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:329:134: note: candidates are:
In file included from C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:208:0,
from Parola_Scrolling.ino:15:
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:616:8: note: bool MD_MAX72XX::transform(MD_MAX72XX::transformType_t)
bool transform(transformType_t ttype);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:616:8: note: candidate expects 1 argument, 3 provided
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:735:8: note: bool MD_MAX72XX::transform(uint8_t, MD_MAX72XX::transformType_t)
bool transform(uint8_t buf, transformType_t ttype);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:735:8: note: candidate expects 2 arguments, 3 provided
In file included from Parola_Scrolling.ino:15:0:
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h: In member function 'void MD_PZone::setIntensity(uint8_t)':
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:425:115: error: no matching function for call to 'MD_MAX72XX::control(uint8_t&, uint8_t&, MD_MAX72XX::controlRequest_t, uint8_t&)'
inline void setIntensity(uint8_t intensity) { _MX->control(_zoneStart, _zoneEnd, MD_MAX72XX::INTENSITY, intensity); };
^
C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:425:115: note: candidates are:
In file included from C:\Program Files\Arduino\libraries\MD_Parola\src/MD_Parola.h:208:0,
from Parola_Scrolling.ino:15:
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:405:8: note: bool MD_MAX72XX::control(uint8_t, MD_MAX72XX::controlRequest_t, int)
bool control(uint8_t dev, controlRequest_t mode, int value);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:405:8: note: candidate expects 3 arguments, 4 provided
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:416:8: note: void MD_MAX72XX::control(MD_MAX72XX::controlRequest_t, int)
void control(controlRequest_t mode, int value);
^
C:\Program Files\Arduino\libraries\MD_MAX72xx/MD_MAX72xx.h:416:8: note: candidate expects 2 arguments, 4 provided
Error compiling.
Please make sure that you are using the latest MD_Parola and MD_MAX72xx libraries. From the messages it looks like the MD_MAX72xx is not the most current.
hi friend;
i update everything and it works.
but i have 4 MAX7219 dot matrix module one display each 4 of them are display the character and it is inverted. any idea how i can change zat
The matrix is wired a lot of different ways depending on the hardware design. The library needs to know how it is wired up.
Determine what type of hardware you have from the supported list. I think you may have FC-16 from the picture you provided, but the documentation has a number of images to try and help you decide.
If yours is non-standard then you need to understand what the setting will be using the HW_Mapper example software.
Change the library defines to suit your findings from either 1 or 2 above.
i have another problem. i try the do display sms using the parola library but it's not working, gsm sheild is initialised bt no msg is display including curMessage
while (sms.available())
{
newMessage[putIndex] = (char)sms.read();
if ((newMessage[putIndex] == '\n') || (putIndex >= BUF_SIZE-2)) // end of message character or full buffer
{
// put in a message separator and end the string
newMessage[putIndex] = '\0';
// restart the index for next filling spree and flag we have a message waiting
putIndex = 0;
newMessageAvailable = true;
}
else
// Just save the next char in next location
newMessage[putIndex++];
}
Never used the gsm shield, so I have no idea if what you are doing is correct or where the problem could be. You may be better changing the topic so that is is relevant to the gsm problem, or creating a new topic for this problem.
hi
i did solve the problem i was getting. Concerning Scrolling direction and Invert ON/OFF which type of switch is being used? can i use push button to control them?
i did try use 1, i connect 1 side of it to 5v and the other to pin 8 but nothing happen how can i solve this.
To control direction and inverse you need to call the functions that change the mode in Parola.
In your code, if you want to use switches, you will need to detect the transition from on to off (or the other way around) and call the Parola functions then. There are a lot of examples on the internet and on this forum about advice for connecting and detecting switches, so please search.
hi friend
thanks for your help and reply i did succeed to complete my project which is SMS notice board everything is working fine but i want want 1 add a small feature to make it a lil bit interesting that's controlling its speed by using POTS but when i set the "USE_UI_CONTROL " to 1 nothing happen i don't know what went wrong.
Regards
int led7 = 7;
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <GSM.h>
#define PINNUMBER ""
GSM gsmAccess;
GSM_SMS sms;
char senderNumber[20];
// set to 1 if we are implementing the user interface pot, switch, etc
#define USE_UI_CONTROL 0
#if USE_UI_CONTROL
#include <MD_KeySwitch.h>
#endif
// Turn on debug statements to the serial output
#define DEBUG 1
#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
#define PAUSE_TIME 1000
#define SPEED_DEADBAND 5
// Scrolling parameters
#if USE_UI_CONTROL
#define SPEED_IN A5
#define DIRECTION_SET 8 // change the effect
#define INVERT_SET 9 // change the invert
#endif // USE_UI_CONTROL
uint8_t frameDelay = 25; // default frame delay value
textEffect_t scrollEffect = SCROLL_LEFT;
// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char curMessage[160];
char newMessage[160];
bool newMessageAvailable = false;
#if USE_UI_CONTROL
MD_KeySwitch uiDirection(DIRECTION_SET);
MD_KeySwitch uiInvert(INVERT_SET);
void doUI(void)
{
// set the speed if it has changed
{
int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 10, 150);
if ((speed >= ((int16_t)P.getSpeed() + SPEED_DEADBAND)) ||
(speed <= ((int16_t)P.getSpeed() - SPEED_DEADBAND)))
{
P.setSpeed(speed);
P.setPause(speed);
frameDelay = speed;
PRINT("\nChanged speed to ", P.getSpeed());
}
}
if (uiDirection.read()) // SCROLL DIRECTION
{
PRINTS("\nChanging scroll direction");
scrollEffect = (scrollEffect == SCROLL_LEFT ? SCROLL_RIGHT : SCROLL_LEFT);
P.setTextEffect(scrollEffect, scrollEffect);
P.displayReset();
}
if (uiInvert.read()) // INVERT MODE
{
PRINTS("\nChanging invert mode");
P.setInvert(!P.getInvert());
}
}
#endif // USE_UI_CONTROL
void readSerial(void)
{
char c;
byte smsIndex = 0;
if (sms.available())
{
while (c = sms.read())
{ // Always use curly braces with while statements!
Serial.print(c);
newMessage[smsIndex++] = c;
newMessage[smsIndex] = '\0'; // Keep string NULL terminated
newMessageAvailable = true;
} // Always use curly braces with while statements!
Serial.println("\nMESSAGE STORE IN ARRAY");
Serial.print(newMessage);
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
}
void setup()
{
pinMode(led7, OUTPUT);
Serial.begin(57600);
#if USE_UI_CONTROL
uiDirection.begin();
uiInvert.begin();
pinMode(SPEED_IN, INPUT);
doUI();
#endif // USE_UI_CONTROL
P.begin();
P.displayClear();
P.displaySuspend(false);
P.displayScroll(curMessage, LEFT, scrollEffect, frameDelay);
strcpy(curMessage, "Hello! Enter new message?");
newMessage[0] = '\0';
Serial.begin(57600);
Serial.print("\n[Parola Scrolling Display]\n");
Serial.println("\nSMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM connection
while (notConnected)
{
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
{
digitalWrite(led7, HIGH);
notConnected = false;
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
#if USE_UI_CONTROL
doUI();
#endif // USE_UI_CONTROL
readSerial();
if (P.displayAnimate())
{
if (newMessageAvailable)
{
strcpy(curMessage, newMessage);
newMessageAvailable = false;
}
P.displayReset();
}
}
when i set the "USE_UI_CONTROL " to 1 nothing happen
Does it compile without errors?
Does it still work like it did before?
Have you got a pot on A5?
If you are not connecting switches for direction and invert control then you may need to disable that part of the code?
hi friend,
yaps it does compile without errors and i do have a POTS on A5, even i can change the direction and the invert both are working. when i compare the code with the unmodified one i notice "static uint8_t putIndex = 0;" is missing from mine, does this has something to do with the speed?
void readSerial(void)
{
char c;
byte smsIndex = 0;
if (sms.available())
{
while (c = sms.read())
{ // Always use curly braces with while statements!
Serial.print(c);
newMessage[smsIndex++] = c;
newMessage[smsIndex] = '\0'; // Keep string NULL terminated
newMessageAvailable = true;
} // Always use curly braces with while statements!
Serial.println("\nMESSAGE STORE IN ARRAY");
Serial.print(newMessage);
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
}
Verify that you pot works. Do this by running the Arduino standard example AnalogInOutSerial and change the pin to A5. The serial display should change as you change the pot. If it does not, check the wiring in the pot.