Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo engine1;
- int incomingByte =0;
- int pos_engine1 = 0;
- int mounting_pount = 21; //here the engine starts turning
- void setup()
- {
- engine1.attach(8);
- Serial.begin(9600);
- }
- void loop()
- {
- if (Serial.available() > 0)
- {
- incomingByte = Serial.read();
- Serial.println(incomingByte);
- if (incomingByte == 119 && pos_engine1 < 180)
- {
- if (pos_engine1 < 21)
- {
- pos_engine1 = 21;
- }
- else
- {
- pos_engine1 ++;
- }
- }
- else if (incomingByte == 115 && pos_engine1 > 0 && !pos_engine1 > 21)
- {
- pos_engine1 --;
- }
- }
- engine1.write(pos_engine1);
- Serial.println(pos_engine1);
- }
Add Comment
Please, Sign In to add comment