If you want to follow along at home, you can order the Arduino Kit we are using HERE.
Typically, the servos in electronics kits are not the best ones, but are suitable to learn with. Heads up that in Lesson 33 we will be using a joystick to control two servos. If you want to get ready for that lesson, go ahead and order your HiTEC Servos.
This is the code that we developed in the video above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
int Xpin=A0; int Ypin=A1; int Spin=2; int Xval; int Yval; int Sval; int dt=200; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(Xpin,INPUT); pinMode(Ypin,INPUT); pinMode(Spin,INPUT); digitalWrite(Spin,HIGH); } void loop() { Xval=analogRead(Xpin); Yval=analogRead(Ypin); Sval=digitalRead(Spin); delay(dt); Serial.print("X Value = "); Serial.print(Xval); Serial.print(" Y Value = "); Serial.print(Yval); Serial.print(" Switch State is "); Serial.println(Sval); } |