top of page
Writer's pictureLasha Areshidze

Arduino Flower | Lasha A





Here is the code used.


#include <Servo.h>


int sensorPin = A0;

int servoPin = 9;


int sensorValue = 0;

int servoGrad = 90;

int tolerance = 40;


Servo myservo;


void setup() {

pinMode( sensorPin, INPUT);

myservo.attach( servoPin );

myservo.write( servoGrad );

}


void loop() {

sensorValue = analogRead(sensorPin);

if ( sensorValue < (512-tolerance) )

{

if (servoGrad < 180) servoGrad++;

}


if ( sensorValue > (512+tolerance) )

{

if (servoGrad > 0) servoGrad--;

}


myservo.write( servoGrad );


delay(100);

}

15 views1 comment

1 Comment


Johnny
Johnny
Mar 11, 2019

Great job! kiss mark sunflower lol however, you missed the image, video, explanation and late upload. I only can give you 20 for this, but if you upload video and explanation and image to cover it up. I will add more points on this. good luck

Like
bottom of page