<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; ATMEGA8 + LCD1602_I2C]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=498&amp;type=atom" />
	<updated>2022-07-18T03:32:38Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=498</id>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6455#p6455" />
			<content type="html"><![CDATA[<p><a href="http://rcl-radio.ru/?p=100721">http://rcl-radio.ru/?p=100721</a></p><p>Можно заменить, схема аналогичная,&nbsp; на reset резистор 10 К к +5В, кварц на xtal1 xtal2 c емкостями 22 пФ</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-07-18T03:32:38Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6455#p6455</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6454#p6454" />
			<content type="html"><![CDATA[<p>можно ли заменить ардуино на атмега 16 так же как и атмега 8, если можно то какая схема</p>]]></content>
			<author>
				<name><![CDATA[sanj76a]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=569</uri>
			</author>
			<updated>2022-07-18T03:26:01Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6454#p6454</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6425#p6425" />
			<content type="html"><![CDATA[<p>не по этой теме к вам вопрос уже давно жду<br /><a href="http://forum.rcl-radio.ru/viewtopic.php?id=489&amp;p=4">http://forum.rcl-radio.ru/viewtopic.php?id=489&amp;p=4</a></p>]]></content>
			<author>
				<name><![CDATA[sanj76a]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=569</uri>
			</author>
			<updated>2022-07-14T18:07:06Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6425#p6425</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6423#p6423" />
			<content type="html"><![CDATA[<p>Схемы нет. Это просто макетная плата, кварц с двумя конденсаторами, резистор 10 К на RESET и все, больше там ничего нет</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-07-14T15:55:03Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6423#p6423</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6419#p6419" />
			<content type="html"><![CDATA[<p>какие функции, для чего она, название ее ,а схема есть? Сам хочу собрать.</p>]]></content>
			<author>
				<name><![CDATA[sanj76a]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=569</uri>
			</author>
			<updated>2022-07-14T02:33:18Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6419#p6419</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6418#p6418" />
			<content type="html"><![CDATA[<p>Эта макетная плата для atmega8 48 88 168 328 в dip корпусе, продается на Алиэкспресс, покупал за 150 р в наборе для самостоятельной пайки</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-07-14T02:16:56Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6418#p6418</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6417#p6417" />
			<content type="html"><![CDATA[<p>У вас в статье на фото плата с ATMEGA8 на зажимной панельке (там еще USB разъем), что за плата, для чего она?</p>]]></content>
			<author>
				<name><![CDATA[sanj76a]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=569</uri>
			</author>
			<updated>2022-07-14T02:10:54Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6417#p6417</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[ATMEGA8 + LCD1602_I2C]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6414#p6414" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;

#define RS           0
#define E            2
#define LED          3
#define ADDR_LED     0x27

byte led_b;

int main(){
  wire_set(8000000,100000); // тактовая частота контроллера, частота шины I2C
  setInit();
  Clear(); // очистка экрана
  led(1);  // включение и отключение подсветки экрана

 // собственные символы, 0...7  
  Write(0,        0b11111,
                  0b00000,
                  0b10001,
                  0b10001,
                  0b10001,
                  0b10001,
                  0b00000,
                  0b11111);
                  
  Write(1,        0b11111,
                  0b10001,
                  0b11111,
                  0b10001,
                  0b11111,
                  0b10001,
                  0b11111,
                  0b00000);    

  Curs(0,0);
  PrintString(&quot;HELLO &quot;);
  PrintFloat(-1.2344, 3);
  Curs(1,0);
  PrintInt(-12345);
  PrintChar(0);             // вывод собственного символа 0
  PrintChar(1);             // вывод собственного символа 1
  
while(1){
  
  }  
  }



void led(bool led_on_off){
    if(led_on_off==1){i2c_write_1bit(led_b |= (1&lt;&lt;LED));}
    if(led_on_off==0){i2c_write_1bit(led_b &amp;=~ (1&lt;&lt;LED));}
}

void Write(byte addr_w, byte wr1,byte wr2,byte wr3,byte wr4,byte wr5,byte wr6,byte wr7,byte wr8){
     lcd(0b01000000|addr_w*8);PrintChar(wr1);PrintChar(wr2);PrintChar(wr3);PrintChar(wr4);PrintChar(wr5);PrintChar(wr6);PrintChar(wr7);PrintChar(wr8);}

void PrintInt(int data_int){char str[6];PrintString(itoa(data_int, str, 10));} 

void PrintFloat(float data_float, byte dp){
    char str[8];
    if(data_float&lt;0){data_float=-data_float;PrintChar(0b101101);PrintString(itoa((int)data_float, str, 10));}
     else{PrintString(itoa((int)data_float, str, 10));}
    int float10 = round((data_float - (int)data_float)*pow(10,dp));
    PrintChar(0b101110);
    PrintString(itoa(float10, str, 10));
} 

void setInit(){ 
    lcd(0x03);_delay_us(4500);
    lcd(0x03);_delay_us(4500);
    lcd(0x03);_delay_us(200);
    lcd(0b00000010);_delay_ms(5);
    lcd(0b00001100);_delay_ms(5);
    lcd(0b00000001);
} 

void Clear(){lcd(0b00000001);} 

void Curs(byte str, byte mesto){
  if(str==0){lcd(0b10000000+mesto);}
  if(str==1){lcd(0b11000000+mesto);}
  } 

void PrintString(const char* str) {while(*str != &#039;\0&#039;) {_delay_us(200);PrintChar(*str);str++;}}

void PrintChar(const char chr) {lcdSend(false, (uint8_t)chr);}

void e_pin(){
    i2c_write_1bit(led_b |= (1&lt;&lt;E));
    _delay_us(200);
    i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;E));
}

void lcd(uint8_t sett) {lcdSend(true, sett);}

void lcdSend(bool rs, byte data) {
    if(rs==0){led_b |= (1&lt;&lt;RS);} else {led_b &amp;= ~(1&lt;&lt;RS);}//RS
    _delay_us(200);
    if(((data &gt;&gt; 7) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;7));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;7));}
    if(((data &gt;&gt; 6) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;6));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;6));}
    if(((data &gt;&gt; 5) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;5));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;5));}
    if(((data &gt;&gt; 4) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;4));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;4));}
    e_pin();
    if(((data &gt;&gt; 3) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;7));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;7));}
    if(((data &gt;&gt; 2) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;6));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;6));}
    if(((data &gt;&gt; 1) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;5));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;5));}
    if(((data &gt;&gt; 0) &amp; 1) ==1){i2c_write_1bit(led_b |= (1&lt;&lt;4));} else {i2c_write_1bit(led_b &amp;= ~(1&lt;&lt;4));}
    e_pin();
}

