Commit 67dd2bca authored by Cheng Pan's avatar Cheng Pan 😁

Update week09.md

parent e9a705ad
Pipeline #152547 passed with stages
in 46 seconds
......@@ -13,7 +13,22 @@
[ATtiny44Datasheet](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/blob/master/docs/images/week09/ATtiny44Datasheet.pdf)
## Connection for my board
Pin configurations:
![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200323232044.png)
| ISP Pin used on my board | FTDI Pin used on my board |
| ------------------------ | ------------------------- |
|![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200323231514.png)|![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200323231448.png)|
The pins I have used for my board:
![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/datasheet_screenshots.jpg)
## program your board to do something
### Connection for my board
An ISP cable was used to connect my board to an existing programmer like FabISP or Arduino. I used a working FabISP as the programmer to program my new made PCB.
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200315000603.jpg)
......@@ -21,7 +36,7 @@ I downloaded the `echo.c` and `echo.c.make` file from [Neil's page](http://acade
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200317000522.png)
## Make fuses
### Make fuses
What is fuses?
There are 3 bytes of permanent storage in the chip called 'fuse low byte', 'fuse high byte' and 'fuse extended byte'. These bytes are called fuses and can be reprogrammed as many times as you want and determines the behaviour of the chip. To do that, their value is not erased when the chip is powered off or reprogrammed.
......@@ -50,9 +65,9 @@ two new files in the dictionary:
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200314152450.png)
## Use Arduino for programming
### Use Arduino for programming
### Arduino IDE setting:
#### Arduino IDE setting:
Followed the [tutorial](http://fabacademy.org/2019/docs/FabAcademy-Tutorials/week08_embedded_programming/attiny_arduino.html)
......@@ -74,17 +89,20 @@ Installing ATtiny support in Arduino using the built-in boards manager.
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200317101918.png)
The description in make file:
The description in **make** file:
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200317103620.png)
### Programming:
!!! tip
Use **USE PROGRAMMER TO UPLOAD** not directly use **UPLOAD**
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200317103248.png)
Codes:
#### Programming 1:
Use button to control LED
##### Codes:
```
int buttonPin = 3; /refer to ATtiny44 datasheet
int ledPin =7; /refer to ATtiny44 datasheet
......@@ -107,14 +125,50 @@ void loop() {
}
```
### Reference
##### Outcome:
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week07/attiny_pinout.jpeg)
<video width = "500" controls>
<source src = "https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/WeChat_20200314235820.mp4" type = "video/mp4">
</video>
#### Programming 2:
## Testing
Blink test
##### Codes:
```
int ledPin = 7; /refer to ATtiny44 datasheet
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH); /turn the LED on
delay(1000); /wait for a second
digitalWrite(ledPin, LOW); /turn the LED off
delay(1000); /wait for a second
}
```
##### Outcome:
<video width = "500" controls>
<source src = "https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/WeChat_20200314235820.mp4" type = "video/mp4">
<source src = "https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/b8ac2ff9bc28d8887b62dd34d4bd18f6.mp4">
</video>
I found a problem: the delay time in my program is 1 second, but it seemed to be about 8 seconds.
This is probably because we are using the fuse file written in C by Niel, which may not contain the "divide by 8" fuse setting which is more commonly set for microcontrollers. Arduino expects the "divide by 8" setting on microcontroller and tries to make up for that. In our case, it slows down because our board works in normal speed. After burning the bootloader, the microcontroller's setting matchs with Arduino's, and the 8x slower issue gets solved.
![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200324020955.png)
![](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week09/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20200324020631.png)
### Reference
![image](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/raw/master/docs/images/week07/attiny_pinout.jpeg)
## Original files:
[Blink.ino](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/blob/master/docs/original%20files/week09/Blink.ino)
[Buttom control LED.ino](https://gitlab.fabcloud.org/academany/fabacademy/2020/labs/oshanghai/students/pan-cheng/blob/master/docs/original%20files/week09/Buttom_control_LED.ino)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment