john2020
Full Member level 5
const vs define
Hi ,
I would like to know why is const used can we use #define LPT1 0x378 instead ??
If so which one is better why?
const int LPT1 = 0x378;
const int CONTROL = 0x37A;
const int NUM_BITS = 8;
const int CERO = 0;
const int onfiltered= 1;
const int TIME_DELAY = 0;
the program is given below....
// PC Display Driver
Max7219
//
// Signal DB25 pin Signal
IC pin
// D0................. 2
CLOCK............ 13
// D1................. 3
DATA............. 01
// D2................. 4 /DATA
ENEABLE.... 12
#include
#include
#include
#include
#include
#include
#include
#include "MAX7219.H"
const int LPT1 = 0x378;
const int CONTROL = 0x37A;
const int NUM_BITS = 8;
const int CERO = 0;
const int onfiltered= 1;
const int TIME_DELAY = 0;
const char REG_DECODE = 0x09;
const char REG_INTENSITY = 0x0A;
const char REG_SCAN_LIMIT= 0x0B;
const char REG_SHUTDOWN = 0x0C;
const char REG_DISPLAY_TEST= 0x0F;
const char INTENSITY_MIN = 0x00;
const char INTENSITY_MAX = 0x0F;
thanks & regards
john
Hi ,
I would like to know why is const used can we use #define LPT1 0x378 instead ??
If so which one is better why?
const int LPT1 = 0x378;
const int CONTROL = 0x37A;
const int NUM_BITS = 8;
const int CERO = 0;
const int onfiltered= 1;
const int TIME_DELAY = 0;
the program is given below....
// PC Display Driver
Max7219
//
// Signal DB25 pin Signal
IC pin
// D0................. 2
CLOCK............ 13
// D1................. 3
DATA............. 01
// D2................. 4 /DATA
ENEABLE.... 12
#include
#include
#include
#include
#include
#include
#include
#include "MAX7219.H"
const int LPT1 = 0x378;
const int CONTROL = 0x37A;
const int NUM_BITS = 8;
const int CERO = 0;
const int onfiltered= 1;
const int TIME_DELAY = 0;
const char REG_DECODE = 0x09;
const char REG_INTENSITY = 0x0A;
const char REG_SCAN_LIMIT= 0x0B;
const char REG_SHUTDOWN = 0x0C;
const char REG_DISPLAY_TEST= 0x0F;
const char INTENSITY_MIN = 0x00;
const char INTENSITY_MAX = 0x0F;
thanks & regards
john