You are here:   Blog
  |  Login

View_Blog

Minimize
Dec 27

Written by: Rimon
12/27/2010 6:24 AM  RssIcon

I got the microcontroller Teensy++ http://www.pjrc.com/teensy/index.html and I have a stander 8X2 LCD, and I wrote the driver in C to write strings to my LCD, here I am writing my name :-)

IMAGE_013

 

 

/*
* LCD Write
* By: Rimon Tadros
*
*/

void setup()                    // run once, when the sketch starts
{
  InitializePorts();           //makes the pins as output pins
  SetDisplay();
  ConfigDisplay();
  ClearDisplay();
  WriteString("Rimon");
  SelectSecondLine();
  WriteString("Tadros");
}

void InitializePorts()
{
  for(int i = 0; i < 8 ; i++)
  {
     pinMode(PIN_D0+i, OUTPUT);
  }
  pinMode(PIN_E0, OUTPUT);     
  pinMode(PIN_C0, OUTPUT);     
}

void SelectSecondLine()
{
  SendData(B11000000, true);
}

void ConfigDisplay()
{
  SendData(B00111100, true);
}

void SetDisplay()
{
  SendData(B00001100, true);
}

void ClearDisplay()
{
  SendData(B00000001, true);
}

void WriteString(char* x)
{
  int index=0;
  while(x[index] != '\0')
  {
     WriteChar(x[index]);
     index++;
  }
}

void WriteChar(char x)
{
  SendData(x,false);
}

void SendData(char x, boolean command)
{
  for(int i = 0; i < 8 ; i++)
  {
    if( (x>>i) & 0x01  == 0x01)
      digitalWrite(i, HIGH);
    else
      digitalWrite(i, LOW);
  }
  if(command)
    digitalWrite(PIN_E0, LOW);
  else
    digitalWrite(PIN_E0, HIGH);
  digitalWrite(PIN_C0, HIGH);
  delay(1);
  digitalWrite(PIN_C0, LOW);
}

 

void loop()                     // run over and over again
{

//nothing to do here ;)
}

Categories:
Location: Blogs Parent Separator Blog

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

Search_Blog

Minimize

Blog_Archive

Minimize