Что делать? Вот что пишет Изменены опции сборки, пересобираем все sketch_nov04a.ino:2:24: fatal error: Ultrasonic.h: No such file or directory compilation terminated. Ошибка компиляции. Вот скетч Код (C++): #include <Servo.h> #include <Ultrasonic.h> #define RIGHT_HAND_PIN 2 #define LEFT_HAND_PIN 3 #define HEAD_PIN 4 #define TRIGGER_PIN 7 #define ECHO_PIN 6 Servo rightHand; Servo leftHand; Servo head; Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN); void setup() { Serial.begin(9600); rightHand.attach(RIGHT_HAND_PIN); leftHand.attach(LEFT_HAND_PIN); head.attach(HEAD_PIN); } void loop() { head.write(90); delay(1000); float cmMsec; long microsec = ultrasonic.timing(); cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM); Serial.print("CM: "); Serial.println(cmMsec); head.write(135); delay(1000); head.write(45); delay(1000); head.write(90); leftHand.write(0); rightHand.write(0); delay(500); leftHand.write(180); rightHand.write(180); delay(500); } Брал отсюда http://geektimes.ru/post/257204/
Все равно не работает пишет sketch_nov04a.ino: In function 'void loop()': sketch_nov04a:31: error: 'class Ultrasonic' has no member named 'timing' sketch_nov04a:32: error: 'class Ultrasonic' has no member named 'convert' In file included from sketch_nov04a.ino:2:0: C:\Users\влад\Desktop\arduino-nightly\libraries\Ultrasonic/Ultrasonic.h:13:12: error: expected unqualified-id before numeric constant #define CM 1 ^ sketch_nov04a.ino:32:53: note: in expansion of macro 'CM' 'class Ultrasonic' has no member named 'timing'
Зачем библиотека? Код (C++): unsigned int getDistance(byte trig, byte ping) { // указать тригерную и приемную ноги unsigned int duration = 0; unsigned int Distance = 0; digitalWrite(trig, LOW); delayMicroseconds(2); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); duration = pulseIn(ping,HIGH); Distance = duration/29/2; return Distance; }