This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Saturday, November 14, 2015

MAX7219 7-Segment Display

Do you like the 7-segment displays?
This board has a MAX7219, the board has eight digits connected in cascade. The board works at 5V and has SPI interface.
 
Video.

Description of library.

Initializes the MAX7219.

MAX7219_Init(void)
Example:
MAX7219_Init();

Writes a single digit.
MAX7219_WriteDigit(c, digit)

  • c: Sets the 7-segment character.
  • digit: Sets the digit.
Example:
MAX7219_WriteDigit('2', 5);

Writes constant numbers.
MAX7219_ConstDigit(buffer);

  • buffer: Sets the numbers.
Example:
MAX7219_ConstDigit("00001234");

Writes numbers.
MAX7219_Digit(buffer);

  • buffer: Sets the numbers.
Example:
unsigned int i;
char buffer2[20];

i = 25;
sprintf(buffer2, "%8d", i);
MAX7219_Digit(buffer2);

Clears the 8 digits.

MAX7219_Clear(void);
Example:
MAX7219_Clear();

Schematic.


Thursday, November 12, 2015

DS3231 Library.

Professional library for projects where a RTC is implemented. Version 3.
Request a copy.
You can  send a request  to:

armicrocontroller@gmail.com

This function initializes the RTC.
DS3231_Init(void)

Example:
DS3231_Init();


This function gets the time and calendar information of the RTC.

DS3231_GetInfo(void)
Example:
DS3231_GetInfo(); 

This function can be used to configure a new time and calendar information.
DS3231_AddData(dat, inc_dec)

  • dat: This parameter selects seconds, minutes, hours, day, date, month or year.
  • 1 Seconds.
  • 2 Minutes.
  • 3 Hours.
  • 4 Day.
  • 5 Date.
  • 6 Month.
  • 7 Year.
  • inc_dec: This parameter sets the increment or decrement.
  • 1 increment.
  • 2 decrement.
Example:
DS3231_AddData(3, INC_DAT);


This function does a conversion AM to PM or PM to AM.
DS3231_AMPM(void)
Example:
DS3231_AMPM();


This function does a conversion 12hr to 24hr or 24hr to 12hr.
DS3231_HourMode(void)
Example:
DS3231_HourMode();


This function gets the full calendar. "Day Date Month Year" <<Mon 12 Jan 15>>
DS3231_GetCalendar(*p, dat)

  • *p: This parameter saves the date information in a variable.
  • dat: This parameter is used to select the day, date, month, year or the full calendar.
  • 0 Full Calendar.
  • 4 Day.
  • 5 Date.
  • 6 Month.
  • 7 Year.
  • 9 Resume Calendar.
Example:
char calendar[40];

DS3231_GetInfo();
DS3231_GetCalendar(calendar, 0);


This funtion gets the time information. "Hours:Minutes:Seconds" <<01:35:12>>
DS3231_GetTime(p1)

  • *p: This parameter saves the time information in a variable.
  • Return 0 if time is in 24 format.
  • Return 1 if time is in 24 format.
  • Return 2 if time is in AM format.
  • Return 3 if time is in PM format.
Example:
char time[10];
unsigned char ampm;

DS3231_GetInfo();
ampm = DS3231_GetTime(time);

How to use this library in a project.
Basic example:
We have  two buttons, where Button 1 selects the information to configure and Button 2 adds a new time or data information.

main()
{
 unsigned char i = 1;
 unsigned char ampm;
 char time[20];
 char calendar[40];

 DS3231_Init();
 while(1)
 {
  if(BUTTON1 == 1 && i < 8)
  {
   i++;
  }

  if(BUTTON2 == 1)
  {
   DS3231_AddData(i, INC_DAT);
  } 
  DS3231_GetInfo();
  ampm = DS3231_GetTime(time); 
  DS3231_GetCalendar(calendar, 0);
  LCD_Print(time);
  LCD_Print(calendar);
 }
}



Friday, October 23, 2015

Nokia 5110 LCD Library

The module Nokia 5110 is a monochrome graphic LCD with 48x84 pixels. This LCD has SPI interface and blue backlight. We can buy these modules for less 2 USD.


