Embedded programming

I use Arduino as Arduino ISP to program the board

1.Library

Open the preferences dialog in the Arduino software. Find the “Additional Boards Manager URLs” field near the bottom of the dialog.

Paste the following URL into the field (use a comma to separate it from any URLs you’ve already added):

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Click the OK button to save your updated preferences.

Open the boards manager in the “Tools > Board” menu.

Scroll to the bottom of the list; you should see an entry for “ATtiny”.

The word “installed” should now appear next to the title of the ATtiny entry.

2. ArduinoISP

Now I need to load ArduinoISP and update it to Arduino. The function of this step is to make the board as ArduinoISP and then program my helloboard.

3. Code

The function of this code is using switch to control the operation of LED

int led1 = 2;    // the led1 connect on the pin 11on Attiny44( PA2 on Attiny44 is correspond 2 on Arduino  )
int led2 = 7;    // the led2 connect on the pin6 on Attiny44( PA7 on Attiny44 is correspond 7 on Arduino  )
int  buttonpin=3;  // the number of the button on the pin10 on Attiny44( PA3 on Attiny44 is correspond 3 on Arduino  )
int buttonstate=0; //define the orign station of button

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(buttonpin, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the state of the button value:
  buttonstate = digitalRead(buttonpin);
  // check if the button is pressed. If it is, the buttonState is HIGH:
  if (buttonstate == HIGH) {
 digitalWrite(2, HIGH);  
  delay(1000);
  digitalWrite(2,LOW);
  delay(1000);
  } 

  else {
   digitalWrite(2, HIGH);  
  delay(50);
  digitalWrite(2,LOW);
  delay(50);
  }
}

4. Attiny 44 and Arduino

I use attiny 44 and get the detail in the following link:Attiny 44

According to the above pinout ,I can basic know which pin I need in my design.

Most of time I use Arduino to program code in my board. So I learn the following picture to know which pin is OK for me.

So in my Embedded programming I coding it like this

int led1 = 2;    // the led1 connect on the pin 11on Attiny44( PA2 on Attiny44 is correspond 2 on Arduino  )
int led2 = 7;    // the led2 connect on the pin6 on Attiny44( PA7 on Attiny44 is correspond 7 on Arduino  )
int  buttonpin=3;  // the number of the button on the pin10 on Attiny44( PA3 on Attiny44 is correspond 3 on Arduino  )

5. Connection

I connect the wire according the following

Attiny44 Arduino
slave reset 10
MISO 12
SCK 13
VCC VCC
GND GND
led1 2
led2 7
buttonpin 3

connect a 10 uF capacitor between RESET and GND on arduino.

6. Test

When i use it ,it isn't normal . I check the design and found one of the wire didn't connect to the chip. So I use a hand drill to make two hole near the chip and solder a wire to connect two pin on the board.

Now it can running ,and I attach the video.

7. Attachment:

results matching ""

    No results matching ""