티스토리 뷰
In order to make 'Pet feeder' solution, I bought one of motors to open and close pet feeder door. I have been searching the web site to find out appropriate mechanical door for pet feeder and here is the list what types are there.
# How to work for feeding.
1. Circle style
If I press button to feed, food is falling out from the box it might be fed due to moving like circle type.
http://nt.petplanet.co.uk/images/product_images/new_product_images/prt/60682.jpg
2. Window style
Exact amount of food is in the tray but it is loocked by kind a window. If I press the button the window will be opened.
http://www.wirelesswhiskers.com/ec/index.php
3. Tray style
Like #2 stype, exact mount of food is in the tray but it is placed inside. If I press the button, the tray can be opend.
http://www.styletails.com/2016/01/12/trends-7-smart-interactive-pet-feeders-for-when-youre-not-home/
Not sure what type is better than other but at least 1 actuator needs to make it feeder and I bought SG-90 servo motor. Because the feeder is needed to rotate around 180 degree to open and close. Also SG-90 servo is very simple to control using pwm way. Arduino provides apis to control easier than other OS.
# SG-90 Servo
There is 3 pin to control which are VCC(5V), GND, PIN and provided fans to attach with servo motor. Once I make up circuit to control like below.
Very simple circuit to control and everyone can control using arduino IDE otherwise we can handle it via pwm driver. Also If we want to control the servo motore detailed, we can use servo motor driver to handle detailed. But I dont thing the driver is not needed in my solution.
# PWM control, but we dont need to know all !
The servo motor is controled by PWM(pulse Width Modulation). What is the key factor fo PWM is, we dont maintain 5V into the pin and interate on and off which can make 'pulse width'. The spec of SG-90 is rotating from -90~90 degree which means 180 degree can be rotated. Apart from the basic theory, Arduino IDE provides Serve library to control. If you add up 'Server.h' and you can use below apis.
- attach(pin, min, max) : Initializing servo
.pin : pin number
.min : pulse width for 0 degree(default 544ms)
.max : pulse width for 180 degree(default(2400ms)
- wirte(value) : control angle for servo
- read() : read current angle
- dettach() : disconnect servor motor
Here is the code for basic control of Servo.
#includeServo servo; int servoPin = 7; int min_value = 544; int max_value = 2400; int angle = 0; void setup() { Serial.begin(9600); Serial.println("Servo Value = ?"); servo.attach(servoPin, min_value, max_value); servo.write(90); } void loop() { if(Serial.available() > 0){ int servo_value = Serial.parseInt(); servo.write(servo_value); Serial.println(servo_value); } }
If you have done to make up the code and circuit, let download to Arduino and open serial window.
According to the anle that I put in serial wondow, servo motor will be rotated. Here is the movie clip that I took when I tested.
So far, I have completed to control for button(ISR) and Actuator(servo). It means, If I press button, servo motor will be rotated also if some command is sending from other device, it will be rotated if it receives. Wrap it up today and move to the next section for wifi and cloud control based on Arduino~!!
'Technology > Arduino' 카테고리의 다른 글
[Project] Pet Feeder with Arduino + EV3 (0) | 2017.02.12 |
---|---|
WIFI + WebServer + Arduino + LED control (0) | 2017.01.31 |
EV3 + Arduino connection via I2C (0) | 2017.01.22 |
ISR or Falling?? (0) | 2017.01.11 |
Let's start Arduino Development ~! (0) | 2017.01.02 |