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.

Tuesday, September 11, 2018

SSD1331 OLED

This display has the driver SSD1331 this one is a RGB OLED display, 65K color and SPI interface. So, our ili9341 driver was adapted to this display.
Request.
Email contact: armicrocontroller@gmail.com

Video. 

Description of library.
This function initializes the driver SSD1331.
SSD1331_Init(void)
Example:
SSD1331_Init();


This function resets the driver SSD1331.
SSD1331_Reset(void)
Example:
SSD1331_Reset();


This function draws a pixel.
SSD1331_Pixel(x, y, color)

  • x: x position. Valid values: 0..96
  • y: y position. Valid values: 0..64
  • color: color parameter.
Example:
SSD1331_Pixel(50, 50, BLUE);


This function sets the size of dot.
SSD1331_SetDotSize(size)

  • size: Size of dot. Valid values: 0, 1, 2, 3, 4, 5.
Example:
SSD1331_SetDotSize(2);
SSD1331_Dot(50, 50, BLACK);


This function draws a dot.
SSD1331_Dot(x, y, color)

  • x: x position. Valid values: 0..96
  • y: y position. Valid values: 0..64
  • color: color parameter.
Example:
SSD1331_Dot(50, 50, BLACK);


This function sets the type of font.
SSD1331_SetFont(font, letterspacing)

  • font: Pointer to read all the array.
  • letterspacing: Letter spacing. Valid values: 1, 2, 3...
Example:
SSD1331_SetFont(Courier_New_Bold_20, 0);


This function draws a character.
SSD1331_WriteChar(c, x, y, color1, color2)

  • c: character to be written.
  • x: x position. Valid values: 0..96
  • y: y position. Valid values: 0..64
  • color1: Top color.
  • color2: Bottom color.
Example:
SSD1331_WriteChar('A', 10, 10, BLACK, WHITE);


This function writes text constant.
SSD1331_ConstText(buffer, x, y, color1, color2)

  • buffer: Pointer to read all the array.
  • x: x position. Valid values: 0..96
  • y: y position. Valid values: 0..64
  • color1: Top color.
  • color2: Bottom color.
Example:
SSD1331_ConstText("pic18fxx", 0, 0, BLACK, WHITE);


This function writes text variable.
SSD1331_Text(buffer, x, y, color1, color2)

  • buffer: Pointer to read all the array.
  • x: x position. Valid values: 0..96
  • y: y position. Valid values: 0..64
  • color1: Top color.
  • color2: Bottom color.
Example:
unsigned char i;
char buffer2[20];
i = 22;
sprintf(buffer2, "%03d", i);
SSD1331_Text(buffer2, 10, 10, BLACK, WHITE);


These functions write text with alignment.

SSD1331_TextLEFT(buffer, y, color1, color2, color3)
SSD1331_TextCENTER(buffer, y, color1, color2)
SSD1331_TextRIGHT(buffer, y, color1, color2)

  • buffer: Pointer to read all the array.
  • y: y position. Valid values: 0..64
  • color1: Top color.
  • color2: Bottom color.
  • color3: Bottom color2.
Examples:
SSD1331_TextLEFT((char*)"ILI9341", 10, BLACK, WHITE, RED);
SSD1331_TextCENTER((char*)"ILI9341",30, BLACK, WHITE);
SSD1331_TextRIGHT((char*)"ILI9341", 50, BLACK, WHITE);