Module Features.
  • Resolution: 48 x 84 dot matrix panel.
  • Power supply: 3.3V.
  • Interface: SPI.
  • Driver IC: PCD8544.
Video.

Request.
Email contact: armicrocontroller@gmail.com


Description of library.

Initializes the Nokia5110 module.
Nokia5110_Init(void)

Example:
Nokia5110_Init();

Sets font that will be used.
Nokia5110_SetFont(_font, _width, _height, _min, _max)

  •  _font: desired font.
  • _width: sets the width in units of pixels.
  • _height: sets the height in units of pixels.
  • _min: sets the range minimum.
  • _max: sets the range maximum.
Example:
Nokia5110_SetFont(Terminal12x16, 12, 16, 32,127);



  • font name : Terminal12x16
  • width 12 pixels
  • height 16 pixels
  • range: start in character 32, end in  character 127
We can use "GLCD Font Creator" to design new fonts, symbols and icons.
Note: Only fonts with multiples of 8 pixels in height (8, 16, 24, 32 ... )

Writes a char on the Nokia5110.
Nokia5110_WriteChar(c, seg, pag)

  • c: char to be written.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
Nokia5110_WriteChar('A', 10, 3);

Prints text constant on Nokia5110.
Nokia5110_ConstText(buffer, seg, pag)

  • buffer: text to be written.
  •  seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
Nokia5110_ConstText("NOKIA", 0, 0);

Prints text variable on Nokia5110.
Nokia5110_Text(buffer, seg, pag)

  • buffer: text to be written.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d", i);
Nokia5110_Text(buffer2, 0, 3);

Prints text constant on Nokia5110 with scroll.
Nokia5110_ConstTextScroll(buffer)

  • buffer: text to be written.
Example:
Nokia5110_SetFont(Terminal12x16, 12, 16, 32 , 127);
Nokia5110_ResetScroll();
while(1){
Nokia5110_ConstTextScroll("This is a new scroll function  ");
Delay_ms(50);
}

Prints text variable on Nokia5110 with scroll.
Nokia5110_TextScroll(buffer)

  • buffer: text to be written.
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d   ", i);
Nokia5110_SetFont(Terminal12x16, 12, 16, 32 , 127);
Nokia5110_ResetScroll();
while(1){
Nokia5110_TextScroll(buffer2);
Delay_ms(50);
}

Resets the scroll.
Nokia5110_ResetScroll(void)

This function must be called before of a new scroll function.
Example:
Nokia5110_ResetScroll();

Fills Nokia5110 memory.
Nokia5110_FillScreen(pattern)

  • pattern: byte to fill Nokia5110 memory.
Example:
Nokia5110_FillScreen(0xFF);

Displays bitmap on Nokia5110.
Nokia5110_Image(buffer)

  • buffer: image to be displayed.
Example:
Nokia5110_Image(truck);

Displays an image on a desired location.
Nokia5110_Icon(buffer, seg, pag, _width, _height)

  • buffer: image to be displayed.
  • seg: sets the segment. Valid values: 0..83
  • pag: sets the page. Valid values: 0..5
  • _width sets the width of the image.
  • _height sets the height of the image.
Example:
Nokia5110_Icon(icon1,25,2,32,32);

Inverts the RAM memory.
Nokia5110_InvertRam(seg1, pag1, seg2, pag2)

  • seg1 sets the start segment. Valid values: 0..83
  • pag1 sets the start page. Valid values: 0..5
  • seg2 sets the end segment. Valid values: 0..83
  • pag2 sets the end page. Valid values: 0..5
Example:
Nokia5110_InvertRam(0, 0, 83, 5);

Draws a Pixel on Nokia5110.

Nokia5110_Pixel(x, y, color)

  • x: x position. Valid values: 0..83
  • y: y position. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Pixel(40, 40, BLACK);

Draws a Line on Nokia5110.
Nokia5110_Line(x1, y1, x2, y2, color)
 

  • x1: x coordinate of the line start. Valid values: 0..83
  • y1: y coordinate of the line start. Valid values: 0..47
  • x2: x coordinate of the line end. Valid values: 0..83
  • y2: y coordinate of the line end. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Line(0, 0, 83, 47, BLACK);