void i2c_write_1bit(byte i2c_reg){
  wire_start_w(ADDR_LED);
  wire_write(i2c_reg);
  wire_stop();
}    

////// I2C ////////////
void wire_set(long f_clock, long i2c_clock){
   TWBR = (((f_clock)/(i2c_clock)-16 )/2) ;
   TWSR = 0;
}

void wire_start_w(byte i2c_addr){
   TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWSTA)|(1&lt;&lt;TWEN);  
  while (!(TWCR &amp; (1&lt;&lt;TWINT)));
   TWDR = i2c_addr &lt;&lt; 1;
   TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);
  while (!(TWCR &amp; (1&lt;&lt;TWINT)));
}

void wire_write(byte i2c_data){
   TWDR = i2c_data;
   TWCR = (1&lt;&lt;TWINT) | (1&lt;&lt;TWEN);
  while (!(TWCR &amp; (1&lt;&lt;TWINT)));
}

void wire_stop(){  
   TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWSTO); 
}</code></pre></div><div class="quotebox"><blockquote><p>Скетч использует 3068 байт (37%) памяти устройства. Всего доступно 8192 байт.<br />Глобальные переменные используют 9 байт (0%) динамической памяти, оставляя 1015 байт для локальных переменных. Максимум: 1024 байт.</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-07-13T07:09:01Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6414#p6414</id>
		</entry>
</feed>
