autoregulated greenhouse

Hi everyone,

this week we learned how to use a servo motor with an Arduino
We used the sg90 servo motor:

towerpro-sg90
Torque: 4.8V (1.6 kg-cm)
Speed: 4.8V 0.1 sec/60°
Weight: 9g
Dimensions : 23mm x 12.2mm x 29 mm
Rotational Range : 180°

In our project we will use 2 servo motors
Here is the code:

#include <Servo.h>
Servo servo;

int const potPin = A0;
int val;
int angle;

void setup()
{
servo.attach(11);
Serial.begin(9600);
}

void loop()
{
val = analogRead(potPin);
Serial.print(“val: “);
Serial.print(val);
angle = map(val, 0, 1023, 0, 179);
Serial.print(“, angle: “);
Serial.println(angle);
servo.write(angle);
delay(10);
}
On the next session, we will try to use the moisture sensor and the light sensor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s