<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; SERVO MOTOR SG90]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=670&amp;type=atom" />
	<updated>2024-09-22T10:26:09Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=670</id>
		<entry>
			<title type="html"><![CDATA[Re: SERVO MOTOR SG90]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=10775#p10775" />
			<content type="html"><![CDATA[<p>Attiny13 примеры для SG90</p><p>Выход управления PB0</p><p>Медленное изменения угла поворота сервопривода:<br /></p><div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;


int main(void) {
   DDRB |=(1&lt;&lt;PB0);        
 
while(1) { 
   for(int i=0;i&lt;=170;i++){
      servoPulse(i);
      _delay_ms(30);
  }
  
  
  for(int i=170;i&gt;=0;i--){
      servoPulse(i);
      _delay_ms(30);
  }  
  }
}

void servoPulse(int angle){
  int times = ((angle * 11) + 500)/10; 
  PORTB |= (1&lt;&lt;PB0);
  for(int n=0;n&lt;times;n++){_delay_us(10);} 
  PORTB &amp;=~ (1&lt;&lt;PB0);
  for(int n=0;n&lt;2000-times;n++){_delay_us(10);} 
}</code></pre></div><br /><p>Быстрое изменения угла поворота сервопривода:<br /></p><div class="codebox"><pre><code>#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;

int val;

int main(void) {
   DDRB |=(1&lt;&lt;PB0);        
 
while(1) { 
      val = 0;
      for (int i = 0; i &lt;= 50; i++){servoPulse(val);}
      _delay_ms(1000);
      val = 90;
      for (int i = 0; i &lt;= 50; i++){servoPulse(val);}
      _delay_ms(1000);
      val = 160;
      for (int i = 0; i &lt;= 50; i++){servoPulse(val);}
      _delay_ms(1000);
      val = 90;
      for (int i = 0; i &lt;= 50; i++){servoPulse(val);}
      _delay_ms(1000);
}}

void servoPulse(int angle){
  int times = ((angle * 11) + 500)/10; 
  PORTB |= (1&lt;&lt;PB0);
  for(int n=0;n&lt;times;n++){_delay_us(10);} 
  PORTB &amp;=~ (1&lt;&lt;PB0);
  for(int n=0;n&lt;2000-times;n++){_delay_us(10);} 
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2024-09-22T10:26:09Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=10775#p10775</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: SERVO MOTOR SG90]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=10774#p10774" />
			<content type="html"><![CDATA[<p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/374a1a618579d08c813cbcac20dd04d6.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/374a1a618579d08c813cbcac20dd04d6.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/06ff8a9bd7d1db5f1c15ce38ffc49a04.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/06ff8a9bd7d1db5f1c15ce38ffc49a04.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/d88391f85971bb70c77479741d268196.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/d88391f85971bb70c77479741d268196.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/a6c3c6ef5209eac7415c293d2f23369a.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/a6c3c6ef5209eac7415c293d2f23369a.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/2b2a1f19d4ea57cb591ce093e6927769.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/2b2a1f19d4ea57cb591ce093e6927769.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/01a5e9f1fabf77df3206f2a25023607a.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/01a5e9f1fabf77df3206f2a25023607a.png" /></span> </p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2024/09/17c50a01f6bc66aa8f54e7bae794fae0.png" alt="http://forum.rcl-radio.ru/uploads/images/2024/09/17c50a01f6bc66aa8f54e7bae794fae0.png" /></span></p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2024-09-20T17:08:50Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=10774#p10774</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: SERVO MOTOR SG90]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=10770#p10770" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>/* Sweep
 by BARRAGAN &lt;http://barraganstudio.com&gt;
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include &lt;Servo.h&gt;

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos &lt;= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable &#039;pos&#039;
    delay(30);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos &gt;= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable &#039;pos&#039;
    delay(30);                       // waits 15ms for the servo to reach the position
  }
}</code></pre></div><div class="codebox"><pre><code>int servoPin = 9; // сигнальный провод от серво на порт 9

void setup()
{
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){

for(int i=0;i&lt;=180;i++){
      servoPulse(servoPin, i);
      delay(30);
}
delay(100); 
for(int i=180;i&gt;=0;i--){
      servoPulse(servoPin, i);
      delay(30);
}    
  
}

// define a servo pulse function
void servoPulse(int pin, int angle){
  int timess;
 // for (int i_ = 0; i_ &lt;= 5; i_++) {
  timess = map(angle, 0,180,  544, 2400); 
  digitalWrite(pin, HIGH); // set the level of servo pin as high
  delayMicroseconds(timess); // delay microsecond of pulse width
  digitalWrite(pin, LOW); // set the level of servo pin as low
  delay(20 - timess / 1000);
}//}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2024-09-19T05:43:17Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=10770#p10770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[SERVO MOTOR SG90]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=10754#p10754" />
			<content type="html"><![CDATA[<p>Основная статья - <a href="http://rcl-radio.ru/?p=132542">http://rcl-radio.ru/?p=132542</a></p><br /><div class="codebox"><pre><code>int servoPin = 9; // сигнальный провод от серво на порт 9
int val;

void setup()
{
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
  Serial.println(&quot;Servo is ready&quot;);
}

void loop(){
      val = 0;
      for (int i = 0; i &lt;= 50; i++){servoPulse(servoPin, val);}
      delay(1000);
      val = 90;
      for (int i = 0; i &lt;= 50; i++){servoPulse(servoPin, val);}
      delay(1000);
      val = 180;
      for (int i = 0; i &lt;= 50; i++){servoPulse(servoPin, val);}
      delay(1000);
      val = 90;
      for (int i = 0; i &lt;= 50; i++){servoPulse(servoPin, val);}
      delay(1000);
}

// define a servo pulse function
void servoPulse(int pin, int angle){
  int pulseWidth = map(angle, 0, 180 , 544, 2480); 
  Serial.println(pulseWidth);
  digitalWrite(pin, HIGH); // set the level of servo pin as high
  delayMicroseconds(pulseWidth); // delay microsecond of pulse width
  digitalWrite(pin, LOW); // set the level of servo pin as low
  delayMicroseconds(20000 - pulseWidth);
}</code></pre></div><div class="codebox"><pre><code>/* Sweep
 by BARRAGAN &lt;http://barraganstudio.com&gt;
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include &lt;Servo.h&gt;

Servo myservo;  // create servo object to control a servo

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {

    myservo.write(0);    
    delay(1000);  
    myservo.write(90);    
    delay(1000); 
    myservo.write(180);    
    delay(1000);  
    myservo.write(90);    
    delay(1000);     
  
 
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2024-09-16T08:16:57Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=10754#p10754</id>
		</entry>
</feed>
