본문 바로가기

IoT/Intel Edison

Grove – Servo

Grove - Servo

Servo is absolutely a fun motion control device to play! Via a servo library built in Arduino IDE, you can locate it at any position between 0 to 180 degrees. With 4 shafts in different shapes coming, this servo is ready to drive a little fan, lift an object, or mimic a clock hand.

Hardware Required
- Intel® Edison for Arduino
- Grove Base Shield v2
- Grove Servo
- Grove Rotary Angle Sensor

- Working Voltage - 5V

Circuit



Schematic


Code 
#include <Servo.h>
Servo groveServo; //create a object

int potentiometer = 0;
int shaft;

void setup()
{
  //Serial.begin(9600);
  groveServo.attach(3); //the servo is attached to D3
  pinMode(potentiometer, INPUT);
}

void loop()
{
  shaft = analogRead(potentiometer);
  //Serial.println(shaft);
  shaft = map(shaft, 0, 1023, 0, 179); 
  //analog input data range from 1~1023, but servo   
  groveServo.write(shaft);             //only reflects to data ranging from 1~179.
  delay(15);
}

See  Also


Reference sites




'IoT > Intel Edison' 카테고리의 다른 글

Intel Edison Stop Arduino functionality  (0) 2015.03.23
Grove - Touch & Relay  (0) 2015.02.21
Grove - LCD RGB Backlight  (0) 2015.02.09
Grove – Rotary Angle Sensor  (0) 2015.01.24
Grove - Sound Sensor  (0) 2015.01.24