Draws a rectangle on Nokia5110.
Nokia5110_Rectangle(x1, y1, x2, y2, color)

  • x1: x coordinate of the upper left rectangle corner. Valid values: 0..83 
  • y1: y coordinate of the upper left rectangle corner. Valid values: 0..47
  • x2: x coordinate of the lower right rectangle corner. Valid values: 0..83
  • y2: y coordinate of the lower right rectangle corner. Valid values: 0..47
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Rectangle(10, 10, 70, 40, BLACK);

Draws a circle on Nokia5110.
Nokia5110_Circle(x1, y1, radius, color)

  • x1: x coordinate of the circle center. Valid values: 0..83
  • y1: y coordinate of the circle center. Valid values: 0..47
  • radius: radius size
  • color: color parameter. Valid values: 1,2,3
Example:
Nokia5110_Circle(41, 23, 5, Black);


Connection.



Tuesday, July 21, 2015

Led matrix, MAX7219 board.

In this post we will evaluate the MAX7219 board. This board was designed to control an 8x8 led matrix. I bought four boards in ebay, I like this model.
How to assemble the boards.
  • We solder two headers in each board.
  • We will solder the led matrix, be sure to put the led matrix in correct position.

How to connect the boards.
We will connect the boards in the following way.
Video.


Request.
Email contact: armicrocontroller@gmail.com


Description of library.
This library support 1, 2, 3, 4 ...n boards, so we will need define the quantity of boards at max7219.h file.

Initializes the modules.

MAX7219_Init() 

Example:
MAX7219_Init();


Sets font.
MAX7219_SetFont(_font,_width,_min,_max)

  • _font: font to be set.
  • _width: char width (pixels)
  • _min: range minimum
  • _max: range maximum
Example:
MAX7219_SetFont(Font_6x8, 6, 32, 127);

Writes a char.
MAX7219_WriteChar(c,col)

  • c: char to be written
  • col: set column. Valid values: 0...
Example:
MAX7219_WriteChar('A', 0);

Prints text constant.
MAX7219_ConstText(buffer,col)

  • buffer: text to be written
  • col: set column. Valid values: 0...
Example:
MAX7219_ConstText("Hello",1);

Prints text variable.
MAX7219_Text(buffer,col)

  • buffer: text to be written
  • col: set column. Valid values: 0...
Example:
unsigned char i;
char buffer2[20];
i = 12;
sprintf(buffer2,"%03d",i);
MAX7219_Text(buffer2, 10);

This function does motion of scroll.
MAX7219_ConstTextScroll(buffer)
MAX7219_TextScroll(buffer)

MAX7219_ResetScroll(void)
  • buffer: text to be written
Example:
MAX7219_ResetScroll();
while(1){
MAX7219_ConstTextScroll("Hello.");
Delay_ms(300);
}

Displays Symbol.
MAX7219_Symbol8x8(buffer,col)

  • buffer: byte of array
  • col: set column. Valid values: 0...
Example:
MAX7219_Symbol8x8(8x8Symbol);

Fills RAM memory.
MAX7219_FillScreen(pattern)

  • pattern: byte to fill RAM memory
Example:
MAX7219_FillScreen(255);

Inverts the RAM memory.
MAX7219_InvertScreen()

Example:
MAX7219_InvertScreen();


Draws a Pixel on LED Matrix.
MAX7219_Pixel(x,y,color)
  • x: x position. Valid values: 0..
  • y: y position. Valid values: 0..7
  • color: color parameter. Valid values: 1, 2, 3
Example:
MAX7219_Pixel(1,1,1);
 

Friday, January 9, 2015

SHT21 Humidity and Temperature Sensor

SHT21, the new humidity and temperature sensor of Sensirion is about to set new standards in terms of size and intelligence: Embedded in a reflow solderable Dual Flat No leads (DFN) package of 3 x 3mm foot print and 1.1mm height it provides calibrated, linearized signals in digital, I2C format.