iT邦幫忙

1

Arduino用javascript寫,但無怎麼找到相關套件的javascript語法呢?

Grove GSR 皮膚電流感應傳感器 要怎找 Johnny-Five 的對應的javaScript的語法

請問這個要找什麼樣的關鍵字。

我只找到原本的程式,但不曉得對應的javaScript的語法怎麼找。

const int BUZZER=3;
const int GSR=A2;
int threshold=0;
int sensorValue;

void setup(){
  long sum=0;
  Serial.begin(9600);
  pinMode(BUZZER,OUTPUT);
  digitalWrite(BUZZER,LOW);
  delay(1000);
  
  for(int i=0;i<500;i++)
  {
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold =");
   Serial.println(threshold);
  }

void loop(){
  int temp;
  sensorValue=analogRead(GSR);
  Serial.print("sensorValue=");
  Serial.println(sensorValue);
  temp = threshold - sensorValue;
  if(abs(temp)>50)
  {
    sensorValue=analogRead(GSR);
    temp = threshold - sensorValue;
    if(abs(temp)>50){
    digitalWrite(BUZZER,HIGH);
    Serial.println("YES!");
    delay(3000);
    digitalWrite(BUZZER,LOW);
    delay(1000);}
  }
  }
jbuduoo iT邦新手 4 級 ‧ 2021-04-14 16:38:17 檢舉
還是用原生的語言寫好了
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

2
EricChu
iT邦新手 4 級 ‧ 2021-04-12 08:15:15

其實Arduino寫的是C++,不是JavaScript,試試換個關鍵字再查

jbuduoo iT邦新手 4 級 ‧ 2021-04-14 16:38:01 檢舉

謝謝

2
King Tzeng
iT邦新手 3 級 ‧ 2021-04-16 11:24:41

您好~
我之前的鐵人賽主題有寫Johnny-Five的應用,不知道能否幫助您^^
PS:因為有人邀請我回答/images/emoticon/emoticon37.gif

剛查了一下這個Seneor類似偵測皮膚上流過的電流有多少,也就是皮膚產生多少電阻,如果往這個方向去想的話,可以參考Grove可變電阻單元
http://johnny-five.io/examples/grove-rotary-potentiometer/

搭配Johnny-five類比訊號的部分一直最後通過的電流剩多少,然後寫出您要的程式~
可以參考Johnny-five中的Sensor篇中的Analog Sensor
http://johnny-five.io/api/sensor/

因為不知道您的需求是什麼,但提供一些方向供您參考^^
希望對您有一些些幫助/images/emoticon/emoticon08.gif

我要發表回答

立即登入回答