รถเข็นของคุณว่างเปล่า!
PROJECT 10
SERIAL COMMUNICATION CONTROL RC SERVO
Back to Project 9 | Go to Project 11 |
———————————————————————————————————————————————————
COMPONENT NEEDED
———————————————————————————————————————————————————-RC SERVO MOTOR | |
JUMPER WIRE |
———————————————————————————————————————————————————-
CONNECTION
———————————————————————————————————————————————————-
In this project, there are 2 RC servo motor signal wire (YELLOW) connected to Arduino Duemilanove digital pin-2 and pin-3. RED wire are connected to +5V while BLACK wire connected to ground(GND).
———————————————————————————————————————————————————-
CODE OVERVIEW
———————————————————————————————————————————————————-
int value; Assign the value as integer to store the value of servo position from 0 to 180. unsigned int old_value; Store the last value of the servo position.
servo1.write(90); Initialize and move the servo1 to 90 degree. old_value = 90; Set and store the position of servo to old_value.
If (value > 180) value = 180; Check if the value is larger than 180. if yes then set it to maximum 180. else if (value < 0) value = 0; Check if the value is less than 0. if yes then set it to minimum 0. if(value < old_value) Check if the current value of servo position is less then the old_value or last value. old_value = value; Assign the current value to old_value as the memory for the microcontroller to determine servo position.
Back to Project 9 | Go to Project 11 |