venerdì 5 dicembre 2014

ATtiny85 - terza parte

PASSO 7
Caricare lo sketch rammmentadosi che non tutte le istruzioni di Arduino Uno vengono accettate, della piedinatura del chip e della non eccessiva memoria dell'ATtiny.
Non confondere il pin del chip con la porta.

Sketch di prova:blink

     /* Piedinatura di ATtiny85
         PB0 (0) = pin 5 tested
         PB1 (1) = pin 6 tested
         PB2 (2) = pin 7 tested
         PB3 (3) = pin 2 tested
         PB4 (4) = pin 3 tested (mio led)
         PB5 (5) = pin 1 non riuscito.Forse perchè è anche RESET?
         
      */

      # define LED 4
      void setup()
          
          { pinMode(LED, OUTPUT);}
       
      void loop() {
     
        digitalWrite(LED, HIGH);
        delay(300);
        digitalWrite(LED, LOW);
        delay(300);
      
      }


Sketch di prova: ATtiny85 lancia un S.O.S.



      #define  LED  4 // PB4 pin 3 di ATtiny
      #define  BUT  3 // PB3 pin 2 di ATtiny

      int buttonState = 0;

      void setup()
                 { pinMode(LED, OUTPUT); 
                   pinMode(BUT, INPUT);  }
      
      void loop(){

        buttonState = digitalRead(BUT);
        if ( buttonState == HIGH)
           { digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(200);             
             digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(200);  
             digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(500); 
         
             digitalWrite(LED, HIGH);
             delay(200);
             digitalWrite(LED, LOW);
             delay(200);             
             digitalWrite(LED, HIGH);
             delay(200);
             digitalWrite(LED, LOW);
             delay(200);      
             digitalWrite(LED, HIGH);
             delay(200);
             digitalWrite(LED, LOW);
             delay(500);

             digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(200);             
             digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(200);  
             digitalWrite(LED, HIGH);
             delay(400);
             digitalWrite(LED, LOW);
             delay(1200); } 
 
      }

Nessun commento:

Posta un commento