小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ATTiny85 Arduino開發(fā)環(huán)境搭建及使用-CSDN博客

 共同成長(zhǎng)888 2024-12-06

Arduino ATTiny85開發(fā)環(huán)境搭建及使用

ATTiny85開發(fā)板有以下兩種:

第一種:可直接插入U(xiǎn)SB口:

第二種:需要通過USB線來連接電腦:

ATTiny85芯片介紹

Arduino IDE下載及安裝

Arduino官網(wǎng)Software | Arduino下載最新版Arduino IDE并安裝。

或使用安裝版Arduino IDE。添加ATTiny85開發(fā)板庫

在線安裝:

Arduino IDE下文件-首選項(xiàng)-附加開發(fā)板管理器網(wǎng)址,添加

http:///package_digistump_index.json

Arduino IDE下工具-開發(fā)板-開發(fā)板管理器,搜索找到Digistump AVR Boards項(xiàng)安裝。

上面的方法可能會(huì)存在json無法解析的問題

如果無法安裝請(qǐng)使用下面的離線安裝方式。

離線安裝:

將“DigistumpArduino-master.zip”解壓到Arduino IDE安裝目錄下的hardware文件夾下:

打開DigistumpArduino-master-tools文件夾,解壓“micronucleus-2.0a4-win.zip”到當(dāng)前目錄

打開Arduino IDE 工具-開發(fā)板如下圖所示,發(fā)現(xiàn)新增加的“Digistump AVR Boards”即可。

Arduino ATTiny85驅(qū)動(dòng)安裝

PC首次連接Arduino ATTiny85需安裝USB驅(qū)動(dòng),注意如果你的電腦是第一次連接ATTiny85開發(fā)板則會(huì)聽到USB設(shè)備連接的提示音,不過過了大概5秒左右就斷開連接了,這是因?yàn)闊o法識(shí)別USB驅(qū)動(dòng)造成的。如果不是第一次連接則可能再次插入ATTiny85時(shí)計(jì)算機(jī)就沒有反應(yīng)了。

在以下網(wǎng)址下載:

https://github.com/digistump/DigistumpArduino/releases/download/1.6.7/Digistump.Drivers.zip

驅(qū)動(dòng)正確安裝后在設(shè)備管理器中顯示如下:

程序編譯及下載

ATTiny85開發(fā)板選擇“Digispark(Default – 16.5mhz)”

Arduino IDE 文件-示例下的例程是針對(duì)Digistump開發(fā)板的

打開示例程序Start.ino,工具-開發(fā)板 選擇Digispark(Default – 16.5mhz)

選擇 項(xiàng)目-上傳,注意此時(shí)不要連接ATTiny85開發(fā)板,出現(xiàn)下圖所示的提示后再連接開發(fā)板

燒錄成功的提示如下:

ATTiny85 Pinout

DigitalWrite:

  1. void setup() {
  2. //All pins are capable of Digital output, though P5 is 3 V at HIGH instead of 5 V
  3. pinMode(0, OUTPUT); //0 is P0, 1 is P1, 2 is P2, etc. - unlike the analog inputs, for digital outputs the pin number matches.
  4. }
  5. void loop() {
  6. digitalWrite(0,HIGH); //Turn the pin HIGH (5 V)
  7. delay(1000);
  8. digitalWrite(0,LOW); //Turn the pin LOW (GND)
  9. delay(1000);
  10. }

Digital Read:

注:ATtiny上的內(nèi)部上拉電阻(在將管腳設(shè)置為輸出后通過調(diào)用digitalWrite(0)打開,其中0是管腳編號(hào))比Arduino上的要弱得多(約25千歐),因此板載LED會(huì)干擾它們。如果需要,可以使用其他端口。將電路更改為不需要內(nèi)部上拉,大家可以加入遠(yuǎn)望創(chuàng)客學(xué)堂QQ群, 一起學(xué)習(xí)新知識(shí)。刪除& —等特殊字符18&751-82&17?;蚯袛郘ED軌跡。對(duì)于型號(hào)A,這將適用于型號(hào)B的P1,這將應(yīng)用于P0。(型號(hào)標(biāo)識(shí))

  1. int sensorValue = 0;
  2. void setup() {
  3. //All pins are capable of digital input.
  4. pinMode(0, INPUT); //0 is P0, 1 is P1, 2 is P2, etc. - unlike the analog inputs, for digital inputs the pin number matches.
  5. }
  6. void loop() {
  7. sensorValue = digitalRead(1); //Returns HIGH or LOW (true or false / 1 or 0).
  8. }

Analog Read:

  1. int sensorValue = 0;
  2. void setup() {
  3. //You need not set pin mode for analogRead - though if you have set the pin to
  4. //output and later want to read from it then you need to set pinMode(0,INPUT);
  5. //where 0 is the physical pin number not the analog input number.
  6. //
  7. //See below for the proper pinMode statement to go with each analog read.
  8. }
  9. void loop() {
  10. // The analog pins are referenced by their analog port number, not their pin
  11. //number and are as follows:
  12. sensorValue = analogRead(1); //Read P2
  13. //To set to input: pinMode(2, INPUT);
  14. //THIS IS P2, P2 is analog input 1, so when you are using analog read, you refer to it as 1.
  15. //sensorValue = analogRead(2); //Read P4
  16. //To set to input: pinMode(4, INPUT);
  17. //THIS IS P4, P4 is analog input 2, so when you are using analog read, you refer to it as 2.
  18. //sensorValue = analogRead(3); //Read P3
  19. //To set to input: pinMode(3, INPUT);
  20. //THIS IS P3, P3 is analog input 3, so when you are using analog read, you refer to it as 3.
  21. //sensorValue = analogRead(0); //Read P5
  22. //To set to input: pinMode(5, INPUT);
  23. //THIS IS P5, P5 is analog input 0, so when you are using analog read, you refer to it as 0.
  24. }

Analog Write:

  1. void setup() {
  2. //P0, P1, and P4 are capable of hardware PWM (analogWrite).
  3. pinMode(0, OUTPUT); //0 is P0, 1 is P1, 4 is P4 - unlike the analog inputs,
  4. //for analog (PWM) outputs the pin number matches the port number.
  5. }
  6. void loop() {
  7. analogWrite(0,255); //Turn the pin on full (100%)
  8. delay(1000);
  9. analogWrite(0,128); //Turn the pin on half (50%)
  10. delay(1000);
  11. analogWrite(0,0); //Turn the pin off (0%)
  12. delay(1000);
  13. }

 如果需要實(shí)現(xiàn)USB HID并且對(duì)管腳要求不多的場(chǎng)合可以考慮使用這個(gè)板子。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多