3

I'm electronics student. I'm a newbie in programming. I have loved C++ after watching some videos on C++. Am using Atmega32 uC, WinAVR GNU GCC compiler programming tool, 16*2 Hitachi HD4478OU LCD for my project.

I have connected 3 switches to PA1, PA2 and PA3. LCD connected to PORTC, PD6 and PD7. I want to write C++ program that will display on the LCD "SWITCH 1 IS PRESSED" when switch on is pressed, "SWITCH 2 IS PRESSED" when switch 2 is pressed and "SWITCH 3 IS PRESSED" when switch 3 is pressed and if no switch is pressed it should display "WELCOME" swinging from end to end. Each switch press should light a corresponding LED connected to PA1,PA2 and PA3.

Please somebody help me as this is my school project and I have only few months to submit it, the circuit is already built. I can write for the LED, but don't know how to write for the LCD and how to combine the two programs.

m.Alin
  • 10,638
  • 19
  • 62
  • 89
Fred
  • 31
  • 1
  • 3
  • Research the protocol used to communicate with the LCD, see if you connected to pins with a peripheral useful for that, or if you are going to have to bit-bang it in software. Since this is supposed to be a learning project, solving this yourself will be what brings you the benefit. – Chris Stratton Aug 01 '12 at 14:51
  • A driver in C++ for HD44780: https://github.com/amanuellperez/mcu/blob/master/src/dev/dev_LCD_HD44780_basic.h. A test to see how to use it https://github.com/amanuellperez/mcu/blob/master/src/dev/test/LCD/HD44780/main.cpp – Antonio Aug 26 '21 at 20:39

1 Answers1

1

You could learn a lot by looking at the Arduino libraries for LCD control.

http://code.google.com/p/arduino/source/browse/trunk/libraries/LiquidCrystal/LiquidCrystal.cpp

Toby Jaffey
  • 28,796
  • 19
  • 96
  • 150
  • you can even import the libraries with a bit of effort and use them in your own code. – jippie Aug 01 '12 at 20:34
  • @jippie, this is my first time am practicing program so please if you can help me please do, as am desperate because time is not on my side – Fred Aug 04 '12 at 21:22
  • I've read articles on Internet about re-using Arduino libraries in a non-Arduino AVR circuit. I remember reading about it, but I never done it myself. – jippie Aug 04 '12 at 21:30
  • Not sure, but I believe it is as simple as finding the Arduino library on your system, then use an `#include "/path/to/some/library.h"` in your source file. Install the Arduino IDE and give it a shot. – jippie Aug 04 '12 at 21:40
  • Hi All, I am a newbie in electronic, please somebody assist me to write a program using 6HOURS DELAY #include #include #define F_CPU 1000000 void deley_sec (long sec); void delay_6_hours (void); int main(void) { DDRD |=_BV(4); while(1) { PORTD |=_BV(4); void delay_6hours (long sec); PORTD &=~_BV(4); } } LED ON #include int main(void) { DDRB = 0xF8; PORTB = 0xFF; DDRA = 0xF0; while(1) { PORTA = PINB; } } Thank you in advance; – Fred Aug 14 '12 at 16:18
  • @Fred This site follows a question and answer format, it's not like a regular forum. Please raise a new question. – Toby Jaffey Aug 14 '12 at 16:33
  • hi All, Am a newbie in c++, but have develop interest after reading and watching videos about it. Please somebody help me identify the default clock fuse of my micro controller. Please my micro controller is ATMEGA32 16PU, please what is the meaning of the 16PU ? I know the 32 is i/o pins. Is the 16PU internal clock frequency ? I need to know that because I will want to set my fuse later, am not using external resonator – Fred Aug 20 '12 at 10:15