00's Adventure

作业13:输出设备[FabNotes027]

这周的作业是

给微控制器电路板增加输出元件

电路板设计

用 ERC 和 DRC 工具检查错误。确保没有错误后,导出黑白 png 文件。

电路设计源文件

电路板制作

依旧是用 Roland SMR-20 雕刻电路板。

1/64 刀头刻线路, 1/32 刀头切边缘。

焊元件

然后烧程序

make -f hello.RGB.45.make

sudo make -f hello.RGB.45.make program-usbtiny

1
avr-objcopy -O ihex hello.RGB.45.out hello.RGB.45.c.hex;\
	avr-size --mcu=attiny45 --format=avr hello.RGB.45.out
AVR Memory Usage
----------------
Device: attiny45

Program:     338 bytes (8.3% Full)
(.text + .data + .bootloader)

Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)


avrdude -p t45 -P usb -c usbtiny -U flash:w:hello.RGB.45.c.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9206
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "hello.RGB.45.c.hex"
avrdude: input file hello.RGB.45.c.hex auto detected as Intel Hex
avrdude: writing flash (338 bytes):

Writing | ################################################## | 100% 0.49s

avrdude: 338 bytes of flash written
avrdude: verifying flash memory against hello.RGB.45.c.hex:
avrdude: load data flash data from input file hello.RGB.45.c.hex:
avrdude: input file hello.RGB.45.c.hex auto detected as Intel Hex
avrdude: input file hello.RGB.45.c.hex contains 338 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.72s

avrdude: verifying ...
avrdude: 338 bytes of flash verified

avrdude: safemode: Fuses OK (H:FF, E:DF, L:62)

avrdude done.  Thank you.

编程

在 Arduino 里面写程序。要先选好 ATtiny 板子,ATtiny45 芯片和 8 MHz internal clock。

1
int led1 = 1;           // the PWM pin the LED is attached to
int led2 = 2;
int led3 = 0;
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 1,2,3 to be an output:
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 1,2,3:
  analogWrite(led1, brightness);
  analogWrite(led2, brightness);
  analogWrite(led3, 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);
}

代码下载.

程序写好之后, Burn Bootloader 上传到电路板上。LED 开始工作:

课程资源

kidult00 wechat
扫码关注 00 的公众号
支持原创,五毛钱不嫌少~