Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Re: Need Help in PROGMEM. on: December 16, 2012, 01:09:06 pm
Code:
   for(d=0;d<INTEN;d++){}

This doesn't look right. Am I missing something?

that's actually for the scroll speed. it just makes the scroll slower by adding FOR statements without any "do" conditions/instructions.
2  Using Arduino / Programming Questions / Re: Need Help in PROGMEM. on: December 16, 2012, 12:06:15 pm
(0x80 >> n)  => read  - http://arduino.cc/en/Reference/Bitshift -


A quick look makes me think this is the only place where the mask is used so you can replace it
Code:
void Display (void)                    // display the data to the LED Matrix
{
  int i = 0;
  for (i = 7; i >=0 ; i--)
  {
    mask = 0x80 >> i ;
    scan();
    digitalWrite(pins[i],LOW);         // pin ON
    for(d=0;d<INTEN;d++){}
    digitalWrite(pins[i],HIGH);        // pin OFF
  }
}
i tried this out and it actually made the program larger. hehe. I'll edit out my ints with uint8_t. smiley hopefully it would make the code smaller. thanks again!
3  Using Arduino / Programming Questions / Re: Need Help in PROGMEM. on: December 16, 2012, 11:42:36 am
#define MASK(n)  (0x80 >> n)

i got a little bit confused about this. how can this be done? and is "uint8_t" same as unsigned int? haven't used that before.

thanks for the reply! smiley i'll go check it out.
4  Using Arduino / Programming Questions / Re: Need Help in PROGMEM. on: December 16, 2012, 11:38:59 am
Code:
    inbox[0];                          // clear inbox from 0-4
    inbox[1];
    inbox[2]; 
    inbox[3]; 
    inbox[4]; 
These statements do nothing. Nothing is assigned to the array element. The [] operator returns a value that is not used.

What do you want to store in PROGMEM? You are aware that PROGMEM is read-only, right?

oh, yeah. good point. smiley-grin i initially thought they erase inbox[0-4] but then, i remembered they dont. smiley) i want to use PROGMEM to save up on RAM since my Arduino is only ATMEGA32. I've used PROGMEM in the original 8x32 matrix because it encountered similar problems.
5  Using Arduino / Programming Questions / Need Help in PROGMEM. on: December 16, 2012, 11:18:56 am
Hello guys. I would appreciate some help in optimizing my code. I developed an SMS-based LED Matrix Display using Arduino. Here's a link to the thread.
http://arduino.cc/forum/index.php/topic,126897.0.html

and here's the video: http://youtu.be/WVhDr5CNxwE

I used a 8x32 LED Matrix Display back then. But now I'm developing the same project, only this time, i'm using a 8x64 LED Matrix Display.

I edited the code to apply the two Matrices, but I encountered problems when it displays the text messages. It shows text message 1 then displays random characters. I'm guessing this is a memory problem. any help? here's the new code:

Code:
#include "cmap.h"             // character map libarary
#include <SIM900.h>           // SIM900D library
#include <sms.h>              // SMS libarart
#include <SoftwareSerial.h>   // Software Serial Library
SMSGSM sms;
#define INTEN 6500 //scroll speed.
                   //the higher the value, the slower the scroll

//-----------------LED MATRIX PINS------------------

#define CLK  5    // clock pin connected to digital pin 5
#define DAT  6    // Data pin connected to digital pin 6
#define STR  7    // Strobe pin connected to digital pin 7
#define K0  A0    // Data 0 connected to analog pin 0
#define K1  A1    // Data 1 connected to analog pin 1
#define K2  A2    // Data 2 connected to analog pin 2
#define K3  A3    // Data 3 connected to analog pin 3
#define K4  8     // Data 4 connected to digital pin 8
#define K5  9     // Data 5 connected to digital pin 9
#define K6  10    // Data 6 connected to digital pin 10
#define K7  11    // Data 7 connected to digital pin 11

//-------------------GSM VARIABLES-----------------------

boolean MSG_RCVD    = false;            // no message recieved as initial value
const char regnum[] = "639177915470";   // admin number
const char passRx[] = "default#";       // holds password, must be 8 char only! and ends with #
char smsdata[160];                      // sms only accept 160 characters
char numberRx[20];                      // holds sender number
char *inbox[5];                         // holds text messages
int message_no;                         // message counter
int loop_count = 1;                     // loop count of messages
int inbox_no = -1;                      // inbox no index (starts at 0)
unsigned int d;                         // for INTEN and strobe


//-----------------LED MATRIX VARIABLES------------------

char Display_Ram[76];           // locates the the ASCII Character Map Display
char count;                             // counter for
unsigned char char_pointer = 0x00;      // character pointer for smsdata and LED_DATA arrays
unsigned char mask;                     // for masking the display
unsigned char shift_counter;            // for scrolling the message

int pins[]  = { CLK, DAT, STR, K0,      // pins for LED Matrix
                K1, K2, K3, K4, K5,
                K6, K7 };
int mask_data[]  = {0x80, 0x40, 0x20,  // mask for LED Matrix Display
                    0x10, 0x08, 0x04,
                    0x02, 0x01};
                   
// unsigned int matrix_size = 64;                   
                   
void setup()
{
  // ---------- serial setup ----------
  gsm.begin(4800);                       // initialize GSM
  pinsetup();                            // setup the pins for LED
}

void loop()
{
  Display();                             // call display
  shift();                               // shift from right to left
}

void pinsetup()                          // setup pins for display
{
  for (int x =0; x<=10; x++){            // all pins OUTPUT
    pinMode(pins[x], OUTPUT);     
  }
 
  for (int y=3; y <=10; y++){            // K0-K7 HIGH
    digitalWrite(pins[y],HIGH); 
  } 

  for(d=0;d<64;d++){                     
    clock();
  }
  strobe();
  d = 0;
}

void checkSMS ()
// ---------- check if there is new message ----------
{
  int i;
  if(gsm.readSMS(smsdata, 160, numberRx, 20))
// read new message and store in smsdata and numberRx 
  {
    if (strncmp (numberRx, regnum, 11) == 0 && strncmp (smsdata, passRx, 8) == 0)
 // check if sender number and password is correct, then continue   
    {
      while (smsdata[i] != '\0')
        {
          smsdata[i] = smsdata[i+8];   // delete the password from the string
          i++;                 
        }
        sms.SendSMS("09177915470", "Message was Recieved");
        MSG_RCVD = true;               // confirm that new message is recieved
        loop_count++;                  // increment loop count
        store();                       // store new message in inbox array
    }
  }
}

void store()
{
  inbox_no++;                          // increment from -1
  if (inbox_no >= 5)                   // check if inbox is full
  {
    inbox_no = 0;                      // reset inbox_no
    inbox[0];                          // clear inbox from 0-4
    inbox[1];
    inbox[2]; 
    inbox[3]; 
    inbox[4]; 
  }
  inbox[inbox_no] = strdup(smsdata);   // dump string into inbox number
}

void Display (void)                    // display the data to the LED Matrix
{
  int i = 0;
  for (i = 7; i >=0 ; i--)
  {
    mask = mask_data[i] ;
    scan();
    digitalWrite(pins[i],LOW);         // pin ON
    for(d=0;d<INTEN;d++){}
    digitalWrite(pins[i],HIGH);        // pin OFF
  }
}

void scan(void)
{
  int matrix_size = 64;
  for (count = matrix_size;count>(-1);count--){
    if ((Display_Ram[count] & mask) == mask)
      digitalWrite(DAT,LOW);           // data pin OFF
    else
      digitalWrite(DAT,HIGH);          // data pin ON
    clock();
  }
  strobe();
}

void clock(void){
  digitalWrite(CLK,HIGH); // clock hi
  digitalWrite(CLK,LOW);         // clock low
}

void strobe(void){
  digitalWrite(STR,HIGH); // strobe hi
  digitalWrite(STR,LOW); // strobe low
}

void shift(void)                                // Scroll display
{
  for (int val=0; val<74; val++)
  {
    Display_Ram[val] = Display_Ram[val+1];
  }
 
  shift_counter++;
 
  if(shift_counter == 6)
  {
    shift_counter = 0;
    load_data();                                 // call load_data
  }
}

void load_data(void)
{
  int counter1 = 0;
  int matrix_size = 64;
  char *LED_DATA = announcement(message_no);     // dump message to LED_DATA
 
  if(LED_DATA[char_pointer+1]  == '\0')          // If end of message
  {
    char_pointer = 0;                            // reset character pointer
    message_no++;                                // go to next message
  }
   
  for(counter1 = 0; counter1 < 5; counter1++)
  {
    Display_Ram[matrix_size + counter1] = pgm_read_byte(&(character_data[(LED_DATA[char_pointer] - 0x20)][counter1]));
  // locate the appropriate character at the CMAP.H
  }
 
  Display_Ram[matrix_size + 10] = 00;
  char_pointer++;
 
  if (message_no > loop_count)    // only check new messages when the message)no > loop_count
  {
     checkSMS();                  // check for new message
     if (MSG_RCVD == false)       // if there are no new messages, continue loop
     {
       message_no = 0;            // continue loop from the start
     }
  MSG_RCVD = false;               // then declare no new messages
  }
  else if (message_no >= 7)       // if messages is 7 or above
  {
    message_no = 0;               // go back to first message
    checkSMS();                   // then check for new messages
  }
 
}

