hi evrybody
i have servo motor controled over Ldr sensor
if the ldr become more than 70 the servo wil start from 0 to 90
i need to update it to be working with 2 types
i need it to be:
if the light source send signal one time the servo will go to from 0 to 90
and if the light source blink 3 times will send the servo from 0 to 180
please i need that help
thanks
my code
#include <Servo.h>
int potpin=0;// initialize analog pin 0, connected with photovaristor
int ledpin=13;// initialize digital pin 13, output regulating the brightness of LED
int greenLed= 12;
int val=0;// initialize variable val
Servo myServo; // define servo name
/* The setup() function is called when a sketch starts. It is used to initialize variables, pin modes, start using libraries, etc. This function will only run once, after each power up or reset of the Arduino board. */
void setup()
{
pinMode(ledpin,OUTPUT);// set digital pin 13 as “output”
pinMode(greenLed, OUTPUT);
Serial.begin(9600); // set baud rate at “9600”
myServo.attach(9); // servo pin
myServo.write(0); // servo start position
}
/* The loop() function executes the program repeatedly until Specified. */
void loop()
{
val=analogRead(potpin);// read the analog value of the sensor and assign it to val
Serial.println(val);// display the value of val
analogWrite(ledpin,val);// turn on the LED and set up brightness(maximum output value 255)
delay(10);// wait for 0.01
if(val>70)
{
myServo.write(0);
}
else
{
myServo.write(90);
}
}