伽利略開(kāi)發(fā)板和BeeMail(三):對象
原型擴展板有利于UNO用于初步檢驗和伽利略板的轉移,從UNO的轉移可以確定,伽利略板的I/O引腳在嵌入式啟動(dòng)和Arduino草圖啟動(dòng)期間處于上拉狀態(tài)(取決于5V還是3.3V電壓)。
本文引用地址:http://dyxdggzs.com/article/265933.htm上面所說(shuō)只是在理想狀態(tài)下的負邏輯,但馬達系統其實(shí)并不太適用。這里我按照GPIO的思路將引腳初始化為高電平,看看能不能找出其他辦法。
代碼部分
以下代碼僅為對蜜蜂基于電位計作為輸入的測試。若對蜜蜂不加干涉,程序自動(dòng)上鎖,我在這里遇到了麻煩。我去檢查串聯(lián)端口和開(kāi)發(fā)板端口是否正常,可直到現在我仍舊不清楚到底是哪里出了問(wèn)題。
//------------------------------------------------------------ START LICENSE
/*The MIT License (MIT)
Copyright (c) 2014 Carlyn Maw
特此授權許可,在此情況下本軟件免費,并允許任何人復制此軟件及相關(guān)文檔,不限制銷(xiāo)售,任何人有權使用、復制、修改、合并、出版、發(fā)行、授予執照或銷(xiāo)售軟件副本,供任何對其有幫助的使用者使用。
以上版權聲明和許可聲明包括軟件所有副本和可觀(guān)部分。
軟件未加任何明指或暗指的擔保,按現狀出售,但不限于為特定目的和不侵權的適銷(xiāo)性及適用性的擔保。
在任何情況下,作者或版權持有人,都無(wú)權要求任何索賠或有關(guān)損害賠償的其他責任,不管在本軟件的使用上或其他買(mǎi)賣(mài)交易中是否涉及合同、侵權或其他行為。
*/
// ---------------------------------------------------------------- END LICENSE
//This code is testing code for the circut to make sure all of the
//physical Arduino I/O is working. It checks a potentiometer or other
//sensors on the AO PIN and equates it to the future number of mails
//in the inbox.
//On each pin 9, 10 and 11 are 220 Ohm resistors leading to the bases of
//PN2222A transistors. The collector is attached to the motor and the
//emitter to ground.
//------------------------------------------------- OUTPUTS AND THEIR VARIABLES
//the total number of bees bing controlled
const int beeTotalNumber = 3;
int beePins[beeTotalNumber] = {9, 10, 11 };
//INPUTS AND THEIR VARIABLES
int howManyNewEmails = 0;
//-------------------------------------------------------- GLOBAL BEE SETTINGS
//the number of emails the bees hit maximum freakout.
//ideally it should be divisible by the number of
//beeActivityLevels
int maxBeeVar = 1023;
//how many different states the Bees can be in
const int beeActivityLevels = 16;
//The area that dictates the 16 BeeActivityLevels.
int b[beeActivityLevels][beeTotalNumber] =
{
{ 0, 0, 0 },
{ 0, 0, 50 },
{ 0, 50, 50 },
{ 50, 50, 50 },
{ 50, 50, 100 },
{ 50, 100, 100 },
{ 100, 100, 100 },
{ 100, 100, 150 },
{ 100, 150, 150 },
{ 150, 150, 150 },
{ 150, 150, 200 },
{ 150, 200, 200 },
{ 200, 200, 200 },
{ 200, 200, 250 },
{ 200, 250, 250 },
{ 255, 255, 255 },
};
//---------------------------------------------------------------------- SETUP
void setup() {
Serial.begin(9600);
}
//----------------------------------------------------------------------- LOOP
void loop() {
//get the data determining bee behavior
howManyNewEmails = analogRead(A0);
//Serial.println(howManyNewEmails);
//update the bees
updateBees(howManyNewEmails, maxBeeVar);
//mini-pause
delay(10);
}
//---------------------------------------------------------------- updateBees()
void updateBees(int v, int maxVal) {
//ignore any values of V above maximum freakout level
// v = min(v, maxVal); does not work in Intel Galileo MacOS IDE
if (v > maxVal) {
v = maxVal;
}
//map the newly constrained V to the beeActivityLevel array
//the top value is 1 less than the number than the array size
//because the an array starts with the index number 0
int mappedV = map(v, 0, maxVal, 0, beeActivityLevels-1);
//Serial.println(mappedV);
//for each bee, get the value it supposed to be and set it there
for (int i=0; i <= beeTotalNumber-1; i++){
//Serial.println(b[mappedV][i]);
analogWrite(beePins[i], b[mappedV][i]);
}
}
電容器相關(guān)文章:電容器原理
評論