Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <stdlib.h>
- #include "lcd.h"
- uint8_t kontrast=50;
- void writeLCD() {
- lcd_clrscr();
- lcd_puts("Mia je best");
- }
- void povecaj() {
- if(kontrast < 250){
- kontrast +=5;
- if(kontrast > 100) {
- PORTA = 0b00000000;
- }
- }
- OCR1B = kontrast;
- }
- void smanji() {
- if(kontrast > 10) {
- kontrast -=5;
- if (kontrast < 100) {
- PORTA = 0b10000000;
- }
- }
- OCR1B = kontrast;
- }
- int main(void) {
- DDRD = _BV(4);
- DDRA = 0xff;
- PORTB = _BV(1) | _BV(2);
- DDRB = 0xff;
- TCCR1A = _BV(COM1B1) | _BV(WGM10);
- TCCR1B = _BV(WGM12) | _BV(CS11);
- OCR1B = kontrast;
- lcd_init(LCD_DISP_ON);
- while(1){
- if(bit_is_clear(PINB, 1)){
- povecaj();
- }
- if(bit_is_clear(PINB, 2)) {
- smanji();
- }
- _delay_ms(150);
- writeLCD();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement