私はarduinoとC ++に不慣れで、上記のエラーに遭遇しています。それはかなり自明のように思えます、しかし私はコードの中に欠けているコンマを見つけることができません。 binaryOut
関数を追加する前にコードが正常に機能していたので、そこにあると思います。
Arduinoがどこでエラーが発生しているのかを示してくれたらいいでしょう。
任意の助けは大歓迎です。
#define ultrasonic 6
#define buzzer 3
#define latchPin 8
#define clockPin 12
#define dataPin 11
int sound = 250;
void setup(){
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop(){
long duration, inches;
pinMode(ultrasonic, OUTPUT);
digitalWrite(ultrasonic, LOW);
delayMicroseconds(2);
digitalWrite(ultrasonic, HIGH);
delayMicroseconds(5);
digitalWrite(ultrasonic, LOW);
pinMode(ultrasonic, INPUT);
duration = pulseIn(ultrasonic, HIGH);
inches = microsecondsToInches(duration);
if(inches > 36 || inches <= 0){
Serial.print("Out of range. ");
Serial.println(inches);
}else{
Serial.print(inches);
Serial.println(" in.");
}
binaryOut(inches);
digitalWrite(latchPin, LOW);
digitalWrite(latchPin, HIGH);
delay(1000);
}
long microsecondsToInches(long microseconds){
/* 73.746 microseconds per inch
* Sound travels at 1130 ft/s */
return microseconds/73.746/2;
}
void binaryOut(byte dataOut){
Serial.println(dataOut);
boolean pinState;
for(int i = 0; i <= 7; i++){
digitalWrite(clockPin, LOW);
if(dataOut & (1<
編集:ArduinoではHIGHとLOWは定義された定数です( http://arduino.cc/en/Reference/Constants booleanはプリミティブデータ型です( http://en.wikipedia.org/wiki)。/Primitive_data_type )
EDIT2: I modeled the binaryOut
from the example (shiftOut
) in the image below.

編集3:正確なエラーは次のとおりです。
In file included from UltrasonicRangeSensorAJ.ino:7:
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:111: error: expected ',' or '...' before numeric constant
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:112: error: expected ',' or '...' before numeric constant
最初は "111"と "112"が行番号に対応していると思いましたが、私のコードは90行以下です。