user78063: Another beginner to arduino device.
My knowledge for programming is so weak.
As i mention to the title i would like your help.
I just want to run this simple sketch into attiny85 for lets say 1 min and then chip goes to sleepmode by its own.
My code is below but i cannot manage to achive what i want.
Any help?
Many thanks.
void setup() {

  pinMode(0, OUTPUT); 
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);    
  
  
}

void loop() {
  
                              // put your main code here, to run repeatedly:
  pinMode(0, OUTPUT); 
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);

  
  digitalWrite(0, HIGH);
  digitalWrite(1, LOW);  // 1
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, HIGH);   // 2
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);      //3
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //4
  digitalWrite(2, INPUT);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //5
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, HIGH);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //4
  digitalWrite(2, INPUT);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);     //3
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, HIGH);   // 2
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, HIGH);
  digitalWrite(1, LOW);  // 1
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);

  
}   


user7508: You can write, at the end of loop(), “if one minute has elapsed, then
go to sleep”. In C++, that would be:
if (millis() >= 60000)  // 60 seconds elapsed
    sleep_mode();

You will need to include <avr/sleep.h> in order to have access to the
sleep_mode() function. The sleep is likely to be very short though,
probably less than a millisecond, as the ATtiny will be waken up by the
next timer interrupt.
If you want a deeper, longer sleep, you could choose a different sleep
mode in setup():
set_sleep_mode(SLEEP_MODE_PWR_DOWN);

Read the datasheet if you want to know what wakeup sources are available
in each sleep mode.
Alternatively, if you want to make the ATtiny sleep forever (until the
next power cycle), call cli() in order to disable the interrupts,
right before calling sleep_mode().

78063: <p>Another beginner to arduino device.
My knowledge for programming is so weak.
As i mention to the title i would like your help.
I just want to run this simple sketch into attiny85 for lets say 1 min and then chip goes to sleepmode by its own.
My code is below but i cannot manage to achive what i want.
Any help?
Many thanks.</p>
<pre class="lang-cpp prettyprint-override"><code>void setup() {

  pinMode(0, OUTPUT); 
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);    
  
  
}

void loop() {
  
                              // put your main code here, to run repeatedly:
  pinMode(0, OUTPUT); 
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);

  
  digitalWrite(0, HIGH);
  digitalWrite(1, LOW);  // 1
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, HIGH);   // 2
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);      //3
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //4
  digitalWrite(2, INPUT);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //5
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, HIGH);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);   //4
  digitalWrite(2, INPUT);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);     //3
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, LOW);
  digitalWrite(1, HIGH);   // 2
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  delay(180);
  digitalWrite(0, HIGH);
  digitalWrite(1, LOW);  // 1
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);

  
}   
</code></pre>
 7508: <p>You can write, at the end of <code>loop()</code>, “if one minute has elapsed, then
go to sleep”. In C++, that would be:</p>
<pre class="lang-cpp prettyprint-override"><code>if (millis() &gt;= 60000)  // 60 seconds elapsed
    sleep_mode();
</code></pre>
<p>You will need to include <code>&lt;avr/sleep.h&gt;</code> in order to have access to the
<code>sleep_mode()</code> function. The sleep is likely to be very short though,
probably less than a millisecond, as the ATtiny will be waken up by the
next timer interrupt.</p>
<p>If you want a deeper, longer sleep, you could choose a different sleep
mode in <code>setup()</code>:</p>
<pre class="lang-cpp prettyprint-override"><code>set_sleep_mode(SLEEP_MODE_PWR_DOWN);
</code></pre>
<p>Read the datasheet if you want to know what wakeup sources are available
in each sleep mode.</p>
<p>Alternatively, if you want to make the ATtiny sleep forever (until the
next power cycle), call <code>cli()</code> in order to disable the interrupts,
right before calling <code>sleep_mode()</code>.</p>
