You are here:   Blog
Register   |  Login

View Blog

Minimize
Apr 23

Written by: Rimon
4/23/2009 1:06 AM 

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 ;)
}

Tags:

2 comment(s) so far...

Re: Teensy++ LCD driver

Allah yr7m ayam ma kont saiblna mashro3 el ta5rog 3al maktab fe worx
nsit el 3rbia el maruti wel baby foot
miss u ya king

mimi :D

By Amr on   4/23/2009 2:16 AM

Re: Teensy++ LCD driver

mimi pasha, tab3an ana faker, miss you too ya gameel

By Rimon on   4/23/2009 9:02 AM

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

Blog Archive

Minimize

Search My Blog

Minimize