I decided to use light measuring sensor and continuous rotation servo to turn servo based on the light ammount. I have released full code for free use.
Basic idea
Measure ammount of light and divide it with 5 to get speed for servo and then turn servo. This could be used to to automatically lower curtains when night comes maybe
//Petri Mäki
// 19.4.2013
// http://www.petrimaki.wordpress.com#include <Servo.h>
Servo myServo;float lightValue;
int lightPin = 1;
int servoPin = 2;
int delayTime = 1000; // msvoid setup(){
Serial.begin(9600);
myServo.attach(servoPin);
}void loop()
{lightValue = analogRead(lightPin);
Serial.print(”Light value: ”);
Serial.println(lightValue); //Print light value, not sure what the scales are. 1000 seems to be realy dark and close 0 means there is much light/* Turn light value to speed. I decide to divide light value
with 5 since i think it gives good accurate. e.g 1000 / 5 = 200
where 1000 would be realy dark light value and 200 is result
for speed*/
int newSpeed = lightValue / 5;
Serial.print(”Speed: ”);
Serial.println(newSpeed);
if(newSpeed > 90) {
if (newSpeed > 180) { // Speed can only be 180 MAX
newSpeed = 180;
}myServo.write(newSpeed);
} else {
if (newSpeed < 0) {
newSpeed = 0; //Speed cannot be -1
}
myServo.write(newSpeed);
}
delay(delayTime); //ms}
// Continuous rotation servos
// Controlling continuous rotation servos with servo.h
// 90 = servo wont move
// 0 = Full speed to left
// 180 = Full speed to rightvoid servoRight(int rotatingSpeed) { // Turn right based on value
myServo.write(rotatingSpeed);
}void servoLeft(int rotatingSpeed) { //Turn left based on value
myServo.write(rotatingSpeed);
}
What i used:
- Arduino UNO
- Breadboard
- Jumper Wires
- Light sensor (Unknown model)
- SpringRC SM-S4303R Continuous Rotation Servo
Source:
- Tero karvinen – HAAGA-HELIA teacher (http://terokarvinen.com/)
- http://botbook.com/
This page is licensed under a GNU General Public License v2
Hi,Dear,
Glad to contact you today.
After some research ,we would like to suggest our another servo it might be of your interest,it is same specification with Spring SM-4303R but lower cost.
FS5103R: 3kg Standard continous rotation servo plastic gears 2 bearing
Size: 40.8*20.1*38mm
Weight: 36g
Speed: 0.18sec/60°(max 55rpm at 4.8V)
0.16sec/60°(max 62rpm at6V)
Torque: 2.5kg.cm (4.8V)
3kg.cm (6V)
Apply for robot
If you are interested in this servos,please feel free to contact us,we are ready to do the best for you on time!
Thanks a lot.Wish you a pleasant day!
Best Regards
Jenny Deng
Shenzhen FEETECH RC Model CO.,Ltd.
http://www.feetechrc.com
http://feetechrc.en.alibaba.com/
Ali account:cn1510825345
MSN: Jenny-fitec@hotmail.com
Skype: Jenny-fitec
QQ:2337371583
Tel: +86 755 89335266
Fax: +86 755 26966318
Factory address:
Block 2,5/F, Jinshunli Industrial Zone, Heng Yi Road,
Henggang,Longgang District, Shenzhen,518115,China