skip to main |
skip to sidebar
** Device: Joystick **
** File: EF_Joystick_Test.c **
** **
** Created by ElecFreaks Robi.W /10 June 2011 **
** **
** Description: **
** This file is a sample code for your reference. **
** **
** Copyright (C) 2011 ElecFreaks Corp. **
*********************************************************************/
iint FirstShotX , FirstShotY;
void setup()
{
for(int i=0; i<19; i++)
{
pinMode(i, INPUT);
digitalWrite(i, 1);
}
Serial.begin(9600);
FirstShotX = 0;
FirstShotY = 0;
}
void loop(){
int i, someInt, flag = 0;
for(i=4; i<11; i++)
{
someInt = digitalRead(i);
if(someInt == 0)
{
flag =1;
break;
}
}
if(flag == 1)
{
switch(i)
{
case 4: Serial.println("--------> Button A"); break;
case 5: Serial.println("--------> Button B"); break;
case 6: Serial.println("--------> Button C"); break;
case 7: Serial.println("--------> Button D"); break;
case 8: Serial.println("--------> Button E"); break;
case 9: Serial.println("--------> Button F"); break;
case 10: Serial.println("--------> Button KEY"); break;
default: break;
}
flag=0;
}
int sensorValue = analogRead(A0);
if(FirstShotX == 0)
{
FirstShotX = sensorValue;
Serial.print("FirstShotX = ");
Serial.println(FirstShotX);
}
Serial.print("X = ");
Serial.println(sensorValue - FirstShotX);
sensorValue = analogRead(A1);
if(FirstShotY == 0)
{
FirstShotY = sensorValue;
Serial.print("FirstShotY = ");
Serial.println(FirstShotY);
}
Serial.print("Y = ");
Serial.println(sensorValue - FirstShotY);
delay(200);
}
學習 Arduino 的筆記
使用 Arduino 遙控家電
http://www.makezine.com.tw/2012/12/17/%E4%BD%BF%E7%94%A8-arduino-%E9%81%99%E6%8E%A7%E5%AE%B6%E9%9B%BB/
ArduBlock - Arduino圖像化編程
http://blog.ardublock.com/engetting-started-ardublockzhardublock/
http://blog.sina.com.cn/s/blog_69bcf45201016i59.html
http://blog.sina.com.cn/s/blog_69bcf45201016i59.html
arduino reset
u could connect an IO pin X to the reset pin via a 1kR resistor...
if that IO pin X is INPUT/LOW no reset is triggered (like the reset button is unpressed)...
if that IO pin X is OUTPUT/LOW a reset is triggered (like the reset button is pressed)...
//digitalPin 7 is connected to the RESET pin on Arduino
//NOTE: you CANNOT program the board while they are connected
//by default digitalPin 13 will blink upon reset, so stick an LED in there
int interval = 5000;
long int time = 0;
void setup(){
digitalWrite(7, HIGH); //We need to set it HIGH immediately on boot
pinMode(7,OUTPUT); //We can declare it an output ONLY AFTER it's HIGH
// (( HACKHACKHACKHACK ))
Serial.begin(9600); //So you can watch the time printed
}
void loop(){
time = millis();
Serial.println(time);
if(time > interval){
Serial.println("RESET!");
digitalWrite(7, LOW); //Pulling the RESET pin LOW triggers the reset.
}
}
if that IO pin X is INPUT/LOW no reset is triggered (like the reset button is unpressed)...
if that IO pin X is OUTPUT/LOW a reset is triggered (like the reset button is pressed)...
//digitalPin 7 is connected to the RESET pin on Arduino
//NOTE: you CANNOT program the board while they are connected
//by default digitalPin 13 will blink upon reset, so stick an LED in there
int interval = 5000;
long int time = 0;
void setup(){
digitalWrite(7, HIGH); //We need to set it HIGH immediately on boot
pinMode(7,OUTPUT); //We can declare it an output ONLY AFTER it's HIGH
// (( HACKHACKHACKHACK ))
Serial.begin(9600); //So you can watch the time printed
}
void loop(){
time = millis();
Serial.println(time);
if(time > interval){
Serial.println("RESET!");
digitalWrite(7, LOW); //Pulling the RESET pin LOW triggers the reset.
}
}
Arduino PS2搖杆 遊戲搖杆模塊 Joystick 模塊
Arduino 測試實例Demo
/*********************************************************************** Device: Joystick **
** File: EF_Joystick_Test.c **
** **
** Created by ElecFreaks Robi.W /10 June 2011 **
** **
** Description: **
** This file is a sample code for your reference. **
** **
** Copyright (C) 2011 ElecFreaks Corp. **
*********************************************************************/
iint FirstShotX , FirstShotY;
void setup()
{
for(int i=0; i<19; i++)
{
pinMode(i, INPUT);
digitalWrite(i, 1);
}
Serial.begin(9600);
FirstShotX = 0;
FirstShotY = 0;
}
void loop(){
int i, someInt, flag = 0;
for(i=4; i<11; i++)
{
someInt = digitalRead(i);
if(someInt == 0)
{
flag =1;
break;
}
}
if(flag == 1)
{
switch(i)
{
case 4: Serial.println("--------> Button A"); break;
case 5: Serial.println("--------> Button B"); break;
case 6: Serial.println("--------> Button C"); break;
case 7: Serial.println("--------> Button D"); break;
case 8: Serial.println("--------> Button E"); break;
case 9: Serial.println("--------> Button F"); break;
case 10: Serial.println("--------> Button KEY"); break;
default: break;
}
flag=0;
}
int sensorValue = analogRead(A0);
if(FirstShotX == 0)
{
FirstShotX = sensorValue;
Serial.print("FirstShotX = ");
Serial.println(FirstShotX);
}
Serial.print("X = ");
Serial.println(sensorValue - FirstShotX);
sensorValue = analogRead(A1);
if(FirstShotY == 0)
{
FirstShotY = sensorValue;
Serial.print("FirstShotY = ");
Serial.println(FirstShotY);
}
Serial.print("Y = ");
Serial.println(sensorValue - FirstShotY);
delay(200);
}
蜂鳴器的結構原理
蜂鳴器的結构原理
(一)蜂鳴器的介紹
1.蜂鳴器的作用:蜂鳴器是一種一體化結构的電子訊響器,采用直流電源供電,廣泛應用于計算机、打印机、復印机、報警器、電子玩具、汽車電子設備、電話机、定時器等電子產品中作發聲器件。
2.蜂鳴器分類:主要分為壓電式蜂鳴器和電磁式蜂鳴器兩種類型。
3.蜂鳴器的電路圖形符號:蜂鳴器在電路中用字母“H”或“HA”(舊標准用“FM”、“LB”、“JD”等)表示。
2.蜂鳴器分類:主要分為壓電式蜂鳴器和電磁式蜂鳴器兩種類型。
3.蜂鳴器的電路圖形符號:蜂鳴器在電路中用字母“H”或“HA”(舊標准用“FM”、“LB”、“JD”等)表示。
蜂鳴器示意圖
(二)蜂鳴器的結构原理
1.壓電式蜂鳴器:壓電式蜂鳴器主要由多諧振蕩器、壓電蜂鳴片、阻抗匹配器及共鳴箱、外殼等組成。有的壓電式蜂鳴器外殼上還裝有發光二极管。
多諧振蕩器由晶體管或集成電路构成。當接通電源后(1.5V-15V直流工作電壓),多諧振蕩器起振,輸出1.5-2.5kHZ的音頻信號,阻抗匹配器推動壓電蜂鳴片發聲。
壓電蜂鳴片由鋯鈦酸鉛或鈮鎂酸鉛壓電陶瓷材料制成。在陶瓷片的兩面鍍上銀電极,經极化和老化處理后,再與黃銅片或不銹鋼片粘在一起。
2.電磁式蜂鳴器:電磁式蜂鳴器由振蕩器、電磁線圈、磁鐵、振動膜片及外殼等組成。
接通電源后,振蕩器產生的音頻信號電流通過電磁線圈,使電磁線圈產生磁場。振動膜片在電磁線圈和磁鐵的相互作用下,周期性地振動發聲。
多諧振蕩器由晶體管或集成電路构成。當接通電源后(1.5V-15V直流工作電壓),多諧振蕩器起振,輸出1.5-2.5kHZ的音頻信號,阻抗匹配器推動壓電蜂鳴片發聲。
壓電蜂鳴片由鋯鈦酸鉛或鈮鎂酸鉛壓電陶瓷材料制成。在陶瓷片的兩面鍍上銀電极,經极化和老化處理后,再與黃銅片或不銹鋼片粘在一起。
2.電磁式蜂鳴器:電磁式蜂鳴器由振蕩器、電磁線圈、磁鐵、振動膜片及外殼等組成。
接通電源后,振蕩器產生的音頻信號電流通過電磁線圈,使電磁線圈產生磁場。振動膜片在電磁線圈和磁鐵的相互作用下,周期性地振動發聲。
(三)蜂鳴器的制作
(1)制備電磁鐵M:在長約6厘米的鐵螺栓上繞100圈導線,線端留下5厘米作引線,用透明膠布把線圈粘好,以免線圈松開,再用膠布把它粘在一個盒子上,電磁鐵就做好了。
(2)制備彈片P:從鐵罐頭盒上剪下一條寬約2厘米的長鐵片,彎成直角,把電磁鐵的一條引線接在彈片上,再用膠布把彈片緊貼在木板上。
(3)用曲別針做触頭Q,用書把曲別針墊高,用膠布粘牢,引出一條導線,如圖連接好電路。
(4)調節M與P之間的距離(通過移動盒子),使電磁鐵能吸引彈片,調節触點與彈片之間的距離,使它們能恰好接触,通電后就可以听到蜂鳴聲。
(2)制備彈片P:從鐵罐頭盒上剪下一條寬約2厘米的長鐵片,彎成直角,把電磁鐵的一條引線接在彈片上,再用膠布把彈片緊貼在木板上。
(3)用曲別針做触頭Q,用書把曲別針墊高,用膠布粘牢,引出一條導線,如圖連接好電路。
(4)調節M與P之間的距離(通過移動盒子),使電磁鐵能吸引彈片,調節触點與彈片之間的距離,使它們能恰好接触,通電后就可以听到蜂鳴聲。
(四)有源蜂鳴器和無源蜂鳴器
教你區分有源蜂鳴器和無源蜂鳴器
現在市場上出售的一種小型蜂鳴器因其體積小(直徑只有llmm)、重量輕、价格低、結构牢靠,而廣泛地應用在各種需要發聲的電器設備、電子制作和單片机等電路中。
現在市場上出售的一種小型蜂鳴器因其體積小(直徑只有llmm)、重量輕、价格低、結构牢靠,而廣泛地應用在各種需要發聲的電器設備、電子制作和單片机等電路中。
從外觀上看,兩種蜂鳴器好像一樣,但仔細看,兩者的高度略有區別,有源蜂鳴器a,高度為9mm,而無源蜂鳴器b的高度為8mm。如將兩種蜂鳴器的引腳都朝上放置時,可以看出有綠色電路板的一種是無源蜂鳴器,沒有電路板而用黑膠封閉的一種是有源蜂鳴器。
迸一步判斷有源蜂鳴器和無源蜂鳴器,還可以用萬用表電阻檔Rxl檔測試:用黑表筆接蜂鳴器"+"引腳,紅表筆在另一引腳上來回碰触,如果触發出咔、咔聲的且電阻只有8Ω(或16Ω)的是無源蜂鳴器;如果能發出持續聲音的,且電阻在几百歐以上的,是有源蜂鳴器。
有源蜂鳴器直接接上額定電源(新的蜂鳴器在標簽上都有注明)就可連續發聲;而無源蜂鳴器則和電磁揚聲器一樣,需要接在音頻輸出電路中才能發聲。
迸一步判斷有源蜂鳴器和無源蜂鳴器,還可以用萬用表電阻檔Rxl檔測試:用黑表筆接蜂鳴器"+"引腳,紅表筆在另一引腳上來回碰触,如果触發出咔、咔聲的且電阻只有8Ω(或16Ω)的是無源蜂鳴器;如果能發出持續聲音的,且電阻在几百歐以上的,是有源蜂鳴器。
有源蜂鳴器直接接上額定電源(新的蜂鳴器在標簽上都有注明)就可連續發聲;而無源蜂鳴器則和電磁揚聲器一樣,需要接在音頻輸出電路中才能發聲。
Updating the Atmega8U2 on an Uno or Mega2560 using DFU
http://arduino.cc/en/Hacking/DFUProgramming8U2
The Arduino Uno and Mega 2560 have been shipping with the updated (rev. 0001) version of the ATmega8U2 firmware since around May, 2011. To check which version of the firmware is on your board, connect it to your computer and follow the directions for your operating system:
If your board has rev. 0001 of the 8U2 firmware on it, there's no need to upgrade it.
The Arduino Uno and Mega 2560 have been shipping with the updated (rev. 0001) version of the ATmega8U2 firmware since around May, 2011. To check which version of the firmware is on your board, connect it to your computer and follow the directions for your operating system:
- Windows: locate the board in the Device Manager (it should be under Ports), right click on it and select "Properties"; in the resulting dialog, click on "driver details" in the "driver" tab. In one the properties, you should the VID, PID, and the revision number.
- Mac OS X: run the System Profiler application (e.g. by selecting "About This Mac" from the Apple menu and clicking the "More Info..." button); go to the USB sheet and click on the item for the Arduino board. The 8U2 firmware version is listed as "version" (e.g. 0.01 for rev. 0001).
Arduino Ethernet Shield -W5100
官網
http://www.arduino.cc/en/Main/ArduinoEthernetShield
網購介紹
http://www.playrobot.com/cart/shop.php?id=652&factory=&header=&sub=&Fno=&date_buy=
http://www.arduino.cc/en/Main/ArduinoEthernetShield
網購介紹
http://www.playrobot.com/cart/shop.php?id=652&factory=&header=&sub=&Fno=&date_buy=
Arduino Ethernet WITHOUT PoE
Arduino Ethernet 網路控制器(無掛POE)本身結合arduino與ethernet+SD卡的功能於一身 與arudino一樣同樣擁有 14組數位IO
6組類比輸入(其中10.11.12.13如使用ethernet會被占用)
而POE指的是-->power of ethernet, 也就是網路線供電的裝置, 如有需要可以考慮另一款的產品 Arduino Ethernet WITH PoE 注意: 此款產品如要更新程式 需搭配USBtoTTL5V的燒錄器(訊號轉換裝置)
Ethernet的使用透過SPI訊號-->10.11.12.13
SD卡的使用也透過SPI訊號-->4.11.12.13
藉由SPI訊號中的SS腳位(slave select)的觸發來處理~
http://www.aroboto.com/shop/goods.php?id=506
6組類比輸入(其中10.11.12.13如使用ethernet會被占用)
而POE指的是-->power of ethernet, 也就是網路線供電的裝置, 如有需要可以考慮另一款的產品 Arduino Ethernet WITH PoE 注意: 此款產品如要更新程式 需搭配USBtoTTL5V的燒錄器(訊號轉換裝置)
Ethernet的使用透過SPI訊號-->10.11.12.13
SD卡的使用也透過SPI訊號-->4.11.12.13
藉由SPI訊號中的SS腳位(slave select)的觸發來處理~
http://www.aroboto.com/shop/goods.php?id=506