char *announcement(int message_no2)      // where the strings and text messages are stored
{
  char *LED_message[]={"    LCoES Announcements         ",   
                       "    Hello Letranites!           ",   
                              inbox[0]                   ,   
                              inbox[1]                   ,   
                              inbox[2]                   ,   
                              inbox[3]                   ,   
                              inbox[4]                   };   
 
  // FIXED MESSAGE 1 = LCOES ANNOUNCEMENTS
  // FIXED MESSAGE 2 = HELLO LETRANITES
  // INBOX 0 - 4 = TEXT MESSAGES
 
  return LED_message[message_no2];      // returns message index based from message no.
}

would really appreciate some help with PROGMEM. thanks! smiley-grin
6  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 11, 2012, 05:13:57 am
nothings change no msg are displaying  smiley-confuse

have you tried the sample code i uploaded? try that out first before anything else. there might be problems with the GSM Shield. also make sure that the SIM has enough prepaid balance when you try out the code i gave.
7  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 10, 2012, 05:06:50 am
can i change the password without # for example "opensms"  ?

yes. as long as you also check and edit the strcmp function in the checkSMS. you might have the incorrect password. try this code first so you see what's the function of each part of the code. see the attached file.

another off-topic question: are you a computer engineering student?

8  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 10, 2012, 05:03:17 am
i used my no. as the admin and the default# password,,, i will upload the codes
this is my first time in arduino smiley

have you tried using 0906... instead of 63906...?
try it out first. sometimes our local networks use the "63" area code.

try out the basic codes first. take it step by step first.
9  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 10, 2012, 04:04:45 am
sir I have problem, no text msg. appear in led matrix, only the first and 2nd msg are displaying.  smiley-confuse ???

http://www.youtube.com/watch?v=_HQjEAwLnOY&feature=youtu.be

pls check this.

i think you have the wrong password. it should be "default#" without any spaces. maybe you've altered some part of the code i uploaded. there's something wrong with your checkSMS function of maybe you're text message is wrong.

and oh, i almost forgot, i think you didn't edit my number out. only my number is registered in the code i uploaded. i guess that will do the trick.

random question though: have you had extensive experience in programming?
10  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 07, 2012, 06:24:34 am
thank sir problem solved !!!!  smiley smiley smiley

Good job! Appreciate it if you left me some Karma points and some likes on Youtube. Hahaha. Thanks!
11  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: November 07, 2012, 05:51:37 am
Quote
im working same project, but i cant upload the the code i think because of the version of the arduino. im using arduino 1.0.1 pls help me  smiley-cry

Hello. It's because you didn't download the proper libraries. Look for GSM/GPRS library made by open electronics and change the Tx Rx to 2 and 3 of the Gsm.cpp file
12  Using Arduino / General Electronics / Embed Sound in Arduino GSM Shield. on: November 02, 2012, 12:23:42 pm
Hi Guys, I would like to develop an anti-theft detector that would call and text the administrator once it detects someone opening a PC case.

I've successfully tried the call and text functions from the GSM/GPRS shield. But i would like to add a voice call that would say, for example: "Intrusion Detected". How can i embed sounds in when the GSM shield calls?

thanks in advace! smiley-grin

- Migs
13  Using Arduino / Programming Questions / Re: What's PROGMEM for? on: October 22, 2012, 10:12:17 pm
Your incoming messages are hardcoded?

what do you mean by hardcoded? i used PROGMEM'd CMAP.h only to locate the appropriate hexa value of each character.
14  Using Arduino / Project Guidance / Re: SMS-Based LED Matrix Display. on: October 22, 2012, 10:09:50 pm
Good smiley

I'm sorry that I led (smiley-razz) you in the wrong direction with my comment about pointers..

haha. i see what you did there. smiley thanks! smiley-grin
15  Using Arduino / Programming Questions / Re: What's PROGMEM for? on: October 21, 2012, 09:27:04 am
Not if you want to write to it. PROGMEM is read-only.

nope, didn't need to write to it. i just needed to read from it. smiley

i finished the project! smiley-grin



you can see the full thread here. smiley-grin

http://arduino.cc/forum/index.php/topic,126897.msg964816.html#msg964816

hope i contributed something to the arduino community. smiley
Pages: [1] 2 3 ... 6