Arduino UnoとCAN-BUSシールドV2を使用してCAN-BUSのスリープとウェイクアップを繰り返すプログラムを作りたいです。
でもINT(2)をdigital.Read()した返り値に変化がありません。
どうしたらいいですか?
Arduino
1#include <mcp_can.h> 2#include <mcp_can_dfs.h> 3 4MCP_CAN CAN(9); 5 6void setup() 7{ 8 pinMode(2, INPUT); 9 Serial.begin(57600); 10 whie(CAN_OK != CAN.begin(CAN_500KBPS, MCP_16MHz)) 11 { 12 Serial.println("CAN_NG"); 13 } 14} 15 16void loop() 17{ 18 static byte state = 0; 19 byte a = digital.Read(2); 20 Serial.println(a); 21 byte b = 0; 22 23 if(state == 0) 24 { 25 Serial.print("sleep : "); 26 b = CAN.sleep(); 27 Serial.println(b); 28 state = 1; 29 delay(2000); 30 } 31 else 32 { 33 Serial.print("wake : "); 34 b = CAN.wake(); 35 Serial.println(b); 36 state = 0; 37 delay(2000); 38 } 39} 40
ライブラリURL
回答1件
あなたの回答
tips
プレビュー