新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 牛人業(yè)話 > 伽利略開發(fā)板和BeeMail(三):對象

伽利略開發(fā)板和BeeMail(三):對象

作者:EEPW編譯 時(shí)間:2014-11-25 來源:電子產(chǎn)品世界 收藏

  原型擴(kuò)展板有利于UNO用于初步檢驗(yàn)和板的轉(zhuǎn)移,從UNO的轉(zhuǎn)移可以確定,板的I/O引腳在嵌入式啟動和Arduino草圖啟動期間處于上拉狀態(tài)(取決于5V還是3.3V電壓)。

本文引用地址:http://butianyuan.cn/article/265933.htm

  上面所說只是在理想狀態(tài)下的負(fù)邏輯,但馬達(dá)系統(tǒng)其實(shí)并不太適用。這里我按照GPIO的思路將引腳初始化為高電平,看看能不能找出其他辦法。

  代碼部分

  以下代碼僅為對蜜蜂基于電位計(jì)作為輸入的測試。若對蜜蜂不加干涉,程序自動上鎖,我在這里遇到了麻煩。我去檢查串聯(lián)端口和端口是否正常,可直到現(xiàn)在我仍舊不清楚到底是哪里出了問題。

  //------------------------------------------------------------ START LICENSE

  /*The MIT License (MIT)

  Copyright (c) 2014 Carlyn Maw

  特此授權(quán)許可,在此情況下本軟件免費(fèi),并允許任何人復(fù)制此軟件及相關(guān)文檔,不限制銷售,任何人有權(quán)使用、復(fù)制、修改、合并、出版、發(fā)行、授予執(zhí)照或銷售軟件副本,供任何對其有幫助的使用者使用。

  以上版權(quán)聲明和許可聲明包括軟件所有副本和可觀部分。

  軟件未加任何明指或暗指的擔(dān)保,按現(xiàn)狀出售,但不限于為特定目的和不侵權(quán)的適銷性及適用性的擔(dān)保。

  在任何情況下,作者或版權(quán)持有人,都無權(quán)要求任何索賠或有關(guān)損害賠償?shù)钠渌?zé)任,不管在本軟件的使用上或其他買賣交易中是否涉及合同、侵權(quán)或其他行為。

  */

  // ---------------------------------------------------------------- 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)文章:電容器原理



上一頁 1 2 下一頁

關(guān)鍵詞: 伽利略 BeeMail 開發(fā)板

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