I can't seem to find the error I made; can anyone help me?
The error message: 'Servo_Pointer' was not declared in this scope
I get the error at the end of the code with the line: Servo_Pointer.write(servo_pos)
The code:
const int photo_left = A0; // select the input pins for the photoresistor
const int photo_right = A1;
const int ledPin_1 = 2; // These leds will be used for the testing of the pointing of the servo motor
const int ledPin_2 = 4;
const int ledPin_3 = 7;
const int ledPin_4 = 8;
const int ledPin_5 = 12;
const int photoValue = 0; // variable to store the value coming from the photoresistor
const int numReadings = 10;
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin_1, OUTPUT);
pinMode(ledPin_2, OUTPUT);
pinMode(ledPin_3, OUTPUT);
pinMode(ledPin_4, OUTPUT);
pinMode(ledPin_5, OUTPUT);
Serial.begin(9600);
#include <Servo.h>
Servo Servo_Pointer;
Servo_Pointer.attach(9);
int servo_pos = 0;
// initialize serial communication with computer:
Serial.begin(9600);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading ) {
readings[thisReading] = 0;
}
}
void loop() {
Servo_Pointer.write(servo_pos); // tell servomotor to go to position in variable 'servo_pos'
delay(15); // waits 15ms for the servo to reach the position
// turn the ledPin on
delay(15);
}