Hallo zusamm,
bin mir sicher dass es ein anfängerfehler ist:
ich wollte den servo code mit einer tasterschaltung erweitern. das der servo weiter wie bisher funktioniert, ich aber zusatzlich über ein O/I signal (in dem fall deine gehackter bewegungsmelder (4,5V)...) deine led ansteuere..
aber beim prüfen wird ein fehler angegeben an der markeirten stelle:
// include the servo library
#include <Servo.h>
Servo myServo; // create a servo object
int const potPin = A0; // analog pin used to connect the potentiometer
int potVal; // variable to read the value from the analog pin
int angle; // variable to hold the angle for the servo motor
const int buttenpin = 38; //pin 38 wird initialisiert
const int ledpin = 9;
int Sensorstatus = 0;
void setup() {
myServo.attach(36); // attaches the servo on pin 9 to the servo object
Serial.begin(9600); // open a serial connection to your computer
pinMode(ledpin, OUTPUT); // pin 9 für led wird als eingang deklariert
pinMode(buttenpin, INPUT); // pin 38 fürden sensor wirs
}
void loop() {
potVal = analogRead(potPin); // read the value of the potentiometer
// print out the value to the serial monitor
Serial.print("potVal: ");
Serial.print(potVal);
Sensorstatus = digitalRead(buttenpin);
// scale the numbers from the pot
angle = map(potVal, 0, 1023, 0, 179);
// print out the angle for the servo motor
Serial.print(", angle: ");
Serial.println(angle);
// set the servo position
myServo.write(angle);
if (Sensorstatus == HIGH) (
// turn LED on:
digitalWrite(ledpin, HIGH); // <------------hier wird ein fehler angezeit!
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
// wait for the servo to get there
delay(15);
}
was habe ich falsch gemacht??
gruß andy