This function fills screen with given color.
SSD1331_FillScreen(color

  • color: color parameter.
Example:
SSD1331_FillScreen(BRIGHTGREEN);


This function draws a box.
SSD1331_Box(x1, y1, x2, y2, color)

  • x1: x coordinate of the upper left rectangle corner. Valid values: 0..96 
  • y1: y coordinate of the upper left rectangle corner. Valid values: 0..64
  • x2: x coordinate of the lower right rectangle corner. Valid values: 0..96
  • y2: y coordinate of the lower right rectangle corner. Valid values: 0..64
  • color: color parameter.
Example:
SSD1331_Box(0, 0, 50, 50, BLUE);


This function draws a line.
SSD1331_Line(x1, y1, x2, y2, color)

  • x1: x coordinate of the line start. Valid values: 0..96
  • y1: y coordinate of the line start. Valid values: 0..64
  • x2: x coordinate of the line end. Valid values: 0..96
  • y2: y coordinate of the line end. Valid values: 0..64
  • color: color parameter.
Example:
SSD1331_Line(1, 1, 50, 50, GREEN);


This function draws a rectangle.
SSD1331_Rectangle(x1, y1, x2, y2, color)

  • x1: x coordinate of the upper left rectangle corner. Valid values: 0..96 
  • y1: y coordinate of the upper left rectangle corner. Valid values: 0..64
  • x2: x coordinate of the lower right rectangle corner. Valid values: 0..96
  • y2: y coordinate of the lower right rectangle corner. Valid values: 0..64
  • color: color parameter.
Example:
SSD1331_Rectangle(1, 1, 50, 50, GREEN);


This function draws a rounded edge rectangle.
SSD1331_RectangleRound(x1, y1, x2, y2, radius, color)

  • radius: radius of the rounded edge.
Example:
SSD1331_RectangleRound(1, 1, 50, 50, 6, GREEN);


This function draws a filled rounded edge rectangle.

SSD1331_RectangleRoundFill(x1, y1, x2, y2, radius, color)
Example:
SSD3131_RectangleRoundFill(1, 1, 50, 50, 6, GREEN);


This function draws a circle.
SSD1331_Circle(x1, y1, radius, color)

  • x1: x coordinate of the circle center. Valid values: 0..96
  • y1: y coordinate of the circle center. Valid values: 0..64
  • radius: radius size
  • color: color parameter.
Example:
SSD1331_Circle(50, 30, 10, BLACK);


This function draws a filled circle.
SSD1331_CircleFill(x1, y1, radius, color)
Example:
SSD1331_CircleFill(50, 30, 10, BRIGHTRED);


This function draws an image on a desired location.
SSD1331_Icon(buffer, x, y, width, height)

  • buffer: Pointer to read all the array.
  • x: x position.
  • y: y position.
  • width: width of the image in pixels.
  • height: height of the image in pixels.
Example:
SSD1331_Icon(icon_play, 10, 16, 20, 34);
 

This function draws an image with transparent color on a desired location.
SSD1331_IconTransparent(buffer, x, y, width, height, color);

  • buffer: Pointer to read all the array.
  • x: x position.
  • y: y position.
  • width: width of the image in pixels.
  • height: height of the image in pixels.
  • color: transparent color.
Example:
SSD1331_IconTransparent(icon_speaker, 10, 16, 22, 18, WHITE);


 Connection.


Note:
The pins CS, RESET and DC can be configured in the file ili9341.h

Bitmap Editor. C#
This software programed at c# can be used to make bitmaps.


Sunday, October 1, 2017

Touch Screen TSC2046 XPT2046

This library controls the IC TSC2046 included in some displays with touch screen. Buttons, Push Buttons, Switches and Potentiometers can be added in few seconds. This is a library designed for automation projects. You can use this library to control relays, leds, pwm and on-off control.

Using the library.
The control BUTTON makes a button with text. The size of button is determined by the text dimension.
Example. Draw and read a button at x = 10, y = 20, text = Power, state = 0.

The button is determined by a structure. The format of the structure is as follows.
BUTTON b = {10, 20, "Power", 0};

To draw the button is necessary to define the type of font. The button takes the size automatically.
TFT_SetFont(Courier_New_Bold_20, 1);
Draw_Button(&b);

To Read the button the statement if or while can be used.
TFT_SetFont(Courier_New_Bold_20, 1);
if(Read_Button(&b) == 1) 
  {
   // Your Code Here.
  }

The control PUSH_BUTTON makes a push button.
Example. Draw and a read a push button at x = 10, y = 60, state = 0.

The push button is determined by a structure. The format of the structure  is as follows.
 PUSH_BUTTON pb = {10, 60, 0};

To draw the push button is used the following function.
Draw_PushButton(&pb);

To read the push button the statement while can be used.
while(Read_PushButton(&pb))
        {
         // Your Code Here.
        }

The control ON_OFF_SWITCH makes a on-off switch.
Example. Draw and read a switch at x = 10, y = 100, state = normally closed.

The on-off switch is determined by a structure. The format of the structure is as follows.
ON_OFF_SWITCH s = {10, 100, 1};

To draw an on-off switch is used the following function.
 Draw_Switch(&s);

To read an on-off switch the statement switch can be used.
switch(Read_Switch(&s))
          {
           case 0: /* Your Code Here */ break;
           case 1: /* Your Code Here */ break;
          }

The control POTENTIOMETER makes a potentiometer.
Example. Draw and make a potentiometer at x = 10, y = 140, range from -20 to 20, default value = 0, state = 0.

The potentiometer is defined by a structure. The format of the structure is as follows.
POTENTIOMETER p = {10, 140, -20, 20, 0, 0};

To draw the potentiometer is used the following function.
Draw_Potentiometer(&p);

To read the potentiometer the statement do while can be used.
do{
     Read_Potentiometer(&p);
     // Your Code Here
     Delay_ms(100);
    }while(p.state > 0);

Connection.




Saturday, August 20, 2016

nRF24L01+

The nRF24L01+ is a single chip 2.4GHz transceiver with an embedded baseband protocol engine (Enhanced ShockBurst™), suitable for ultra low power wireless applications.
Looking in eBay I found the nRF24L01+ in three different modules. I bought the smd module, but for testing is better the module with pin header.  


Description of library.

Initializes the nRF24L01 module.
NRF24L01_Init(mode, rf_channel)
  • mode: Sets RX_MODE or TX_MODE.
  • rf_channel: Sets the channel to be used.
Example:
NRF24L01_Init(TX_MODE, 0x20);

Sends a data from Transmitter to Receiver. 
NRF24L01_SendData(buffer)
  • buffer: Data to be sent.
Example:
unsigned char data[32] = {'P', 'I', 'C', '1', '8', 'F', '4', '5', '5', '0'};
NRF24L01_SendData(data);

Reads the interrupt.
NRF24L01_DataReady(void)
This function reads the STATUS and returns a 0 logic if the receiver got a new data.
  • return 0: When is available  a data.
  • return 1: When  isn't available a data.
Example:
while(NRF24L01_DataReady()){}

Reads a data received from transmitter. 
NRF24L01_ReadData(buffer)
  • buffer: Saves the data received. 
Example:
unsigned char buffer1[32];
while(NRF24L01_DataReady()){}
NRF24L01_ReadData(buffer1);


Sets the nRF24L01 as RX or TX mode.
NRF24L01_SetMode(mode)

  • mode: Sets RX_MODE or TX_MODE.
Example:
NRF24L01_SetMode( RX_MODE);

 
Sets a channel.
NRF24L01_SetChannel(rf_channel)
  • rf_channel: Sets a new channel.
Example:
NRF24L01_SetChannel(0x45);

Gets the channel used
NRF24L01_GetChannel(void) 
  • return the channel used.
Example:
unsigned char channel;
channel = NRF24L01_GetChannel();

Example 1. Simplex communication.
This video shows a system simplex, where the transmitter sends a byte to receiver. The receiver gets the byte and set the value binary at the PORTB.


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.