BRITOV DENIS

Status:

 

Week 7: embedded programming

COMPLEATED

It's time to use our FabISP programmer. I have installed Arduino software and also installed Attiny drivers in it.

Attiny library you can find here: https://github.com/damellis/attiny/

 

To install library:

 

 

 

Our helloBoard using Attiny44 with external 20MHz sourse.

So before programming i chosen:

Board:Attiny

Clock: 20MHz

Prcs: ATtiny44

 

Using a standart scatch and changing pin numbers i programmed my HelloWorld board.

The result you can see on the video:

 

So, it works and now i can play with my own code. My first attemp was to use fade effect.

Here is my code:

 

const int buttonPin = 3;     // the number of the pushbutton pin

const int ledPin =  7;      // the number of the LED pin

 

// variables will change:

int buttonState = 0;         // variable for reading the pushbutton status

int brightness = 0;

int fadeAmount = 5;

void setup() {

  // initialize the LED pin as an output:

  pinMode(ledPin, OUTPUT);

  // initialize the pushbutton pin as an input:

  pinMode(buttonPin, INPUT);

}

 

void loop() {

  // read the state of the pushbutton value:

  buttonState = digitalRead(buttonPin);

 

  // check if the pushbutton is pressed.

  // if it is, the buttonState is HIGH:

  if (buttonState == LOW) {

    // turn LED on:

     // set the brightness of pin 9:

  analogWrite(ledPin, brightness);

 

  // change the brightness for next time through the loop:

  brightness = brightness + fadeAmount;

 

  // reverse the direction of the fading at the ends of the fade:

  if (brightness == 0 || brightness == 255) {

    fadeAmount = -fadeAmount ;

  }

  // wait for 30 milliseconds to see the dimming effect

  delay(30);

  }

  else {

    // turn LED off:

    digitalWrite(ledPin, LOW);

  }

}

 

Next attemt was to program SOS signal. It looks like:

Here is my code:

 

 

 

 

const int buttonPin = 3;     // the number of the pushbutton pin

const int ledPin =  7;      // the number of the LED pin

 

// variables will change:

int buttonState = 0;         // variable for reading the pushbutton status

int k = 0;

void setup() {

  // initialize the LED pin as an output:

  pinMode(ledPin, OUTPUT);

  // initialize the pushbutton pin as an input:

  pinMode(buttonPin, INPUT);

}

 

void loop() {

  // read the state of the pushbutton value:

  buttonState = digitalRead(buttonPin);

 

  // check if the pushbutton is pressed.

  // if it is, the buttonState is HIGH:

  if (buttonState == LOW) {

  k = 1;

 

  if (k == 1) {

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(1000);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(1000);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(1000);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    delay(1000);

    digitalWrite(ledPin, HIGH);

    delay(100);

    digitalWrite(ledPin, LOW);

    k = 0;

  }

 

  }

  else {

    // turn LED off:

    digitalWrite(ledPin, LOW);

  }

}